Eclipse SUMO - Simulation of Urban MObility
MSStage.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-2020 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>
43 
44 
45 /* -------------------------------------------------------------------------
46 * static member definitions
47 * ----------------------------------------------------------------------- */
48 const double MSStage::ROADSIDE_OFFSET(3);
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 /* -------------------------------------------------------------------------
55  * MSStage - methods
56  * ----------------------------------------------------------------------- */
57 MSStage::MSStage(const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, MSStageType type, const std::string& group) :
58  myDestination(destination),
59  myDestinationStop(toStop),
60  myArrivalPos(arrivalPos),
61  myDeparted(-1),
62  myArrived(-1),
63  myType(type),
64  myGroup(group)
65 {}
66 
68 
69 const MSEdge*
71  return myDestination;
72 }
73 
74 
75 const MSEdge*
77  return myDestination;
78 }
79 
80 
81 const MSEdge*
83  return myDestination;
84 }
85 
86 
87 double
88 MSStage::getEdgePos(SUMOTime /* now */) const {
89  return myArrivalPos;
90 }
91 
92 
95  return 0;
96 }
97 
98 
99 double
101  return 0.;
102 }
103 
104 
107  ConstMSEdgeVector result;
108  result.push_back(getDestination());
109  return result;
110 }
111 
112 
113 void
115  if (myDeparted < 0) {
116  myDeparted = now;
117  }
118 }
119 
120 SUMOTime
122  return myDeparted;
123 }
124 
125 SUMOTime
127  return myArrived;
128 }
129 
130 const std::string
131 MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) {
132  myArrived = now;
133  return "";
134 }
135 
136 bool
137 MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const {
138  return false;
139 }
140 
141 Position
142 MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const {
143  return getLanePosition(e->getLanes()[0], at, offset);
144 }
145 
146 Position
147 MSStage::getLanePosition(const MSLane* lane, double at, double offset) const {
148  return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
149 }
150 
151 
152 double
153 MSStage::getEdgeAngle(const MSEdge* e, double at) const {
154  return e->getLanes()[0]->getShape().rotationAtOffset(at);
155 }
156 
157 
158 void
159 MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
160  myDestination = newDestination;
161  myDestinationStop = newDestStop;
162  if (newDestStop != nullptr) {
163  myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
164  }
165 }
166 
167 
168 
169 /* -------------------------------------------------------------------------
170 * MSStageTrip - methods
171 * ----------------------------------------------------------------------- */
173  const MSEdge* destination, MSStoppingPlace* toStop,
174  const SUMOTime duration, const SVCPermissions modeSet,
175  const std::string& vTypes, const double speed, const double walkFactor,
176  const std::string& group,
177  const double departPosLat, const bool hasArrivalPos, const double arrivalPos):
178  MSStage(destination, toStop, arrivalPos, MSStageType::TRIP),
179  myOrigin(origin),
180  myOriginStop(fromStop),
181  myDuration(duration),
182  myModeSet(modeSet),
183  myVTypes(vTypes),
184  mySpeed(speed),
185  myWalkFactor(walkFactor),
186  myGroup(group),
187  myDepartPosLat(departPosLat),
188  myHaveArrivalPos(hasArrivalPos) {
189 }
190 
191 
193 
194 MSStage*
196  return new MSStageTrip(myOrigin, const_cast<MSStoppingPlace*>(myOriginStop),
199 }
200 
201 
202 Position
204  // may be called concurrently while the trip is still being routed
206 }
207 
208 
209 double
210 MSStageTrip::getAngle(SUMOTime /* now */) const {
211  // may be called concurrently while the trip is still being routed
212  return getEdgeAngle(myOrigin, myDepartPos) + M_PI / 2 * (MSGlobals::gLefthand ? -1 : 1);
213 }
214 
215 
216 const MSEdge*
218  return myOrigin;
219 }
220 
221 
222 double
224  return myDepartPos;
225 }
226 
227 
228 const std::string
229 MSStageTrip::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived) {
230  MSStage::setArrived(net, transportable, now, vehicleArrived);
231  MSVehicleControl& vehControl = net->getVehicleControl();
232  std::vector<SUMOVehicleParameter*> pars;
233  for (StringTokenizer st(myVTypes); st.hasNext();) {
234  pars.push_back(new SUMOVehicleParameter());
235  pars.back()->vtypeid = st.next();
236  pars.back()->parametersSet |= VEHPARS_VTYPE_SET;
237  pars.back()->departProcedure = DEPART_TRIGGERED;
238  pars.back()->id = transportable->getID() + "_" + toString(pars.size() - 1);
239  }
240  if (pars.empty()) {
241  if ((myModeSet & SVC_PASSENGER) != 0) {
242  pars.push_back(new SUMOVehicleParameter());
243  pars.back()->id = transportable->getID() + "_0";
244  pars.back()->departProcedure = DEPART_TRIGGERED;
245  } else if ((myModeSet & SVC_TAXI) != 0) {
246  pars.push_back(new SUMOVehicleParameter());
247  pars.back()->vtypeid = DEFAULT_TAXITYPE_ID;
248  pars.back()->id = transportable->getID() + "_taxi";
249  pars.back()->line = "taxi";
250  } else if ((myModeSet & SVC_BICYCLE) != 0) {
251  pars.push_back(new SUMOVehicleParameter());
252  pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
253  pars.back()->id = transportable->getID() + "_b0";
254  pars.back()->departProcedure = DEPART_TRIGGERED;
255  } else {
256  // allow shortcut via busStop even when not intending to ride
257  pars.push_back(nullptr);
258  }
259  }
260  MSStage* previous;
262  if (transportable->getNumStages() == transportable->getNumRemainingStages()) { // this is a difficult way to check that we are the first stage
263  myDepartPos = transportable->getParameter().departPos;
266  }
267  previous = new MSStageWaiting(myOrigin, nullptr, -1, transportable->getParameter().depart, myDepartPos, "start", true);
268  time = transportable->getParameter().depart;
269  } else {
270  previous = transportable->getNextStage(-1);
271  myDepartPos = previous->getArrivalPos();
272  }
273  // TODO This works currently only for a single vehicle type
274  const int oldNumStages = transportable->getNumStages();
275  for (SUMOVehicleParameter* vehPar : pars) {
276  SUMOVehicle* vehicle = nullptr;
277  bool isTaxi = false;
278  if (vehPar != nullptr) {
279  isTaxi = vehPar->vtypeid == DEFAULT_TAXITYPE_ID && vehPar->line == "taxi";
280  if (myDepartPos != 0) {
281  vehPar->departPosProcedure = DepartPosDefinition::GIVEN;
282  vehPar->departPos = myDepartPos;
283  vehPar->parametersSet |= VEHPARS_DEPARTPOS_SET;
284  }
285  MSVehicleType* type = vehControl.getVType(vehPar->vtypeid);
286  if (type->getVehicleClass() != SVC_IGNORING && (myOrigin->getPermissions() & type->getVehicleClass()) == 0 && !isTaxi) {
287  WRITE_WARNING("Ignoring vehicle type '" + type->getID() + "' when routing person '" + transportable->getID() + "' because it is not allowed on the start edge.");
288  } else {
289  const MSRoute* const routeDummy = new MSRoute(vehPar->id, ConstMSEdgeVector({ myOrigin }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
290  vehicle = vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes);
291  }
292  }
293  bool carUsed = false;
294  std::vector<MSNet::MSIntermodalRouter::TripItem> result;
295  int stageIndex = 1;
297  transportable->getMaxSpeed() * myWalkFactor, vehicle, myModeSet, time, result)) {
298  for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = result.begin(); it != result.end(); ++it) {
299  if (!it->edges.empty()) {
301  double localArrivalPos = bs != nullptr ? bs->getAccessPos(it->edges.back()) : it->edges.back()->getLength() / 2.;
302  if (it + 1 == result.end() && myHaveArrivalPos) {
303  localArrivalPos = myArrivalPos;
304  }
305  if (it->line == "") {
306  // determine walk departPos
307  double depPos = previous->getArrivalPos();
308  if (previous->getDestinationStop() != nullptr) {
309  depPos = previous->getDestinationStop()->getAccessPos(it->edges.front());
310  } else if (myOrigin->isTazConnector()) {
311  // walk the whole length of the first edge
312  const MSEdge* first = it->edges.front();
313  if (std::find(first->getPredecessors().begin(), first->getPredecessors().end(), myOrigin) != first->getPredecessors().end()) {
314  depPos = 0;
315  } else {
316  depPos = first->getLength();
317  }
318  } else if (previous->getDestination() != it->edges.front()) {
319  if ((previous->getDestination()->getToJunction() == it->edges.front()->getToJunction())
320  || (previous->getDestination()->getFromJunction() == it->edges.front()->getToJunction())) {
321  depPos = it->edges.front()->getLength();
322  } else {
323  depPos = 0.;
324  }
325  }
326  if (myDestination->isTazConnector()) {
327  // walk the whole length of the last edge
328  const MSEdge* last = it->edges.back();
329  if (std::find(last->getSuccessors().begin(), last->getSuccessors().end(), myDestination) != last->getSuccessors().end()) {
330  localArrivalPos = last->getLength();
331  } else {
332  localArrivalPos = 0;
333  }
334  }
335  previous = new MSPerson::MSPersonStage_Walking(transportable->getID(), it->edges, bs, myDuration, mySpeed, depPos, localArrivalPos, myDepartPosLat);
336  transportable->appendStage(previous, stageIndex++);
337  } else if (isTaxi) {
338  const ConstMSEdgeVector& prevEdges = previous->getEdges();
339  if (prevEdges.size() >= 2) {
340  // determine walking direction and let the previous
341  // stage end after entering its final edge
342  const MSEdge* last = prevEdges.back();
343  const MSEdge* prev = prevEdges[prevEdges.size() - 2];
344  if (last->getFromJunction() == prev->getToJunction() || prev->getFromJunction() == last->getFromJunction()) {
345  previous->setArrivalPos(MIN2(last->getLength(), 10.0));
346  } else {
347  previous->setArrivalPos(MAX2(0.0, last->getLength() - 10));
348  }
349  }
350  previous = new MSStageDriving(nullptr, it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ "taxi" }), myGroup);
351  transportable->appendStage(previous, stageIndex++);
352  } else if (vehicle != nullptr && it->line == vehicle->getID()) {
353  if (bs == nullptr && it + 1 != result.end()) {
354  // we have no defined endpoint and are in the middle of the trip, drive as far as possible
355  localArrivalPos = it->edges.back()->getLength();
356  }
357  previous = new MSStageDriving(nullptr, it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }));
358  transportable->appendStage(previous, stageIndex++);
359  vehicle->replaceRouteEdges(it->edges, -1, 0, "person:" + transportable->getID(), true);
360  vehicle->setArrivalPos(localArrivalPos);
361  vehControl.addVehicle(vehPar->id, vehicle);
362  carUsed = true;
363  } else {
364  previous = new MSStageDriving(nullptr, it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }), myGroup, it->intended, TIME2STEPS(it->depart));
365  transportable->appendStage(previous, stageIndex++);
366  }
367  }
368  }
369  } else {
370  // append stage so the GUI won't crash due to inconsistent state
372  if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
373  return "No connection found between edge '" + myOrigin->getID() + "' and edge '" + (myDestinationStop != nullptr ? myDestinationStop->getID() : myDestination->getID()) + "' for person '" + transportable->getID() + "'.";
374  }
375  }
376  if (vehicle != nullptr && (isTaxi || !carUsed)) {
377  vehControl.deleteVehicle(vehicle, true);
378  }
379  }
380  if (transportable->getNumStages() == oldNumStages) {
381  // append stage so the GUI won't crash due to inconsistent state
383  if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
384  return "Empty route between edge '" + myOrigin->getID() + "' and edge '" + (myDestinationStop != nullptr ? myDestinationStop->getID() : myDestination->getID()) + "' for person '" + transportable->getID() + "'.";
385  }
386  }
387  return "";
388 }
389 
390 
391 void
392 MSStageTrip::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* /* previous */) {
393  // just skip the stage, every interesting happens in setArrived
394  transportable->proceed(net, now);
395 }
396 
397 
398 std::string
399 MSStageTrip::getStageSummary(const bool) const {
400  return "trip from '" + myOrigin->getID() + "' to '" + getDestination()->getID() + "'";
401 }
402 
403 
404 /* -------------------------------------------------------------------------
405 * MSStageWaiting - methods
406 * ----------------------------------------------------------------------- */
408  SUMOTime duration, SUMOTime until, double pos, const std::string& actType,
409  const bool initial) :
410  MSStage(destination, toStop, SUMOVehicleParameter::interpretEdgePos(
411  pos, destination->getLength(), SUMO_ATTR_DEPARTPOS, "stopping at " + destination->getID()),
413  myWaitingDuration(duration),
414  myWaitingUntil(until),
415  myActType(actType) {
416 }
417 
418 
420 
421 MSStage*
424 }
425 
426 SUMOTime
428  return myWaitingUntil;
429 }
430 
431 
432 Position
436 }
437 
438 
439 double
442 }
443 
444 
445 void
446 MSStageWaiting::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous) {
447  myDeparted = now;
448  const SUMOTime until = MAX3(now, now + myWaitingDuration, myWaitingUntil);
449  if (myDestinationStop != nullptr) {
450  myDestinationStop->addTransportable(transportable);
451  }
452  if (dynamic_cast<MSPerson*>(transportable) != nullptr) {
453  previous->getEdge()->addPerson(transportable);
454  net->getPersonControl().setWaitEnd(until, transportable);
455  } else {
456  previous->getEdge()->addContainer(transportable);
457  net->getContainerControl().setWaitEnd(until, transportable);
458  }
459 }
460 
461 
462 void
465  os.openTag("stop");
466  os.writeAttr("duration", time2string(myArrived - myDeparted));
467  os.writeAttr("arrival", time2string(myArrived));
468  os.writeAttr("arrivalPos", toString(myArrivalPos));
469  os.writeAttr("actType", toString(myActType));
470  os.closeTag();
471  }
472 }
473 
474 
475 void
476 MSStageWaiting::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool, const MSStage* const /* previous */) const {
478  os.openTag("stop");
479  std::string comment = "";
480  if (myDestinationStop != nullptr) {
482  if (myDestinationStop->getMyName() != "") {
483  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
484  }
485  } else {
486  // lane index is arbitrary
487  os.writeAttr(SUMO_ATTR_LANE, getDestination()->getID() + "_0");
489  }
490  if (myWaitingDuration >= 0) {
492  }
493  if (myWaitingUntil >= 0) {
495  }
496  os.closeTag(comment);
497  }
498 }
499 
500 
501 SUMOTime
503  return now - myDeparted;
504 }
505 
506 
507 void
509  MSTransportableControl& tc = (t->isPerson() ?
512  tc.abortWaiting(t);
513 }
514 
515 
516 std::string
517 MSStageWaiting::getStageSummary(const bool /* isPerson */) const {
518  std::string timeInfo;
519  if (myWaitingUntil >= 0) {
520  timeInfo += " until " + time2string(myWaitingUntil);
521  }
522  if (myWaitingDuration >= 0) {
523  timeInfo += " duration " + time2string(myWaitingDuration);
524  }
525  return "stopping at edge '" + getDestination()->getID() + "' " + timeInfo + " (" + myActType + ")";
526 }
527 
528 
529 /* -------------------------------------------------------------------------
530 * MSStageMoving - methods
531 * ----------------------------------------------------------------------- */
533  delete myState;
534 }
535 
536 const MSEdge*
538  if (myCurrentInternalEdge != nullptr) {
539  return myCurrentInternalEdge;
540  } else {
541  return *myRouteStep;
542  }
543 }
544 
545 const MSEdge*
547  return myRoute.front();
548 }
549 
552  return myRoute;
553 }
554 
555 
556 double
558  return myState == nullptr ? 0. : myState->getEdgePos(*this, now);
559 }
560 
561 Position
563  return myState == nullptr ? Position::INVALID : myState->getPosition(*this, now);
564 }
565 
566 double
568  return myState == nullptr ? 0. : myState->getAngle(*this, now);
569 }
570 
571 SUMOTime
573  return myState == nullptr ? 0 : myState->getWaitingTime(*this, now);
574 }
575 
576 double
578  return myState == nullptr ? 0. : myState->getSpeed(*this);
579 }
580 
581 const MSLane*
583  return myState == nullptr ? nullptr : myState->getLane();
584 }
585 
586 void
587 MSStageMoving::setRouteIndex(MSTransportable* const transportable, int routeOffset) {
588  assert(routeOffset >= 0);
589  assert(routeOffset < (int)myRoute.size());
590  getEdge()->removePerson(transportable);
591  myRouteStep = myRoute.begin() + routeOffset;
592  getEdge()->addPerson(transportable);
593 }
594 
595 void
596 MSStageMoving::replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset) {
597  assert(routeOffset >= 0);
598  assert(routeOffset < (int)edges.size());
599  getEdge()->removePerson(transportable);
600  myRoute = edges;
601  myRouteStep = myRoute.begin() + routeOffset;
602  getEdge()->addPerson(transportable);
603 }
604 
605 /****************************************************************************/
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:31
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
const std::string DEFAULT_TAXITYPE_ID
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_BIKETYPE_ID
@ RANDOM
The position is chosen randomly.
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_VTYPE_SET
@ DEPART_TRIGGERED
The departure is person triggered.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_DURATION
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
T MAX3(T a, T b, T c)
Definition: StdDefs.h:93
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
bool compute(const E *from, const E *to, const double departPos, const double arrivalPos, const std::string stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
A road/street connecting two junctions.
Definition: MSEdge.h:77
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition: MSEdge.h:594
const MSEdgeVector & getPredecessors() const
Definition: MSEdge.h:383
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.cpp:948
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:166
const MSJunction * getFromJunction() const
Definition: MSEdge.h:388
double getLength() const
return the length of the edge
Definition: MSEdge.h:630
bool isTazConnector() const
Definition: MSEdge.h:279
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:662
const MSJunction * getToJunction() const
Definition: MSEdge.h:392
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1013
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.cpp:953
static bool gCheckRoutes
Definition: MSGlobals.h:76
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:136
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:476
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:497
The simulated network and simulation perfomer.
Definition: MSNet.h:89
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1237
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:995
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:371
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1098
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:986
virtual ~MSStage()
destructor
Definition: MSStage.cpp:67
const MSEdge * getDestination() const
returns the destination edge
Definition: MSStage.cpp:70
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSStage.cpp:106
virtual double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:88
virtual const MSEdge * getFromEdge() const
Definition: MSStage.cpp:82
MSStage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, MSStageType type, const std::string &group="")
constructor
Definition: MSStage.cpp:57
virtual double getArrivalPos() const
Definition: MSStage.h:89
SUMOTime getDeparted() const
get departure time of stage
Definition: MSStage.cpp:121
void setDeparted(SUMOTime now)
logs end of the step
Definition: MSStage.cpp:114
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition: MSStage.cpp:137
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition: MSStage.h:221
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition: MSStage.cpp:131
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSStage.h:80
SUMOTime getArrived() const
get arrival time of stage
Definition: MSStage.cpp:126
void setArrivalPos(double arrivalPos)
Definition: MSStage.h:93
virtual double getSpeed() const
the speed of the transportable
Definition: MSStage.cpp:100
SUMOTime myArrived
the time at which this stage ended
Definition: MSStage.h:230
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition: MSStage.cpp:159
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition: MSStage.cpp:147
MSStageType myType
The type of this stage.
Definition: MSStage.h:233
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition: MSStage.cpp:153
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:239
double myArrivalPos
the position at which we want to arrive
Definition: MSStage.h:224
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition: MSStage.cpp:142
const MSEdge * myDestination
the next edge to reach by getting transported
Definition: MSStage.h:218
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSStage.cpp:94
SUMOTime myDeparted
the time at which this stage started
Definition: MSStage.h:227
double getAngle(SUMOTime now) const
Returns the angle of the container.
Definition: MSStage.cpp:567
const MSLane * getLane() const
Returns the current lane.
Definition: MSStage.cpp:582
double getEdgePos(SUMOTime now) const
Returns the offset from the start of the current edge measured in its natural direction.
Definition: MSStage.cpp:557
MSTransportableStateAdapter * myState
state that is to be manipulated by MSPModel
Definition: MSStage.h:523
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSStage.cpp:551
SUMOTime getWaitingTime(SUMOTime now) const
Returns the time the container spent waiting.
Definition: MSStage.cpp:572
double getSpeed() const
Returns the speed of the container.
Definition: MSStage.cpp:577
MSEdge * myCurrentInternalEdge
The current internal edge this transportable is on or nullptr.
Definition: MSStage.h:532
Position getPosition(SUMOTime now) const
Returns the position of the container.
Definition: MSStage.cpp:562
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:537
virtual void setRouteIndex(MSTransportable *const transportable, int routeOffset)
place transportable on a previously passed edge
Definition: MSStage.cpp:587
std::vector< const MSEdge * > myRoute
The route of the container.
Definition: MSStage.h:526
const MSEdge * getFromEdge() const
Returns first edge of the containers route.
Definition: MSStage.cpp:546
virtual void replaceRoute(MSTransportable *const transportable, const ConstMSEdgeVector &edges, int routeOffset)
Definition: MSStage.cpp:596
std::vector< const MSEdge * >::iterator myRouteStep
current step
Definition: MSStage.h:529
virtual ~MSStageMoving()
destructor
Definition: MSStage.cpp:532
const bool myHaveArrivalPos
whether an arrivalPos was in the input
Definition: MSStage.h:358
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSStage.cpp:210
MSStageTrip(const MSEdge *origin, MSStoppingPlace *fromStop, const MSEdge *destination, MSStoppingPlace *toStop, const SUMOTime duration, const SVCPermissions modeSet, const std::string &vTypes, const double speed, const double walkFactor, const std::string &group, const double departPosLat, const bool hasArrivalPos, const double arrivalPos)
constructor
Definition: MSStage.cpp:172
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSStage.cpp:392
const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition: MSStage.cpp:229
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSStage.cpp:399
const std::string myVTypes
The possible vehicles to use.
Definition: MSStage.h:340
double myDepartPos
The depart position.
Definition: MSStage.h:352
double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:223
MSStage * clone() const
Definition: MSStage.cpp:195
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:217
const MSEdge * myOrigin
the origin edge
Definition: MSStage.h:328
const double mySpeed
The walking speed.
Definition: MSStage.h:343
MSStoppingPlace * myOriginStop
the origin edge
Definition: MSStage.h:331
SUMOTime myDuration
the time the trip should take (applies to only walking)
Definition: MSStage.h:334
const double myWalkFactor
The factor to apply to walking durations.
Definition: MSStage.h:346
const double myDepartPosLat
The lateral depart position.
Definition: MSStage.h:355
const SVCPermissions myModeSet
The allowed modes of transportation.
Definition: MSStage.h:337
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSStage.cpp:203
virtual ~MSStageTrip()
destructor
Definition: MSStage.cpp:192
std::string myGroup
The group for this personTrip.
Definition: MSStage.h:349
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
Definition: MSStage.cpp:476
SUMOTime getUntil() const
Definition: MSStage.cpp:427
SUMOTime myWaitingDuration
the time the person is waiting
Definition: MSStage.h:429
SUMOTime myWaitingUntil
the time until the person is waiting
Definition: MSStage.h:432
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSStage.cpp:502
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSStage.cpp:446
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSStage.cpp:440
MSStage * clone() const
Definition: MSStage.cpp:422
std::string myActType
The type of activity.
Definition: MSStage.h:435
virtual ~MSStageWaiting()
destructor
Definition: MSStage.cpp:419
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSStage.cpp:508
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSStage.cpp:517
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSStage.cpp:433
MSStageWaiting(const MSEdge *destination, MSStoppingPlace *toStop, SUMOTime duration, SUMOTime until, double pos, const std::string &actType, const bool initial)
constructor
Definition: MSStage.cpp:407
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSStage.cpp:463
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
bool addTransportable(MSTransportable *p)
adds a transportable to this stop
double getEndLanePosition() const
Returns the end position of this stop.
const std::string & getMyName() const
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
bool isPerson() const
Whether it is a person.
int getNumStages() const
Return the total number stages in this persons plan.
MSStage * getNextStage(int next) const
Return the current stage.
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
double getMaxSpeed() const
Returns the object's maximum speed.
virtual double getSpeed(const MSStageMoving &stage) const =0
return the current speed of the transportable
virtual Position getPosition(const MSStageMoving &stage, SUMOTime now) const =0
return the network coordinate of the transportable
virtual SUMOTime getWaitingTime(const MSStageMoving &stage, SUMOTime now) const =0
return the time the transportable spent standing
virtual double getEdgePos(const MSStageMoving &stage, SUMOTime now) const =0
return the offset from the start of the current edge measured in its natural direction
virtual const MSLane * getLane() const
whether the transportable is jammed
Definition: MSPModel.h:174
virtual double getAngle(const MSStageMoving &stage, SUMOTime now) const =0
return the direction in which the transportable faces in degrees
The class responsible for building and deletion of vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
The car-following model and parameter.
Definition: MSVehicleType.h:62
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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:73
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
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:239
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:36
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:282
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:51
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
Structure representing possible vehicle parameter.
double departPos
(optional) The position the vehicle shall depart from
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
bool hasNext()
returns the information whether further substrings exist
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