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-2024 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
73 void move(SUMOTime currentTime);
74
76 const std::string deviceName() const override {
77 return "fcd-replay";
78 }
79
83 std::string edgeOrLane;
84 double lanePos;
85 double speed;
86 double angle;
87 };
88
89 typedef std::vector<TrajectoryEntry> Trajectory;
90
91 void setTrajectory(Trajectory* const t) {
92 myTrajectory = t;
94 }
95
96private:
102 MSDevice_FCDReplay(SUMOVehicle& holder, const std::string& id);
103
104 class MoveVehicles : public Command {
105 public:
106 SUMOTime execute(SUMOTime currentTime) override;
107 private:
110 };
111
112 class FCDHandler : public SUMOSAXHandler, public MapMatcher<MSEdge, MSLane, MSJunction> {
113 public:
114 FCDHandler(const std::string& file);
116 return myTime;
117 }
118 void updateTrafficObjects(const SUMOTime intervalStart);
119
120 protected:
122
123
131 void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
133
134 void initLaneTree(NamedRTree* tree) override;
135
136 MSEdge* retrieveEdge(const std::string& id) override;
137
138 private:
139 struct StageStart {
140 std::string vehicle;
143 };
144
146 const std::vector<StageStart>& stages, const Trajectory& t);
147 ConstMSEdgeVector checkRoute(const ConstMSEdgeVector& edges, const SUMOVehicle* const vehicle);
148
150 std::map<std::string, Trajectory> myTrajectories;
151 std::map<std::string, std::tuple<SUMOTime, std::string, bool, ConstMSEdgeVector, std::vector<StageStart> > > myRoutes;
152 std::map<const Position, std::string> myPositions;
153 };
154
155private:
160
161private:
164
167
168};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
Base (microsim) event class.
Definition Command.h:50
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.
MSDevice_FCDReplay(const MSDevice_FCDReplay &)=delete
Invalidated copy constructor.
static void init()
Static intialization.
const std::string deviceName() const override
return the name for this type of device
std::vector< TrajectoryEntry > Trajectory
static SUMOTime parseNext(SUMOTime t)
static FCDHandler * myHandler
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.
void move(SUMOTime currentTime)
static SUMOSAXReader * myParser
void setTrajectory(Trajectory *const t)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCDReplay-options.
A road/street connecting two junctions.
Definition MSEdge.h:77
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:44
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:89
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:62
Structure representing possible vehicle parameter.
SUMOTime time
double angle
std::string edgeOrLane
Position pos
double speed
double lanePos