Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_FCDReplay.cpp
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#include <config.h>
21
23#include <utils/geom/Position.h>
26#include <utils/xml/XMLSubSys.h>
27#include <libsumo/Vehicle.h>
28#include <microsim/MSNet.h>
29#include <microsim/MSEdge.h>
30#include <microsim/MSLane.h>
31#include <microsim/MSRoute.h>
39#include "MSDevice_FCDReplay.h"
40
41
42// ===========================================================================
43// static member initializations
44// ===========================================================================
45std::vector<std::unique_ptr<MSDevice_FCDReplay::FCDHandler> > MSDevice_FCDReplay::myHandlers;
46std::vector<std::unique_ptr<SUMOSAXReader> > MSDevice_FCDReplay::myParsers;
48
49
50// ===========================================================================
51// method definitions
52// ===========================================================================
53// ---------------------------------------------------------------------------
54// static initialisation methods
55// ---------------------------------------------------------------------------
56void
58 oc.addOptionSubTopic("FCD Replay Device");
59 insertDefaultAssignmentOptions("fcd-replay", "FCD Replay Device", oc);
60
61 oc.doRegister("device.fcd-replay.files", new Option_FileName());
62 oc.addSynonyme("device.fcd-replay.files", "device.fcd-replay.file");
63 oc.addDescription("device.fcd-replay.files", "FCD Replay Device", TL("FCD files to read"));
64 oc.doRegister("device.fcd-replay.consistency", new Option_StringVector(StringVector({ "all" })));
65 oc.addDescription("device.fcd-replay.consistency", "FCD Replay Device", TL("Values to use when replaying ('all' or any combination of 'x', 'y', 'edge', 'lane', 'speed', 'position', 'angle', 'type')"));
66}
67
68
69void
70MSDevice_FCDReplay::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
72 if (equippedByDefaultAssignmentOptions(oc, "fcd-replay", v, oc.isSet("device.fcd-replay.files"))) {
73 MSDevice_FCDReplay* device = new MSDevice_FCDReplay(v, "fcdReplay_" + v.getID());
74 into.push_back(device);
75 }
76}
77
78
79void
82 myUsedAttributes.reset();
83 for (const std::string& attr : oc.getStringVector("device.fcd-replay.consistency")) {
84 if (attr == "x" || attr == "all") {
86 }
87 if (attr == "y" || attr == "all") {
89 }
90 if (attr == "edge" || attr == "all") {
92 }
93 if (attr == "lane" || attr == "all") {
95 }
96 if (attr == "speed" || attr == "all") {
98 }
99 if (attr == "position" || attr == "pos" || attr == "all") {
101 }
102 if (attr == "angle" || attr == "all") {
104 }
105 if (attr == "type" || attr == "all") {
107 }
108 }
109 myHandlers.clear();
110 if (oc.isSet("device.fcd-replay.files")) {
111 for (const std::string& filename : oc.getStringVector("device.fcd-replay.files")) {
112 myHandlers.push_back(std::unique_ptr<MSDevice_FCDReplay::FCDHandler>(new MSDevice_FCDReplay::FCDHandler(filename)));
113 myParsers.push_back(std::unique_ptr<SUMOSAXReader>(XMLSubSys::getSAXReader(*myHandlers.back())));
114 if (!myParsers.back()->parseFirst(filename)) {
115 throw ProcessError(TLF("Can not read XML-file '%'.", filename));
116 }
117 const SUMOTime inc = parseNext(SIMSTEP);
119 if (inc > 0) {
121 SIMSTEP + inc);
122 }
123 }
124 }
125}
126
127
130 SUMOTime inc = string2time(OptionsCont::getOptions().getString("route-steps"));
131 bool haveData = false;
132 for (int i = 0; i < (int)myHandlers.size(); i++) {
133 if (myParsers[i] != nullptr) {
134 haveData = true;
135 // make sure that we have always at least inc time steps buffered, so at time 200 we will parse 400 to 600
136 const SUMOTime start = myHandlers[i]->getTime();
137 while (myHandlers[i]->getTime() < t + 2 * inc) {
138 if (!myParsers[i]->parseNext()) {
139 myParsers[i] = nullptr;
140 break;
141 }
142 }
143 myHandlers[i]->updateTrafficObjects(start);
144 }
145 }
146 return haveData ? inc : 0;
147}
148
149
150// ---------------------------------------------------------------------------
151// MSDevice_FCDReplay-methods
152// ---------------------------------------------------------------------------
154 MSVehicleDevice(holder, id) {
155}
156
157
160
161
162void
164 if (myTrajectory == nullptr) {
165 for (auto& handler : myHandlers) {
166 auto it = handler->getTrajectories().find(myHolder.getID());
167 if (it != handler->getTrajectories().end()) {
168 setTrajectory(&it->second);
169 break;
170 }
171 }
172 if (myTrajectory == nullptr) {
173 return;
174 }
175 } else if (myTrajectoryIndex == (int)myTrajectory->size()) {
176 // removal happens via the usual MSVehicle::hasArrived mechanism
177 // TODO we may need to set an arrivalPos
178 return;
179 }
180 MSVehicle* v = dynamic_cast<MSVehicle*>(&myHolder);
182 if (v == nullptr || te.time > currentTime) {
183 return;
184 }
185 if (te.edgeOrLane != "") {
186 const std::string& edgeID = SUMOXMLDefinitions::getEdgeIDFromLane(te.edgeOrLane);
187 const int laneIdx = SUMOXMLDefinitions::getIndexFromLane(te.edgeOrLane);
188 libsumo::Vehicle::moveToXY(myHolder.getID(), edgeID, laneIdx, te.pos.x(), te.pos.y(), te.angle, 7);
189 } else if (te.pos.x() != libsumo::INVALID_DOUBLE_VALUE) {
190 libsumo::Vehicle::moveToXY(myHolder.getID(), "", -1, te.pos.x(), te.pos.y(), te.angle, 0);
191 }
193 libsumo::Vehicle::setSpeed(myHolder.getID(), te.speed);
194 // libsumo::Vehicle::changeLane(myHolder.getID(), laneIdx, TS);
196}
197
198
202 for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
203 MSDevice_FCDReplay* device = static_cast<MSDevice_FCDReplay*>(i->second->getDevice(typeid(MSDevice_FCDReplay)));
204 if (device != nullptr && i->second->hasDeparted()) {
205 device->move(currentTime);
206 }
207 }
208 return DELTA_T;
209}
210
211
212// ---------------------------------------------------------------------------
213// MSDevice_FCDReplay::FCDHandler-methods
214// ---------------------------------------------------------------------------
216 SUMOSAXHandler(file),
217 MapMatcher(false, false,
218 OptionsCont::getOptions().getFloat("mapmatch.distance"),
219 MsgHandler::getErrorInstance()) {}
220
221
222void
224 bool ok = true;
225 switch (element) {
227 myTime = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME, "", ok);
228 myPositions.clear();
229 return;
230 case SUMO_TAG_VEHICLE:
231 case SUMO_TAG_PERSON:
232 if (myTime >= SIMSTEP) {
233 const bool isPerson = element == SUMO_TAG_PERSON;
234 const std::string id = attrs.getString(SUMO_ATTR_ID);
235 auto getOptDouble = [&](const SumoXMLAttr attr) {
236 return myUsedAttributes.test(attr) ? attrs.getOpt<double>(attr, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE) : libsumo::INVALID_DOUBLE_VALUE;
237 };
238 const Position xy = Position(getOptDouble(SUMO_ATTR_X), getOptDouble(SUMO_ATTR_Y));
239 const std::string type = myUsedAttributes.test(SUMO_ATTR_TYPE) ? attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "") : "";
240 std::string edgeOrLane;
242 edgeOrLane = attrs.getOpt<std::string>(isPerson ? SUMO_ATTR_EDGE : SUMO_ATTR_LANE, id.c_str(), ok, "");
243 }
244 const double speed = getOptDouble(SUMO_ATTR_SPEED);
245 const double pos = getOptDouble(SUMO_ATTR_POSITION);
246 const double angle = getOptDouble(SUMO_ATTR_ANGLE);
247 std::string vehicle = attrs.getOpt<std::string>(SUMO_ATTR_VEHICLE, id.c_str(), ok, "");
248 if (isPerson) {
249 if (vehicle == "") {
250 const auto& veh = myPositions.find(xy);
251 if (veh != myPositions.end()) {
252 vehicle = veh->second;
253 }
254 }
255 } else {
256 myPositions[xy] = id;
257 }
258 if (!ok) {
259 WRITE_WARNING("Invalid FCD data.");
260 return;
261 }
262 myTrajectories[id].push_back({myTime, xy, edgeOrLane, pos, speed, angle});
263 const MSEdge* edge = MSEdge::dictionary(isPerson ? edgeOrLane : SUMOXMLDefinitions::getEdgeIDFromLane(edgeOrLane));
264 if (edge == nullptr && edgeOrLane != "") {
265 WRITE_WARNINGF(isPerson ? TL("Unknown edge '%' in fcd replay file for person '%'.") : TL("Unknown lane '%' in fcd replay file for vehicle '%'."), edgeOrLane, id);
266 }
267 if (myRoutes.count(id) == 0) {
268 if (edgeOrLane == "") {
269 const MSLane* const lane = getClosestLane(xy, SVC_PASSENGER);
270 if (lane != nullptr) {
271 myTrajectories[id].back().edgeOrLane = lane->getID();
272 myTrajectories[id].back().lanePos = lane->interpolateGeometryPosToLanePos(
273 lane->getShape().nearest_offset_to_point25D(xy, false));
274 edge = &lane->getEdge();
275 while (edge->isInternal()) { // we cannot use an internal edge for a route
276 edge = edge->getSuccessors().front();
277 }
278 }
279 }
280 myRoutes[id] = std::make_tuple(myTime, type, isPerson, ConstMSEdgeVector{edge}, std::vector<StageStart>());
281 } else {
282 ConstMSEdgeVector& route = std::get<3>(myRoutes[id]);
283 if (edge != nullptr && !edge->isInternal() && edge != route.back()) {
284 route.push_back(edge);
285 }
286 }
287 std::vector<StageStart>& vehicleUsage = std::get<4>(myRoutes[id]);
288 if ((vehicleUsage.empty() && vehicle != "") || (!vehicleUsage.empty() && vehicle != vehicleUsage.back().vehicle)) {
289 vehicleUsage.push_back({vehicle, (int)myTrajectories[id].size() - 1, (int)std::get<3>(myRoutes[id]).size() - 1});
290 }
291 }
292 return;
293 default:
294 break;
295 }
296}
297
298
301 const std::vector<StageStart>& stages, const Trajectory& t) {
303 plan->push_back(new MSStageWaiting(route.front(), nullptr, 0, params.depart, params.departPos, "awaiting departure", true));
304 int prevRouteOffset = 0;
305 const MSEdge* start = route.front();
306 std::string prevVeh;
307 for (const auto& stageStart : stages) {
308 if (stageStart.vehicle != prevVeh) {
309 if (stageStart.trajectoryOffset != 0) {
310 const MSEdge* prevEdge = MSEdge::dictionary(t[stageStart.trajectoryOffset - 1].edgeOrLane);
311 if (prevVeh == "") {
312 MSStoppingPlace* finalStop = nullptr;
313 if (prevRouteOffset < (int)route.size() - 1 && (route[prevRouteOffset]->getPermissions() & SVC_PEDESTRIAN) == 0) {
314 prevRouteOffset++; // skip the access
315 }
316 int offset = stageStart.routeOffset;
317 if (offset < (int)route.size() - 1 && (route[offset]->getPermissions() & SVC_PEDESTRIAN) == SVC_PEDESTRIAN) {
318 offset++; // a bus stop or two consecutive walks so include the edge in both
319 } else {
320 // may have an access, let's find the stop
321 const std::string& stop = MSNet::getInstance()->getStoppingPlaceID(route[offset]->getLanes()[0], t[stageStart.trajectoryOffset].lanePos, SUMO_TAG_BUS_STOP);
322 if (stop != "") {
324 }
325 }
326 ConstMSEdgeVector subRoute = ConstMSEdgeVector(route.begin() + prevRouteOffset, route.begin() + offset);
327 plan->push_back(new MSStageWalking(params.id, subRoute, finalStop, -1, params.departSpeed, params.departPos, 0, 0));
328 } else {
329 plan->push_back(new MSStageDriving(start, prevEdge, nullptr, -1, 0, {prevVeh}));
330 }
331 start = MSEdge::dictionary(t[stageStart.trajectoryOffset].edgeOrLane);
332 prevVeh = stageStart.vehicle;
333 prevRouteOffset = stageStart.routeOffset;
334 }
335 }
336 }
337 // final stage
338 if (prevVeh == "") {
339 if (prevRouteOffset < (int)route.size() - 1 && (route[prevRouteOffset]->getPermissions() & SVC_PEDESTRIAN) == 0) {
340 prevRouteOffset++;
341 }
342 int offset = (int)route.size() - 1;
343 if ((route[offset]->getPermissions() & SVC_PEDESTRIAN) == SVC_PEDESTRIAN) {
344 offset++;
345 }
346 if (prevRouteOffset < offset) {
347 // otherwise we may be still in a vehicle or in access, skip the stage for now
348 ConstMSEdgeVector subRoute = ConstMSEdgeVector(route.begin() + prevRouteOffset, route.begin() + offset);
349 plan->push_back(new MSStageWalking(params.id, subRoute, nullptr, -1, params.departSpeed, params.departPos, 0, 0));
350 }
351 } else {
352 plan->push_back(new MSStageDriving(start, route.back(), nullptr, -1, 0, {prevVeh}));
353 }
354 return plan;
355}
356
357
360 ConstMSEdgeVector checkedRoute;
361 for (const MSEdge* const e : edges) {
362 if (checkedRoute.empty() || checkedRoute.back()->isConnectedTo(*e, vehicle->getVehicleType().getVehicleClass())) {
363 checkedRoute.push_back(e);
364 } else {
365 const MSEdge* fromEdge = checkedRoute.back();
366 checkedRoute.pop_back();
367 if (!MSNet::getInstance()->getRouterTT(0).compute(fromEdge, e, vehicle, myTime, checkedRoute)) {
368 // TODO maybe warn about disconnected route
369 checkedRoute.push_back(fromEdge);
370 checkedRoute.push_back(e);
371 }
372 // TODO check whether we introduced a big detour
373 }
374 }
375 return checkedRoute;
376}
377
378
379void
381 for (const auto& desc : myRoutes) {
382 const std::string& id = desc.first;
383 const bool isPerson = std::get<2>(desc.second);
384 const ConstMSEdgeVector& routeEdges = std::get<3>(desc.second);
385 Trajectory& t = myTrajectories[id];
386 if (t.front().time >= intervalStart) {
387 // new vehicle or person
389 params->id = id;
390 params->depart = std::get<0>(desc.second);
391 params->departPos = t.front().lanePos;
392 params->departSpeed = t.front().speed;
393 // params->arrivalPos = t.back().lanePos;
394 std::string vType = std::get<1>(desc.second);
395 if (vType == "") {
396 vType = isPerson ? DEFAULT_PEDTYPE_ID : DEFAULT_VTYPE_ID;
397 }
399 if (vehicleType == nullptr) {
400 delete params;
401 throw ProcessError(TLF("Unknown vType '%'.", vType));
402 }
403 if (routeEdges.front() == nullptr) {
404 if (isPerson) {
405 WRITE_WARNINGF(TL("No edge in fcd replay file for person '%' at time %."), id, time2string(t.front().time));
406 } else {
407 WRITE_WARNINGF(TL("No lane in fcd replay file for vehicle '%' at time %."), id, time2string(t.front().time));
408 }
409 delete params;
410 continue;
411 }
412 if (isPerson) {
413 MSTransportable::MSTransportablePlan* plan = makePlan(*params, routeEdges, std::get<4>(desc.second), t);
414 // plan completed, now build the person
415 MSTransportable* person = MSNet::getInstance()->getPersonControl().buildPerson(params, vehicleType, plan, nullptr);
417 if (!MSNet::getInstance()->getPersonControl().add(person)) {
418 delete person;
419 throw ProcessError(TLF("Duplicate person '%'.", id));
420 }
422 if (device == nullptr) { // Person did not get a replay device
423 delete person;
424 continue;
425 }
426 device->setTrajectory(&t);
427 } else {
428 const std::string dummyRouteID = "DUMMY_ROUTE_" + id;
429 const StopParVector stops;
430 ConstMSRoutePtr route = std::make_shared<MSRoute>(dummyRouteID, routeEdges, true, nullptr, stops);
431 if (!MSRoute::dictionary(dummyRouteID, route)) {
432 throw ProcessError(TLF("Could not add route '%'.", dummyRouteID));
433 }
434 if (t.front().edgeOrLane != "") {
437 params->departLane = SUMOXMLDefinitions::getIndexFromLane(t.front().edgeOrLane);
438 }
440 if (!MSNet::getInstance()->getVehicleControl().addVehicle(id, vehicle)) {
441 throw ProcessError(TLF("Duplicate vehicle '%'.", id));
442 }
444 MSDevice_FCDReplay* device = static_cast<MSDevice_FCDReplay*>(vehicle->getDevice(typeid(MSDevice_FCDReplay)));
445 if (device == nullptr) { // Vehicle did not get a replay device
447 continue;
448 }
449 device->setTrajectory(&t);
450
451 // repair the route, cannot do this on parsing because a vehicle is needed
452 ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);
453 if (checkedRoute.size() != routeEdges.size()) {
454 vehicle->replaceRouteEdges(checkedRoute, -1, 0, "FCDReplay", true);
455 }
456 }
457 } else if (t.back().time >= intervalStart) {
458 // new data for existing person / vehicle
459 if (isPerson) {
461 if (person == nullptr) {
462 // TODO this should not happen
463 continue;
464 }
465 // TODO optimize: no need to regenerate the whole plan
466 MSTransportable::MSTransportablePlan* plan = makePlan(person->getParameter(), routeEdges, std::get<4>(desc.second), t);
467 const int stageIndex = person->getNumRemainingStages() - 1;
468 const MSStage* const finalStage = person->getNextStage(stageIndex);
469 bool append = false;
470 for (MSStage* const stage : *plan) {
471 if (stage->getStageType() == finalStage->getStageType() && stage->getFromEdge() == finalStage->getFromEdge()) {
472 // TODO: circular plans?
473 append = true;
474 }
475 if (append) {
476 person->appendStage(stage);
477 } else {
478 delete stage;
479 }
480 }
481 person->removeStage(stageIndex);
482 delete plan;
483 } else {
485 ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);
486 if ((int)checkedRoute.size() != vehicle->getRoute().size()) {
487 vehicle->replaceRouteEdges(checkedRoute, -1, 0, "FCDReplay", true);
488 }
489 }
490 }
491 }
492}
493
494
495void
497 for (const auto& edge : MSEdge::getAllEdges()) {
498 for (MSLane* lane : edge->getLanes()) {
499 Boundary b = lane->getShape().getBoxBoundary();
500 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
501 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
502 tree->Insert(cmin, cmax, lane);
503 }
504 }
505}
506
507
508MSEdge*
510 return MSEdge::dictionary(id);
511}
512
513
514/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
std::vector< std::string > StringVector
Definition of a vector of strings.
Definition Option.h:42
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
#define SIMSTEP
Definition SUMOTime.h:64
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_PEDESTRIAN
pedestrian
@ GIVEN
The lane is given.
@ GIVEN
The position is given.
std::vector< SUMOVehicleParameter::Stop > StopParVector
@ SUMO_TAG_TIMESTEP
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_PERSON
std::bitset< 96 > SumoXMLAttrMask
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_Y
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_X
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_VEHICLE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_TIME
trigger: the time of the step
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:444
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
void updateTrafficObjects(const SUMOTime intervalStart)
void initLaneTree(NamedRTree *tree) override
FCDHandler(const std::string &file)
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.
A device which replays a vehicle trajectory from an fcd file.
static std::vector< std::unique_ptr< SUMOSAXReader > > myParsers
static void init()
Static intialization.
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(SUMOVehicle &holder, const std::string &id)
Constructor.
static std::vector< std::unique_ptr< FCDHandler > > myHandlers
void move(SUMOTime currentTime)
void setTrajectory(const Trajectory *const t)
static SumoXMLAttrMask myUsedAttributes
bit mask for checking attributes to be used
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCDReplay-options.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition MSDevice.cpp:157
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition MSDevice.h:200
A road/street connecting two junctions.
Definition MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition MSEdge.cpp:1128
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:269
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition MSEdge.cpp:1089
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1307
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition MSLane.h:567
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:790
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:199
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition MSNet.h:495
MSVehicleRouter & getRouterTT(int rngIndex, const Prohibitions &prohibited={}) const
Definition MSNet.cpp:1645
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
Definition MSNet.cpp:1534
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1513
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:455
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:402
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1303
int size() const
Returns the number of edges to pass.
Definition MSRoute.cpp:85
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition MSRoute.cpp:116
virtual const MSEdge * getFromEdge() const
Definition MSStage.cpp:77
MSStageType getStageType() const
Definition MSStage.h:138
A lane area vehicles can halt at.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, SumoRNG *rng) const
Builds a new person.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
A device which collects info on the vehicle trip (mainly on departure and arrival)
void setTrajectory(MSDevice_FCDReplay::Trajectory *const t)
MSStage * getNextStage(int offset) const
Return the next (or previous) stage denoted by the offset.
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
MSDevice * getDevice(const std::type_info &type) const override
Returns a device of the given type if it exists or nullptr if not.
const SUMOVehicleParameter & getParameter() const override
Returns the vehicle's parameter (including departure definition)
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
Influencer & getInfluencer()
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
Provides utility functions for matching locations to edges (during route parsing)
Definition MapMatcher.h:45
const std::string & getID() const
Returns the id.
Definition Named.h:73
A RT-tree for efficient storing of SUMO's Named objects.
Definition NamedRTree.h:61
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition NamedRTree.h:79
A storage for options typed value containers)
Definition OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:52
double y() const
Returns the y-position.
Definition Position.h:57
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
SAX-handler base for SUMO-files.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
Representation of a vehicle.
Definition SUMOVehicle.h:63
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given edges.
virtual const MSRoute & getRoute() const =0
Returns the current route.
Structure representing possible vehicle parameter.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double departSpeed
(optional) The initial speed of the vehicle
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
double departPos
(optional) The position the vehicle shall depart from
std::string id
The vehicle's id.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID
A wrapper for a Command function.
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler, const bool isNet=false, const bool isRoute=false)
Builds a reader and assigns the handler to it.
TRACI_CONST double INVALID_DOUBLE_VALUE
SUMOTime time
double angle
std::string edgeOrLane
Position pos
double speed