Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_FCDReplay.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A device which replays recorded floating car data
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
26#include "MSVehicleDevice.h"
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class SUMOSAXReader;
33
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
45public:
49 static void insertOptions(OptionsCont& oc);
50
51
62 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
63
66 static void init();
67 static SUMOTime parseNext(SUMOTime t);
68
69public:
72
74 bool move(SUMOTime currentTime);
75
77 const std::string deviceName() const override {
78 return "fcd-replay";
79 }
80
84 std::string edgeOrLane;
85 double lanePos;
86 double speed;
87 double angle;
88 };
89
90 typedef std::vector<TrajectoryEntry> Trajectory;
91
92private:
93 class FCDHandler;
94
95 void setTrajectory(const Trajectory* t, const FCDHandler* source, bool replayCreated) {
96 myTrajectory = t;
98 myTrajectorySource = source;
99 myReplayCreated = replayCreated;
100 }
101
107 MSDevice_FCDReplay(SUMOVehicle& holder, const std::string& id);
108
109 class MoveVehicles : public Command {
110 public:
111 SUMOTime execute(SUMOTime currentTime) override;
112 private:
115 };
116
117 class FCDHandler : public SUMOSAXHandler, public MapMatcher<MSEdge, MSLane, MSJunction> {
118 public:
119 FCDHandler(const std::string& file);
121 return myTime;
122 }
123 void updateTrafficObjects(const SUMOTime intervalStart);
124
125 void setFinished() {
126 myFinished = true;
127 }
128
129 bool isFinished() const {
130 return myFinished;
131 }
132
133 const std::map<std::string, Trajectory>& getTrajectories() {
134 return myTrajectories;
135 }
136
137 protected:
139
140
148 void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
150
151 void initLaneTree(NamedRTree* tree) override;
152
153 MSEdge* retrieveEdge(const std::string& id) override;
154
155 private:
156 struct StageStart {
157 std::string vehicle;
160 };
161
163 const std::vector<StageStart>& stages, const Trajectory& t);
164 ConstMSEdgeVector checkRoute(const ConstMSEdgeVector& edges, const SUMOVehicle* const vehicle);
165
167 bool myFinished = false;
168 std::map<std::string, Trajectory> myTrajectories;
169 std::map<std::string, std::tuple<SUMOTime, std::string, bool, ConstMSEdgeVector, std::vector<StageStart> > > myRoutes;
170 std::map<const Position, std::string> myPositions;
171 };
172
173private:
174 static std::vector<std::unique_ptr<FCDHandler> > myHandlers;
175 static std::vector<std::unique_ptr<SUMOSAXReader> > myParsers;
178 const Trajectory* myTrajectory = nullptr;
180 bool myReplayCreated = false;
182
183private:
186
189
190};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:75
std::bitset< 96 > SumoXMLAttrMask
Base (microsim) event class.
Definition Command.h:50
const std::map< std::string, Trajectory > & getTrajectories()
std::map< const Position, std::string > myPositions
std::map< std::string, std::tuple< SUMOTime, std::string, bool, ConstMSEdgeVector, std::vector< StageStart > > > myRoutes
std::map< std::string, Trajectory > myTrajectories
void updateTrafficObjects(const SUMOTime intervalStart)
void initLaneTree(NamedRTree *tree) override
ConstMSEdgeVector checkRoute(const ConstMSEdgeVector &edges, const SUMOVehicle *const vehicle)
MSTransportable::MSTransportablePlan * makePlan(const SUMOVehicleParameter &params, const ConstMSEdgeVector &route, const std::vector< StageStart > &stages, const Trajectory &t)
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag.
MSEdge * retrieveEdge(const std::string &id) override
SUMOTime execute(SUMOTime currentTime) override
Executes the command.
MoveVehicles & operator=(const MoveVehicles &)=delete
Invalidated assignment operator.
A device which replays a vehicle trajectory from an fcd file.
static std::vector< std::unique_ptr< SUMOSAXReader > > myParsers
MSDevice_FCDReplay(const MSDevice_FCDReplay &)=delete
Invalidated copy constructor.
const FCDHandler * myTrajectorySource
static void init()
Static intialization.
const std::string deviceName() const override
return the name for this type of device
std::vector< TrajectoryEntry > Trajectory
const Trajectory * myTrajectory
static SUMOTime parseNext(SUMOTime t)
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
MSDevice_FCDReplay & operator=(const MSDevice_FCDReplay &)=delete
Invalidated assignment operator.
static std::vector< std::unique_ptr< FCDHandler > > myHandlers
bool move(SUMOTime currentTime)
Returns true when a replay-created vehicle has finished its recording.
void setTrajectory(const Trajectory *t, const FCDHandler *source, bool replayCreated)
static SumoXMLAttrMask myUsedAttributes
bit mask for checking attributes to be used
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCDReplay-options.
A road/street connecting two junctions.
Definition MSEdge.h:78
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
Abstract in-vehicle device.
Provides utility functions for matching locations to edges (during route parsing)
Definition MapMatcher.h:45
A RT-tree for efficient storing of SUMO's Named objects.
Definition NamedRTree.h:61
A storage for options typed value containers)
Definition OptionsCont.h:92
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.
SAX-reader encapsulation containing binary reader.
Representation of a vehicle.
Definition SUMOVehicle.h:63
Structure representing possible vehicle parameter.
SUMOTime time
double angle
std::string edgeOrLane
Position pos
double speed
double lanePos