Eclipse SUMO - Simulation of Urban MObility
MSStageDriving.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 /****************************************************************************/
20 // The common superclass for modelling transportable objects like persons and containers
21 /****************************************************************************/
22 #include <config.h>
23 
25 #include <utils/geom/GeomHelper.h>
29 #include <microsim/MSEdge.h>
30 #include <microsim/MSLane.h>
31 #include <microsim/MSNet.h>
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
47 MSStageDriving::MSStageDriving(const MSEdge* origin, const MSEdge* destination,
48  MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
49  const std::string& group,
50  const std::string& intendedVeh, SUMOTime intendedDepart) :
51  MSStage(destination, toStop, arrivalPos, MSStageType::DRIVING, group),
52  myOrigin(origin),
53  myLines(lines.begin(), lines.end()),
54  myVehicle(nullptr),
55  myVehicleID("NULL"),
56  myVehicleVClass(SVC_IGNORING),
57  myVehicleDistance(-1.),
58  myTimeLoss(-1),
59  myWaitingSince(-1),
60  myWaitingEdge(nullptr),
61  myStopWaitPos(Position::INVALID),
62  myOriginStop(nullptr),
63  myIntendedVehicleID(intendedVeh),
64  myIntendedDepart(intendedDepart) {
65 }
66 
67 
68 MSStage*
70  return new MSStageDriving(myOrigin, myDestination, myDestinationStop, myArrivalPos, std::vector<std::string>(myLines.begin(), myLines.end()),
72 }
73 
74 
76 
77 
78 const MSEdge*
80  if (myVehicle != nullptr) {
81  if (myVehicle->getLane() != nullptr) {
82  return &myVehicle->getLane()->getEdge();
83  }
84  return myVehicle->getEdge();
85  } else if (myArrived >= 0) {
86  return myDestination;
87  } else {
88  return myWaitingEdge;
89  }
90 }
91 
92 
93 const MSEdge*
95  return myWaitingEdge;
96 }
97 
98 
99 double
101  if (isWaiting4Vehicle()) {
102  return myWaitingPos;
103  } else if (myArrived >= 0) {
104  return myArrivalPos;
105  } else {
106  // vehicle may already have passed the lane (check whether this is correct)
107  return MIN2(myVehicle->getPositionOnLane(), getEdge()->getLength());
108  }
109 }
110 
111 int
113  if (isWaiting4Vehicle()) {
115  } else if (myArrived >= 0) {
117  } else {
118  return MSPModel::FORWARD;
119  }
120 }
121 
122 const MSLane*
124  return myVehicle != nullptr ? myVehicle->getLane() : nullptr;
125 }
126 
127 
128 Position
130  if (isWaiting4Vehicle()) {
132  return myStopWaitPos;
133  }
136  } else if (myArrived >= 0) {
139  } else {
140  return myVehicle->getPosition();
141  }
142 }
143 
144 
145 double
147  if (isWaiting4Vehicle()) {
148  return getEdgeAngle(myWaitingEdge, myWaitingPos) + M_PI / 2. * (MSGlobals::gLefthand ? -1 : 1);
149  } else if (myArrived >= 0) {
150  return getEdgeAngle(myDestination, myArrivalPos) + M_PI / 2. * (MSGlobals::gLefthand ? -1 : 1);
151  } else {
152  MSVehicle* veh = dynamic_cast<MSVehicle*>(myVehicle);
153  if (veh != nullptr) {
154  return veh->getAngle();
155  } else {
156  return 0;
157  }
158  }
159 }
160 
161 
162 double
164  if (myVehicle != nullptr) {
165  // distance was previously set to driven distance upon embarking
167  }
168  return myVehicleDistance;
169 }
170 
171 
172 std::string
173 MSStageDriving::getStageDescription(const bool isPerson) const {
174  return isWaiting4Vehicle() ? "waiting for " + joinToString(myLines, ",") : (isPerson ? "driving" : "transport");
175 }
176 
177 
178 std::string
179 MSStageDriving::getStageSummary(const bool isPerson) const {
180  const std::string dest = (getDestinationStop() == nullptr ?
181  " edge '" + getDestination()->getID() + "'" :
182  " stop '" + getDestinationStop()->getID() + "'" + (
183  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
184  const std::string intended = myIntendedVehicleID != "" ?
185  " (vehicle " + myIntendedVehicleID + " at time=" + time2string(myIntendedDepart) + ")" :
186  "";
187  const std::string modeName = isPerson ? "driving" : "transported";
188  return isWaiting4Vehicle() ?
189  "waiting for " + joinToString(myLines, ",") + intended + " then " + modeName + " to " + dest :
190  modeName + " to " + dest;
191 }
192 
193 
194 void
195 MSStageDriving::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous) {
197  ? previous->getOriginStop()
198  : previous->getDestinationStop());
199  myWaitingSince = now;
200  const bool isPerson = transportable->isPerson();
201  if (transportable->getParameter().departProcedure == DEPART_TRIGGERED
202  && transportable->getNumRemainingStages() == transportable->getNumStages() - 1) {
203  // we are the first real stage (stage 0 is WAITING_FOR_DEPART)
204  const std::string vehID = *myLines.begin();
205  SUMOVehicle* startVeh = net->getVehicleControl().getVehicle(vehID);
206  if (startVeh == nullptr) {
207  throw ProcessError("Vehicle '" + vehID + "' not found for triggered departure of " +
208  (isPerson ? "person" : "container") + " '" + transportable->getID() + "'.");
209  }
210  setVehicle(startVeh);
211  if (myOriginStop != nullptr) {
212  myOriginStop->removeTransportable(transportable);
213  }
214  myWaitingEdge = previous->getEdge();
216  myWaitingPos = previous->getEdgePos(now);
217  myVehicle->addTransportable(transportable);
218  return;
219  }
220  if (myOriginStop != nullptr) {
221  // the arrival stop may have an access point
223  myStopWaitPos = myOriginStop->getWaitPosition(transportable);
225  } else {
226  myWaitingEdge = previous->getEdge();
228  myWaitingPos = previous->getEdgePos(now);
229  }
230  if (myOrigin != nullptr && myOrigin != myWaitingEdge) {
231  // transfer at junction
233  myWaitingPos = 0;
234  }
235  SUMOVehicle* const availableVehicle = myWaitingEdge->getWaitingVehicle(transportable, myWaitingPos);
236  const bool triggered = availableVehicle != nullptr &&
237  ((isPerson && availableVehicle->getParameter().departProcedure == DEPART_TRIGGERED) ||
238  (!isPerson && availableVehicle->getParameter().departProcedure == DEPART_CONTAINER_TRIGGERED));
239  if (triggered && !availableVehicle->hasDeparted()) {
240  setVehicle(availableVehicle);
241  if (myOriginStop != nullptr) {
242  myOriginStop->removeTransportable(transportable);
243  }
244  myVehicle->addTransportable(transportable);
248  } else {
249  // check if the ride can be conducted and reserve it
251  const MSEdge* to = getDestination();
252  double toPos = getArrivalPos();
253  if ((to->getPermissions() & SVC_TAXI) == 0 && getDestinationStop() != nullptr) {
254  // try to find usable access edge
255  for (const auto& tuple : getDestinationStop()->getAllAccessPos()) {
256  const MSEdge* access = &std::get<0>(tuple)->getEdge();
257  if ((access->getPermissions() & SVC_TAXI) != 0) {
258  to = access;
259  toPos = std::get<1>(tuple);
260  break;
261  }
262  }
263  }
264  if ((myWaitingEdge->getPermissions() & SVC_TAXI) == 0 && myOriginStop != nullptr) {
265  // try to find usable access edge
266  for (const auto& tuple : myOriginStop->getAllAccessPos()) {
267  const MSEdge* access = &std::get<0>(tuple)->getEdge();
268  if ((access->getPermissions() & SVC_TAXI) != 0) {
269  myWaitingEdge = access;
271  myWaitingPos = std::get<1>(tuple);
272  break;
273  }
274  }
275  }
276  MSDevice_Taxi::addReservation(transportable, getLines(), now, now, myWaitingEdge, myWaitingPos, to, toPos, myGroup);
277  }
278  if (isPerson) {
279  net->getPersonControl().addWaiting(myWaitingEdge, transportable);
280  myWaitingEdge->addPerson(transportable);
281  } else {
282  net->getContainerControl().addWaiting(myWaitingEdge, transportable);
283  myWaitingEdge->addContainer(transportable);
284  }
285  }
286 }
287 
288 
289 void
290 MSStageDriving::tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const {
292  const SUMOTime departed = myDeparted >= 0 ? myDeparted : now;
293  const SUMOTime waitingTime = myWaitingSince >= 0 ? departed - myWaitingSince : -1;
294  const SUMOTime duration = myArrived - myDeparted;
296  os.openTag(transportable->isPerson() ? "ride" : "transport");
297  os.writeAttr("waitingTime", waitingTime >= 0 ? time2string(waitingTime) : "-1");
298  os.writeAttr("vehicle", myVehicleID);
299  os.writeAttr("depart", myDeparted >= 0 ? time2string(myDeparted) : "-1");
300  os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
301  os.writeAttr("arrivalPos", myArrived >= 0 ? toString(getArrivalPos()) : "-1");
302  os.writeAttr("duration", myArrived >= 0 ? time2string(duration) :
303  (myDeparted >= 0 ? time2string(now - myDeparted) : "-1"));
304  os.writeAttr("routeLength", myArrived >= 0 || myVehicle != nullptr ? toString(getDistance()) : "-1");
305  os.writeAttr("timeLoss", myArrived >= 0 ? time2string(myTimeLoss) : "-1");
306  os.closeTag();
307 }
308 
309 
310 void
311 MSStageDriving::routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const {
312  os.openTag(isPerson ? "ride" : "transport");
313  if (getFromEdge() != nullptr) {
314  os.writeAttr(SUMO_ATTR_FROM, getFromEdge()->getID());
315  } else if (previous != nullptr && previous->getStageType() == MSStageType::WAITING_FOR_DEPART) {
316  os.writeAttr(SUMO_ATTR_FROM, previous->getEdge()->getID());
317  }
318  os.writeAttr(SUMO_ATTR_TO, getDestination()->getID());
319  std::string comment = "";
320  if (myDestinationStop != nullptr) {
322  if (myDestinationStop->getMyName() != "") {
323  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
324  }
325  } else if (!unspecifiedArrivalPos()) {
327  }
329  if (myIntendedVehicleID != "") {
331  }
332  if (myIntendedDepart >= 0) {
334  }
335  if (withRouteLength) {
336  os.writeAttr("routeLength", myVehicleDistance);
337  }
338  if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
341  }
342  os.closeTag(comment);
343 }
344 
345 
346 bool
348  assert(myLines.size() > 0);
349  return (myLines.count(vehicle->getID()) > 0
350  || myLines.count(vehicle->getParameter().line) > 0
351  || MSDevice_Taxi::compatibleLine(vehicle->getParameter().line, *myLines.begin())
352  || (myLines.count("ANY") > 0 && (
353  myDestinationStop == nullptr
354  ? vehicle->stopsAtEdge(myDestination)
355  : vehicle->stopsAt(myDestinationStop))));
356 }
357 
358 
359 bool
361  return myVehicle == nullptr && myArrived < 0;
362 }
363 
364 
365 SUMOTime
367  return isWaiting4Vehicle() ? now - myWaitingSince : 0;
368 }
369 
370 
371 double
373  return myVehicle == nullptr ? 0 : myVehicle->getSpeed();
374 }
375 
376 
379  ConstMSEdgeVector result;
380  result.push_back(getFromEdge());
381  result.push_back(getDestination());
382  return result;
383 }
384 
385 double
388 }
389 
390 bool
392  return myArrivalPos == std::numeric_limits<double>::infinity();
393 }
394 
395 const std::string
396 MSStageDriving::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived) {
397  MSStage::setArrived(net, transportable, now, vehicleArrived);
398  if (myVehicle != nullptr) {
399  // distance was previously set to driven distance upon embarking
402  if (vehicleArrived) {
404  } else {
406  }
407  } else {
408  myVehicleDistance = -1.;
409  myTimeLoss = -1;
410  }
411  myVehicle = nullptr; // avoid dangling pointer after vehicle arrival
412  return "";
413 }
414 
415 
416 void
418  myVehicle = v;
419  if (myVehicle != nullptr) {
420  myVehicleID = v->getID();
423  myVehicleVClass = v->getVClass();
424  if (myVehicle->hasDeparted()) {
427  } else {
428  // it probably got triggered by the person
429  myVehicleDistance = 0.;
430  myTimeLoss = 0;
431  }
432  }
433 }
434 
435 void
437  myDestinationStop = nullptr;
438  if (myVehicle != nullptr) {
439  // jumping out of a moving vehicle!
442  // myVehicleDistance and myTimeLoss are updated in subsequent call to setArrived
443  } else {
444  MSTransportableControl& tc = (t->isPerson() ?
450  }
451 }
452 
453 
454 std::string
456  return isWaiting4Vehicle() ? ("waiting for " + joinToString(myLines, ",")
457  + " at " + (myDestinationStop == nullptr
458  ? ("edge '" + myWaitingEdge->getID() + "'")
459  : ("busStop '" + myDestinationStop->getID() + "'"))
460  ) : "";
461 }
462 
463 
464 bool
466  bool canLeave = false;
467  if (t->getDestination() == veh.getEdge()) {
468  // if this is the last stage, we can use the arrivalPos of the person
469  const bool unspecifiedAP = unspecifiedArrivalPos() && (
471  const double arrivalPos = (unspecifiedArrivalPos()
473  SUMO_ATTR_ARRIVALPOS, t->getID(), true)
474  : getArrivalPos());
475  if (unspecifiedAP ||
476  veh.isStoppedInRange(arrivalPos, veh.getLength() + MSGlobals::gStopTolerance)) {
477  canLeave = true;
478  }
479  }
480  if (myDestinationStop != nullptr) {
481  if (!canLeave) {
482  // check with more tolerance due to busStop size and also check
483  // access edges
484  const double accessPos = myDestinationStop->getAccessPos(veh.getEdge());
485  if (accessPos >= 0) {
486  double tolerance = veh.getLength() + MSGlobals::gStopTolerance;
487  if (&myDestinationStop->getLane().getEdge() == veh.getEdge()) {
488  // accessPos is in the middle of the stop
490  }
491  canLeave = veh.isStoppedInRange(accessPos, tolerance);
492  }
493  }
494  }
495  return canLeave;
496 }
497 
498 
499 void
500 MSStageDriving::saveState(std::ostringstream& out) {
501  const bool hasVehicle = myVehicle != nullptr;
502  out << " " << myWaitingSince << " " << myTimeLoss << " " << myArrived << " " << hasVehicle;
503  if (hasVehicle) {
504  out << " " << myDeparted << " " << myVehicle->getID() << " " << myVehicleDistance;
505  }
506 }
507 
508 
509 void
510 MSStageDriving::loadState(MSTransportable* transportable, std::istringstream& state) {
511  bool hasVehicle;
512  state >> myWaitingSince >> myTimeLoss >> myArrived >> hasVehicle;
513  if (hasVehicle) {
514  std::string vehID;
515  state >> myDeparted >> vehID;
517  setVehicle(startVeh);
518  myVehicle->addTransportable(transportable);
519  state >> myVehicleDistance;
520  }
521 }
522 
523 
524 /****************************************************************************/
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
long long int SUMOTime
Definition: SUMOTime.h:32
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_TAXI
vehicle is a taxi
const int VEHPARS_ARRIVALPOS_SET
@ DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
@ DEPART_TRIGGERED
The departure is person triggered.
@ SUMO_ATTR_LINES
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_INTENDED
T MIN2(T a, T b)
Definition: StdDefs.h:74
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:269
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
static void removeReservation(MSTransportable *person, const std::set< std::string > &lines, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, const std::string &group)
retract reservation
static bool isReservation(const std::set< std::string > &lines)
whether the given lines description is a taxi call
static void addReservation(MSTransportable *person, const std::set< std::string > &lines, SUMOTime reservationTime, SUMOTime pickupTime, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, const std::string &group)
add new reservation
bool compatibleLine(const Reservation *res)
whether the given reservation is compatible with the taxi line
static void addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration, const SUMOVehicleClass vClass, const std::string &line, const SUMOTime waitingTime)
record tripinfo data for rides and transports
A road/street connecting two junctions.
Definition: MSEdge.h:77
SUMOVehicle * getWaitingVehicle(MSTransportable *transportable, const double position) const
Definition: MSEdge.cpp:1251
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition: MSEdge.h:605
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.cpp:1019
double getLength() const
return the length of the edge
Definition: MSEdge.h:641
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:673
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
Definition: MSEdge.cpp:1239
static double gStopTolerance
The tolerance to apply when matching waiting persons and vehicles.
Definition: MSGlobals.h:151
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:157
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
The simulated network and simulation perfomer.
Definition: MSNet.h:88
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:1068
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:429
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1059
static const int FORWARD
Definition: MSPModel.h:108
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:110
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
MSStage * clone() const
MSStoppingPlace * myOriginStop
the stop at which this ride starts (or nullptr)
const MSEdge * getEdge() const
Returns the current edge.
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to this stage
std::string myVehicleID
cached vehicle data for output after the vehicle has been removed
virtual ~MSStageDriving()
destructor
Position myStopWaitPos
double myVehicleDistance
ConstMSEdgeVector getEdges() const
the edges of the current stage
std::string getWaitingDescription() const
Return where the person waits and for what.
const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
marks arrival time and records driven distance
std::string myIntendedVehicleID
double getEdgePos(SUMOTime now) const
double getAngle(SUMOTime now) const
returns the angle of the transportable
const std::set< std::string > & getLines() const
bool unspecifiedArrivalPos() const
double getSpeed() const
the speed of the transportable
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the person waits for the given vehicle.
Position getPosition(SUMOTime now) const
returns the position of the transportable
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
const MSEdge * myOrigin
the origin edge
const MSLane * getLane() const
Returns the current lane (if applicable)
SUMOVehicleClass myVehicleVClass
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
const MSEdge * getFromEdge() const
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
std::string myVehicleLine
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
const MSEdge * myWaitingEdge
SUMOTime myIntendedDepart
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
void setVehicle(SUMOVehicle *v)
std::string myVehicleType
double getDistance() const
get travel distance in this stage
const std::set< std::string > myLines
the lines to choose from
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
SUMOTime myTimeLoss
While driving, this is the timeLoss of the vehicle when the ride started, after arrival this is the t...
double getArrivalPos() const
return default value for undefined arrivalPos
bool canLeaveVehicle(const MSTransportable *t, const SUMOVehicle &veh)
checks whether the person may exit at the current vehicle position
SUMOVehicle * myVehicle
The taken vehicle.
void abort(MSTransportable *t)
abort this stage (TraCI)
int getDirection() const
Return the movement directon on the edge.
MSStageDriving(const MSEdge *origin, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group="", const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
virtual MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
Definition: MSStage.h:85
const MSEdge * getDestination() const
returns the destination edge
Definition: MSStage.cpp:70
virtual double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:88
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition: MSStage.h:224
const std::string myGroup
The id of the group of transportables traveling together.
Definition: MSStage.h:239
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition: MSStage.cpp:136
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSStage.h:80
MSStageType getStageType() const
Definition: MSStage.h:117
SUMOTime myArrived
the time at which this stage ended
Definition: MSStage.h:233
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition: MSStage.cpp:158
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:76
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition: MSStage.h:242
double myArrivalPos
the position at which we want to arrive
Definition: MSStage.h:227
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition: MSStage.cpp:147
const MSEdge * myDestination
the next edge to reach by getting transported
Definition: MSStage.h:221
SUMOTime myDeparted
the time at which this stage started
Definition: MSStage.h:230
A lane area vehicles can halt at.
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
double getBeginLanePosition() const
Returns the begin position of this stop.
const std::vector< std::tuple< MSLane *, double, double > > & getAllAccessPos() const
lanes and positions connected to this stop
SumoXMLTag getElement() const
return the type of this stopping place
double getEndLanePosition() const
Returns the end position of this stop.
void removeTransportable(const MSTransportable *p)
Removes a transportable from this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
const std::string & getMyName() const
Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI)
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
bool isPerson() const
Whether it is a person.
int getNumStages() const
Return the total number stages in this persons plan.
const MSEdge * getDestination() const
Returns the current destination.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void unregisterOneWaiting()
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
double getAngle() const
Returns the vehicle's direction in radians.
Definition: MSVehicle.h:683
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
const std::string & getID() const
Returns the id.
Definition: Named.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:248
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:293
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
virtual bool stopsAtEdge(const MSEdge *edge) const =0
Returns whether the vehicle stops at the given edge.
virtual SUMOTime getTimeLoss() const =0
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual double getOdometer() const =0
Returns the distance that was already driven by this vehicle.
virtual double getLength() const =0
Returns the vehicles's length.
virtual void addTransportable(MSTransportable *transportable)=0
Adds a person or container to this vehicle.
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual bool isStoppedInRange(const double pos, const double tolerance) const =0
Returns whether the vehicle is stopped in the range of the given position.
double arrivalPos
(optional) The position the vehicle shall arrive on
bool wasSet(int what) const
Returns whether the given parameter was set.
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
#define M_PI
Definition: odrSpiral.cpp:40