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 || myTrajectoryIndex == (int)myTrajectory->size()) {
128 // removal happens via the usual MSVehicle::hasArrived mechanism
129 // TODO we may need to set an arrivalPos
130 return;
131 }
132 MSVehicle* v = dynamic_cast<MSVehicle*>(&myHolder);
134 if (v == nullptr || te.time > currentTime) {
135 return;
136 }
137 if (te.edgeOrLane != "") {
138 const std::string& edgeID = SUMOXMLDefinitions::getEdgeIDFromLane(te.edgeOrLane);
139 const int laneIdx = SUMOXMLDefinitions::getIndexFromLane(te.edgeOrLane);
140 libsumo::Vehicle::moveToXY(myHolder.getID(), edgeID, laneIdx, te.pos.x(), te.pos.y(), te.angle, 7);
141 } else {
142 libsumo::Vehicle::moveToXY(myHolder.getID(), "", -1, te.pos.x(), te.pos.y(), te.angle, 0);
143 }
144 libsumo::Vehicle::setSpeed(myHolder.getID(), te.speed);
145 // libsumo::Vehicle::changeLane(myHolder.getID(), laneIdx, TS);
147}
148
149
153 for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
154 MSDevice_FCDReplay* device = static_cast<MSDevice_FCDReplay*>(i->second->getDevice(typeid(MSDevice_FCDReplay)));
155 if (device != nullptr && i->second->hasDeparted()) {
156 device->move(currentTime);
157 }
158 }
159 return DELTA_T;
160}
161
162
163// ---------------------------------------------------------------------------
164// MSDevice_FCDReplay::FCDHandler-methods
165// ---------------------------------------------------------------------------
167 SUMOSAXHandler(file),
168 MapMatcher(OptionsCont::getOptions().getBool("mapmatch.junctions"),
169 OptionsCont::getOptions().getFloat("mapmatch.distance"),
170 MsgHandler::getErrorInstance()) {}
171
172
173void
175 bool ok = true;
176 switch (element) {
178 myTime = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME, "", ok);
179 myPositions.clear();
180 return;
181 case SUMO_TAG_VEHICLE:
182 case SUMO_TAG_PERSON: {
183 if (myTime >= SIMSTEP) {
184 const bool isPerson = element == SUMO_TAG_PERSON;
185 const std::string id = attrs.getString(SUMO_ATTR_ID);
186 const Position xy = Position(attrs.getOpt<double>(SUMO_ATTR_X, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE),
187 attrs.getOpt<double>(SUMO_ATTR_Y, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE));
188 const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
189 const std::string edgeOrLane = attrs.getOpt<std::string>(isPerson ? SUMO_ATTR_EDGE : SUMO_ATTR_LANE, id.c_str(), ok, "");
190 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE);
191 const double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE);
192 const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, libsumo::INVALID_DOUBLE_VALUE);
193 std::string vehicle = attrs.getOpt<std::string>(SUMO_ATTR_VEHICLE, id.c_str(), ok, "");
194 if (isPerson) {
195 if (vehicle == "") {
196 const auto& veh = myPositions.find(xy);
197 if (veh != myPositions.end()) {
198 vehicle = veh->second;
199 }
200 }
201 } else {
202 myPositions[xy] = id;
203 }
204 myTrajectories[id].push_back({myTime, xy, edgeOrLane, pos, speed, angle});
205 const MSEdge* edge = MSEdge::dictionary(isPerson ? edgeOrLane : SUMOXMLDefinitions::getEdgeIDFromLane(edgeOrLane));
206 if (edge == nullptr && edgeOrLane != "") {
207 WRITE_WARNINGF(isPerson ? TL("Unknown edge '%' in fcd replay file for person '%'.") : TL("Unknown lane '%' in fcd replay file for vehicle '%'."), edgeOrLane, id);
208 }
209 if (myRoutes.count(id) == 0) {
210 if (edgeOrLane == "") {
211 const MSLane* const lane = getClosestLane(xy, SVC_PASSENGER);
212 if (lane != nullptr) {
213 myTrajectories[id].back().edgeOrLane = lane->getID();
214 myTrajectories[id].back().lanePos = lane->interpolateGeometryPosToLanePos(
215 lane->getShape().nearest_offset_to_point25D(xy, false));
216 edge = &lane->getEdge();
217 while (edge->isInternal()) { // we cannot use an internal edge for a route
218 edge = edge->getSuccessors().front();
219 }
220 }
221 }
222 myRoutes[id] = std::make_tuple(myTime, type, isPerson, ConstMSEdgeVector{edge}, std::vector<StageStart>());
223 } else {
224 ConstMSEdgeVector& route = std::get<3>(myRoutes[id]);
225 if (edge != nullptr && !edge->isInternal() && edge != route.back()) {
226 route.push_back(edge);
227 }
228 }
229 std::vector<StageStart>& vehicleUsage = std::get<4>(myRoutes[id]);
230 if ((vehicleUsage.empty() && vehicle != "") || (!vehicleUsage.empty() && vehicle != vehicleUsage.back().vehicle)) {
231 vehicleUsage.push_back({vehicle, (int)myTrajectories[id].size() - 1, (int)std::get<3>(myRoutes[id]).size() - 1});
232 }
233 }
234 return;
235 }
236 default:
237 break;
238 }
239}
240
241
244 const std::vector<StageStart>& stages, const Trajectory& t) {
246 plan->push_back(new MSStageWaiting(route.front(), nullptr, 0, params.depart, params.departPos, "awaiting departure", true));
247 int prevRouteOffset = 0;
248 const MSEdge* start = route.front();
249 std::string prevVeh;
250 for (const auto& stageStart : stages) {
251 if (stageStart.vehicle != prevVeh) {
252 if (stageStart.trajectoryOffset != 0) {
253 const MSEdge* prevEdge = MSEdge::dictionary(t[stageStart.trajectoryOffset - 1].edgeOrLane);
254 if (prevVeh == "") {
255 MSStoppingPlace* finalStop = nullptr;
256 if (prevRouteOffset < (int)route.size() - 1 && (route[prevRouteOffset]->getPermissions() & SVC_PEDESTRIAN) == 0) {
257 prevRouteOffset++; // skip the access
258 }
259 int offset = stageStart.routeOffset;
260 if (offset < (int)route.size() - 1 && (route[offset]->getPermissions() & SVC_PEDESTRIAN) == SVC_PEDESTRIAN) {
261 offset++; // a bus stop or two consecutive walks so include the edge in both
262 } else {
263 // may have an access, let's find the stop
264 const std::string& stop = MSNet::getInstance()->getStoppingPlaceID(route[offset]->getLanes()[0], t[stageStart.trajectoryOffset].lanePos, SUMO_TAG_BUS_STOP);
265 if (stop != "") {
267 }
268 }
269 ConstMSEdgeVector subRoute = ConstMSEdgeVector(route.begin() + prevRouteOffset, route.begin() + offset);
270 plan->push_back(new MSStageWalking(params.id, subRoute, finalStop, -1, params.departSpeed, params.departPos, 0, 0));
271 } else {
272 plan->push_back(new MSStageDriving(start, prevEdge, nullptr, -1, 0, {prevVeh}));
273 }
274 start = MSEdge::dictionary(t[stageStart.trajectoryOffset].edgeOrLane);
275 prevVeh = stageStart.vehicle;
276 prevRouteOffset = stageStart.routeOffset;
277 }
278 }
279 }
280 // final stage
281 if (prevVeh == "") {
282 if (prevRouteOffset < (int)route.size() - 1 && (route[prevRouteOffset]->getPermissions() & SVC_PEDESTRIAN) == 0) {
283 prevRouteOffset++;
284 }
285 int offset = (int)route.size() - 1;
286 if ((route[offset]->getPermissions() & SVC_PEDESTRIAN) == SVC_PEDESTRIAN) {
287 offset++;
288 }
289 if (prevRouteOffset < offset) {
290 // otherwise we may be still in a vehicle or in access, skip the stage for now
291 ConstMSEdgeVector subRoute = ConstMSEdgeVector(route.begin() + prevRouteOffset, route.begin() + offset);
292 plan->push_back(new MSStageWalking(params.id, subRoute, nullptr, -1, params.departSpeed, params.departPos, 0, 0));
293 }
294 } else {
295 plan->push_back(new MSStageDriving(start, route.back(), nullptr, -1, 0, {prevVeh}));
296 }
297 return plan;
298}
299
300
303 ConstMSEdgeVector checkedRoute;
304 for (const MSEdge* const e : edges) {
305 if (checkedRoute.empty() || checkedRoute.back()->isConnectedTo(*e, vehicle->getVehicleType().getVehicleClass())) {
306 checkedRoute.push_back(e);
307 } else {
308 const MSEdge* fromEdge = checkedRoute.back();
309 checkedRoute.pop_back();
310 if (!MSNet::getInstance()->getRouterTT(0).compute(fromEdge, e, vehicle, myTime, checkedRoute)) {
311 // TODO maybe warn about disconnected route
312 checkedRoute.push_back(fromEdge);
313 checkedRoute.push_back(e);
314 }
315 // TODO check whether we introduced a big detour
316 }
317 }
318 return checkedRoute;
319}
320
321
322void
324 for (const auto& desc : myRoutes) {
325 const std::string& id = desc.first;
326 const bool isPerson = std::get<2>(desc.second);
327 Trajectory& t = myTrajectories[id];
328 if (t.front().time >= intervalStart) {
329 // new vehicle or person
331 params->id = id;
332 params->depart = std::get<0>(desc.second);
333 params->departPos = t.front().lanePos;
334 params->departSpeed = t.front().speed;
335 // params->arrivalPos = t.back().lanePos;
336 std::string vType = std::get<1>(desc.second);
337 if (vType == "") {
338 vType = isPerson ? DEFAULT_PEDTYPE_ID : DEFAULT_VTYPE_ID;
339 }
341 if (vehicleType == nullptr) {
342 throw ProcessError("Unknown vType '" + vType + "'.");
343 }
344 if (isPerson) {
345 MSTransportable::MSTransportablePlan* plan = makePlan(*params, std::get<3>(desc.second), std::get<4>(desc.second), t);
346 // plan completed, now build the person
347 MSTransportable* person = MSNet::getInstance()->getPersonControl().buildPerson(params, vehicleType, plan, nullptr);
349 if (!MSNet::getInstance()->getPersonControl().add(person)) {
350 throw ProcessError("Duplicate person '" + id + "'.");
351 }
353 if (device == nullptr) { // Person did not get a replay device
354 // TODO delete person
355 continue;
356 }
357 device->setTrajectory(&t);
358 } else {
359 const std::string dummyRouteID = "DUMMY_ROUTE_" + id;
360 const std::vector<SUMOVehicleParameter::Stop> stops;
361 const ConstMSEdgeVector& routeEdges = std::get<3>(desc.second);
362 ConstMSRoutePtr route = std::make_shared<MSRoute>(dummyRouteID, routeEdges, true, nullptr, stops);
363 if (!MSRoute::dictionary(dummyRouteID, route)) {
364 throw ProcessError("Could not add route '" + dummyRouteID + "'.");
365 }
366 if (t.front().edgeOrLane != "") {
369 params->departLane = SUMOXMLDefinitions::getIndexFromLane(t.front().edgeOrLane);
370 }
372 if (!MSNet::getInstance()->getVehicleControl().addVehicle(id, vehicle)) {
373 throw ProcessError("Duplicate vehicle '" + id + "'.");
374 }
376 MSDevice_FCDReplay* device = static_cast<MSDevice_FCDReplay*>(vehicle->getDevice(typeid(MSDevice_FCDReplay)));
377 if (device == nullptr) { // Vehicle did not get a replay device
379 continue;
380 }
381 device->setTrajectory(&t);
382 static_cast<MSVehicle*>(vehicle)->getInfluencer().setSpeedMode(0);
383
384 // repair the route, cannot do this on parsing because a vehicle is needed
385 ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);
386 if (checkedRoute.size() != routeEdges.size()) {
387 vehicle->replaceRouteEdges(checkedRoute, -1, 0, "FCDReplay", true);
388 }
389 }
390 } else if (t.back().time >= intervalStart) {
391 // new data for existing person / vehicle
392 if (isPerson) {
394 if (person == nullptr) {
395 // TODO this should not happen
396 continue;
397 }
398 // TODO optimize: no need to regenerate the whole plan
399 MSTransportable::MSTransportablePlan* plan = makePlan(person->getParameter(), std::get<3>(desc.second), std::get<4>(desc.second), t);
400 const int stageIndex = person->getNumRemainingStages() - 1;
401 MSStage* const final = person->getNextStage(stageIndex);
402 bool append = false;
403 for (MSStage* stage : *plan) {
404 if (stage->getStageType() == final->getStageType() && stage->getFromEdge() == final->getFromEdge()) {
405 // TODO: circular plans?
406 append = true;
407 }
408 if (append) {
409 person->appendStage(stage);
410 }
411 }
412 person->removeStage(stageIndex);
413 } else {
415 const ConstMSEdgeVector& routeEdges = std::get<3>(desc.second);
416 ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);
417 if ((int)checkedRoute.size() != vehicle->getRoute().size()) {
418 vehicle->replaceRouteEdges(checkedRoute, -1, 0, "FCDReplay", true);
419 }
420 }
421 }
422 }
423}
424
425
426void
428 for (const auto& edge : MSEdge::getAllEdges()) {
429 for (MSLane* lane : edge->getLanes()) {
430 Boundary b = lane->getShape().getBoxBoundary();
431 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
432 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
433 tree->Insert(cmin, cmax, lane);
434 }
435 }
436}
437
438
439MSEdge*
441 return MSEdge::dictionary(id);
442}
443
444
445/****************************************************************************/
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
#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:423
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
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
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(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:185
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:1400
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1379
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:431
MSVehicleRouter & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1506
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:378
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1188
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)
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
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:44
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