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-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#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// ===========================================================================
47
48
49// ===========================================================================
50// method definitions
51// ===========================================================================
52// ---------------------------------------------------------------------------
53// static initialisation methods
54// ---------------------------------------------------------------------------
55void
57 oc.addOptionSubTopic("FCD Replay Device");
58 insertDefaultAssignmentOptions("fcd-replay", "FCD Replay Device", oc);
59
60 oc.doRegister("device.fcd-replay.file", new Option_FileName());
61 oc.addDescription("device.fcd-replay.file", "FCD Replay Device", TL("FCD file to read"));
62}
63
64
65void
66MSDevice_FCDReplay::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
68 if (equippedByDefaultAssignmentOptions(oc, "fcd-replay", v, oc.isSet("device.fcd-replay.file"))) {
69 MSDevice_FCDReplay* device = new MSDevice_FCDReplay(v, "fcdReplay_" + v.getID());
70 into.push_back(device);
71 }
72}
73
74
75void
77 delete myHandler;
78 myHandler = nullptr;
80 if (oc.isSet("device.fcd-replay.file")) {
81 const std::string& filename = oc.getString("device.fcd-replay.file");
84 if (!myParser->parseFirst(filename)) {
85 throw ProcessError(TLF("Can not read XML-file '%'.", filename));
86 }
87 const SUMOTime inc = parseNext(SIMSTEP);
89 if (inc > 0) {
91 SIMSTEP + inc);
92 }
93 }
94}
95
96
99 SUMOTime inc = string2time(OptionsCont::getOptions().getString("route-steps"));
100 // make sure that we have always at least inc time steps buffered, so at time 200 we will parse 400 to 600
101 const SUMOTime start = myHandler->getTime();
102 while (myHandler->getTime() < t + 2 * inc) {
103 if (!myParser->parseNext()) {
104 inc = 0;
105 break;
106 }
107 }
109 return inc;
110}
111
112
113// ---------------------------------------------------------------------------
114// MSDevice_FCDReplay-methods
115// ---------------------------------------------------------------------------
117 MSVehicleDevice(holder, id) {
118}
119
120
123
124
125void
127 if (myTrajectory == nullptr) {
128 auto it = myHandler->getTrajectories().find(myHolder.getID());
129 if (it == myHandler->getTrajectories().end()) {
130 return;
131 } else {
132 const Trajectory& t = it->second;
133 setTrajectory(&t);
134 }
135 } else if (myTrajectoryIndex == (int)myTrajectory->size()) {
136 // removal happens via the usual MSVehicle::hasArrived mechanism
137 // TODO we may need to set an arrivalPos
138 return;
139 }
140 MSVehicle* v = dynamic_cast<MSVehicle*>(&myHolder);
142 if (v == nullptr || te.time > currentTime) {
143 return;
144 }
145 if (te.edgeOrLane != "") {
146 const std::string& edgeID = SUMOXMLDefinitions::getEdgeIDFromLane(te.edgeOrLane);
147 const int laneIdx = SUMOXMLDefinitions::getIndexFromLane(te.edgeOrLane);
148 libsumo::Vehicle::moveToXY(myHolder.getID(), edgeID, laneIdx, te.pos.x(), te.pos.y(), te.angle, 7);
149 } else if (te.pos.x() != libsumo::INVALID_DOUBLE_VALUE) {
150 libsumo::Vehicle::moveToXY(myHolder.getID(), "", -1, te.pos.x(), te.pos.y(), te.angle, 0);
151 }
153 libsumo::Vehicle::setSpeed(myHolder.getID(), te.speed);
154 // libsumo::Vehicle::changeLane(myHolder.getID(), laneIdx, TS);
156}
157
158
162 for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
163 MSDevice_FCDReplay* device = static_cast<MSDevice_FCDReplay*>(i->second->getDevice(typeid(MSDevice_FCDReplay)));
164 if (device != nullptr && i->second->hasDeparted()) {
165 device->move(currentTime);
166 }
167 }
168 return DELTA_T;
169}
170
171
172// ---------------------------------------------------------------------------
173// MSDevice_FCDReplay::FCDHandler-methods
174// ---------------------------------------------------------------------------
176 SUMOSAXHandler(file),
177 MapMatcher(false, false,
178 OptionsCont::getOptions().getFloat("mapmatch.distance"),
179 MsgHandler::getErrorInstance()) {}
180
181
182void
184 bool ok = true;
185 switch (element) {
187 myTime = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME, "", ok);
188 myPositions.clear();
189 return;
190 case SUMO_TAG_VEHICLE:
191 case SUMO_TAG_PERSON: {
192 if (myTime >= SIMSTEP) {
193 const bool isPerson = element == SUMO_TAG_PERSON;
194 const std::string id = attrs.getString(SUMO_ATTR_ID);
195 const Position xy = Position(attrs.getOpt<double>(SUMO_ATTR_X, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE),
196 attrs.getOpt<double>(SUMO_ATTR_Y, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE));
197 const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
198 const std::string edgeOrLane = attrs.getOpt<std::string>(isPerson ? SUMO_ATTR_EDGE : SUMO_ATTR_LANE, id.c_str(), ok, "");
199 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE);
200 const double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE);
201 const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE);
202 std::string vehicle = attrs.getOpt<std::string>(SUMO_ATTR_VEHICLE, id.c_str(), ok, "");
203 if (isPerson) {
204 if (vehicle == "") {
205 const auto& veh = myPositions.find(xy);
206 if (veh != myPositions.end()) {
207 vehicle = veh->second;
208 }
209 }
210 } else {
211 myPositions[xy] = id;
212 }
213 myTrajectories[id].push_back({myTime, xy, edgeOrLane, pos, speed, angle});
214 const MSEdge* edge = MSEdge::dictionary(isPerson ? edgeOrLane : SUMOXMLDefinitions::getEdgeIDFromLane(edgeOrLane));
215 if (edge == nullptr && edgeOrLane != "") {
216 WRITE_WARNINGF(isPerson ? TL("Unknown edge '%' in fcd replay file for person '%'.") : TL("Unknown lane '%' in fcd replay file for vehicle '%'."), edgeOrLane, id);
217 }
218 if (myRoutes.count(id) == 0) {
219 if (edgeOrLane == "") {
220 const MSLane* const lane = getClosestLane(xy, SVC_PASSENGER);
221 if (lane != nullptr) {
222 myTrajectories[id].back().edgeOrLane = lane->getID();
223 myTrajectories[id].back().lanePos = lane->interpolateGeometryPosToLanePos(
224 lane->getShape().nearest_offset_to_point25D(xy, false));
225 edge = &lane->getEdge();
226 while (edge->isInternal()) { // we cannot use an internal edge for a route
227 edge = edge->getSuccessors().front();
228 }
229 }
230 }
231 myRoutes[id] = std::make_tuple(myTime, type, isPerson, ConstMSEdgeVector{edge}, std::vector<StageStart>());
232 } else {
233 ConstMSEdgeVector& route = std::get<3>(myRoutes[id]);
234 if (edge != nullptr && !edge->isInternal() && edge != route.back()) {
235 route.push_back(edge);
236 }
237 }
238 std::vector<StageStart>& vehicleUsage = std::get<4>(myRoutes[id]);
239 if ((vehicleUsage.empty() && vehicle != "") || (!vehicleUsage.empty() && vehicle != vehicleUsage.back().vehicle)) {
240 vehicleUsage.push_back({vehicle, (int)myTrajectories[id].size() - 1, (int)std::get<3>(myRoutes[id]).size() - 1});
241 }
242 }
243 return;
244 }
245 default:
246 break;
247 }
248}
249
250
253 const std::vector<StageStart>& stages, const Trajectory& t) {
255 plan->push_back(new MSStageWaiting(route.front(), nullptr, 0, params.depart, params.departPos, "awaiting departure", true));
256 int prevRouteOffset = 0;
257 const MSEdge* start = route.front();
258 std::string prevVeh;
259 for (const auto& stageStart : stages) {
260 if (stageStart.vehicle != prevVeh) {
261 if (stageStart.trajectoryOffset != 0) {
262 const MSEdge* prevEdge = MSEdge::dictionary(t[stageStart.trajectoryOffset - 1].edgeOrLane);
263 if (prevVeh == "") {
264 MSStoppingPlace* finalStop = nullptr;
265 if (prevRouteOffset < (int)route.size() - 1 && (route[prevRouteOffset]->getPermissions() & SVC_PEDESTRIAN) == 0) {
266 prevRouteOffset++; // skip the access
267 }
268 int offset = stageStart.routeOffset;
269 if (offset < (int)route.size() - 1 && (route[offset]->getPermissions() & SVC_PEDESTRIAN) == SVC_PEDESTRIAN) {
270 offset++; // a bus stop or two consecutive walks so include the edge in both
271 } else {
272 // may have an access, let's find the stop
273 const std::string& stop = MSNet::getInstance()->getStoppingPlaceID(route[offset]->getLanes()[0], t[stageStart.trajectoryOffset].lanePos, SUMO_TAG_BUS_STOP);
274 if (stop != "") {
276 }
277 }
278 ConstMSEdgeVector subRoute = ConstMSEdgeVector(route.begin() + prevRouteOffset, route.begin() + offset);
279 plan->push_back(new MSStageWalking(params.id, subRoute, finalStop, -1, params.departSpeed, params.departPos, 0, 0));
280 } else {
281 plan->push_back(new MSStageDriving(start, prevEdge, nullptr, -1, 0, {prevVeh}));
282 }
283 start = MSEdge::dictionary(t[stageStart.trajectoryOffset].edgeOrLane);
284 prevVeh = stageStart.vehicle;
285 prevRouteOffset = stageStart.routeOffset;
286 }
287 }
288 }
289 // final stage
290 if (prevVeh == "") {
291 if (prevRouteOffset < (int)route.size() - 1 && (route[prevRouteOffset]->getPermissions() & SVC_PEDESTRIAN) == 0) {
292 prevRouteOffset++;
293 }
294 int offset = (int)route.size() - 1;
295 if ((route[offset]->getPermissions() & SVC_PEDESTRIAN) == SVC_PEDESTRIAN) {
296 offset++;
297 }
298 if (prevRouteOffset < offset) {
299 // otherwise we may be still in a vehicle or in access, skip the stage for now
300 ConstMSEdgeVector subRoute = ConstMSEdgeVector(route.begin() + prevRouteOffset, route.begin() + offset);
301 plan->push_back(new MSStageWalking(params.id, subRoute, nullptr, -1, params.departSpeed, params.departPos, 0, 0));
302 }
303 } else {
304 plan->push_back(new MSStageDriving(start, route.back(), nullptr, -1, 0, {prevVeh}));
305 }
306 return plan;
307}
308
309
312 ConstMSEdgeVector checkedRoute;
313 for (const MSEdge* const e : edges) {
314 if (checkedRoute.empty() || checkedRoute.back()->isConnectedTo(*e, vehicle->getVehicleType().getVehicleClass())) {
315 checkedRoute.push_back(e);
316 } else {
317 const MSEdge* fromEdge = checkedRoute.back();
318 checkedRoute.pop_back();
319 if (!MSNet::getInstance()->getRouterTT(0).compute(fromEdge, e, vehicle, myTime, checkedRoute)) {
320 // TODO maybe warn about disconnected route
321 checkedRoute.push_back(fromEdge);
322 checkedRoute.push_back(e);
323 }
324 // TODO check whether we introduced a big detour
325 }
326 }
327 return checkedRoute;
328}
329
330
331void
333 for (const auto& desc : myRoutes) {
334 const std::string& id = desc.first;
335 const bool isPerson = std::get<2>(desc.second);
336 const ConstMSEdgeVector& routeEdges = std::get<3>(desc.second);
337 Trajectory& t = myTrajectories[id];
338 if (t.front().time >= intervalStart) {
339 // new vehicle or person
341 params->id = id;
342 params->depart = std::get<0>(desc.second);
343 params->departPos = t.front().lanePos;
344 params->departSpeed = t.front().speed;
345 // params->arrivalPos = t.back().lanePos;
346 std::string vType = std::get<1>(desc.second);
347 if (vType == "") {
348 vType = isPerson ? DEFAULT_PEDTYPE_ID : DEFAULT_VTYPE_ID;
349 }
351 if (vehicleType == nullptr) {
352 throw ProcessError("Unknown vType '" + vType + "'.");
353 }
354 if (routeEdges.front() == nullptr) {
355 if (isPerson) {
356 WRITE_WARNINGF(TL("No edge in fcd replay file for person '%' at time %."), id, time2string(t.front().time));
357 } else {
358 WRITE_WARNINGF(TL("No lane in fcd replay file for vehicle '%' at time %."), id, time2string(t.front().time));
359 }
360 continue;
361 }
362 if (isPerson) {
363 MSTransportable::MSTransportablePlan* plan = makePlan(*params, routeEdges, std::get<4>(desc.second), t);
364 // plan completed, now build the person
365 MSTransportable* person = MSNet::getInstance()->getPersonControl().buildPerson(params, vehicleType, plan, nullptr);
367 if (!MSNet::getInstance()->getPersonControl().add(person)) {
368 throw ProcessError("Duplicate person '" + id + "'.");
369 }
371 if (device == nullptr) { // Person did not get a replay device
372 // TODO delete person
373 continue;
374 }
375 device->setTrajectory(&t);
376 } else {
377 const std::string dummyRouteID = "DUMMY_ROUTE_" + id;
378 const std::vector<SUMOVehicleParameter::Stop> stops;
379 ConstMSRoutePtr route = std::make_shared<MSRoute>(dummyRouteID, routeEdges, true, nullptr, stops);
380 if (!MSRoute::dictionary(dummyRouteID, route)) {
381 throw ProcessError("Could not add route '" + dummyRouteID + "'.");
382 }
383 if (t.front().edgeOrLane != "") {
386 params->departLane = SUMOXMLDefinitions::getIndexFromLane(t.front().edgeOrLane);
387 }
389 if (!MSNet::getInstance()->getVehicleControl().addVehicle(id, vehicle)) {
390 throw ProcessError("Duplicate vehicle '" + id + "'.");
391 }
393 MSDevice_FCDReplay* device = static_cast<MSDevice_FCDReplay*>(vehicle->getDevice(typeid(MSDevice_FCDReplay)));
394 if (device == nullptr) { // Vehicle did not get a replay device
396 continue;
397 }
398 device->setTrajectory(&t);
399
400 // repair the route, cannot do this on parsing because a vehicle is needed
401 ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);
402 if (checkedRoute.size() != routeEdges.size()) {
403 vehicle->replaceRouteEdges(checkedRoute, -1, 0, "FCDReplay", true);
404 }
405 }
406 } else if (t.back().time >= intervalStart) {
407 // new data for existing person / vehicle
408 if (isPerson) {
410 if (person == nullptr) {
411 // TODO this should not happen
412 continue;
413 }
414 // TODO optimize: no need to regenerate the whole plan
415 MSTransportable::MSTransportablePlan* plan = makePlan(person->getParameter(), routeEdges, std::get<4>(desc.second), t);
416 const int stageIndex = person->getNumRemainingStages() - 1;
417 MSStage* const final = person->getNextStage(stageIndex);
418 bool append = false;
419 for (MSStage* stage : *plan) {
420 if (stage->getStageType() == final->getStageType() && stage->getFromEdge() == final->getFromEdge()) {
421 // TODO: circular plans?
422 append = true;
423 }
424 if (append) {
425 person->appendStage(stage);
426 }
427 }
428 person->removeStage(stageIndex);
429 } else {
431 ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);
432 if ((int)checkedRoute.size() != vehicle->getRoute().size()) {
433 vehicle->replaceRouteEdges(checkedRoute, -1, 0, "FCDReplay", true);
434 }
435 }
436 }
437 }
438}
439
440
441void
443 for (const auto& edge : MSEdge::getAllEdges()) {
444 for (MSLane* lane : edge->getLanes()) {
445 Boundary b = lane->getShape().getBoxBoundary();
446 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
447 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
448 tree->Insert(cmin, cmax, lane);
449 }
450 }
451}
452
453
454MSEdge*
456 return MSEdge::dictionary(id);
457}
458
459
460/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
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:69
#define SIMSTEP
Definition SUMOTime.h:61
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.
@ SUMO_TAG_TIMESTEP
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_PERSON
@ 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:130
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:118
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:447
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
const std::map< std::string, Trajectory > & getTrajectories()
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 void init()
Static intialization.
std::vector< TrajectoryEntry > Trajectory
const Trajectory * myTrajectory
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(SUMOVehicle &holder, const std::string &id)
Constructor.
void move(SUMOTime currentTime)
static SUMOSAXReader * myParser
void setTrajectory(const Trajectory *const t)
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:155
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:195
A road/street connecting two junctions.
Definition MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition MSEdge.cpp:1086
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:268
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:1047
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1258
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:566
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:764
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition MSNet.h:471
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:1402
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1381
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:431
MSVehicleRouter & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1508
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:378
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1190
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:109
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
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
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or nullptr if not.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
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:74
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.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
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.
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:55
double y() const
Returns the y-position.
Definition Position.h:60
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.
SAX-reader encapsulation containing binary reader.
bool parseFirst(std::string systemID)
Start parsing the given file using parseFirst of myXMLReader.
bool parseNext()
Continue a progressive parse started by parseFirst.
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:62
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