SUMO - Simulation of Urban MObility
MSTransportable.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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The common superclass for modelling transportable objects like persons and containers
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <utils/geom/GeomHelper.h>
29 #include "MSEdge.h"
30 #include "MSLane.h"
31 #include "MSNet.h"
33 #include "MSVehicleControl.h"
34 #include "MSTransportableControl.h"
35 #include "MSTransportable.h"
36 
37 /* -------------------------------------------------------------------------
38 * static member definitions
39 * ----------------------------------------------------------------------- */
40 const double MSTransportable::ROADSIDE_OFFSET(3);
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 /* -------------------------------------------------------------------------
47  * MSTransportable::Stage - methods
48  * ----------------------------------------------------------------------- */
49 MSTransportable::Stage::Stage(const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, StageType type)
50  : myDestination(destination), myDestinationStop(toStop), myArrivalPos(arrivalPos), myDeparted(-1), myArrived(-1), myType(type) {}
51 
53 
54 const MSEdge*
56  return myDestination;
57 }
58 
59 
60 const MSEdge*
62  return myDestination;
63 }
64 
65 
66 const MSEdge*
68  return myDestination;
69 }
70 
71 
72 double
74  return myArrivalPos;
75 }
76 
77 
80  return 0;
81 }
82 
83 
84 double
86  return 0.;
87 }
88 
89 
92  ConstMSEdgeVector result;
93  result.push_back(getDestination());
94  return result;
95 }
96 
97 
98 void
100  if (myDeparted < 0) {
101  myDeparted = now;
102  }
103 }
104 
105 void
107  myArrived = now;
108 }
109 
110 bool
111 MSTransportable::Stage::isWaitingFor(const std::string& /*line*/) const {
112  return false;
113 }
114 
115 Position
116 MSTransportable::Stage::getEdgePosition(const MSEdge* e, double at, double offset) const {
117  return getLanePosition(e->getLanes()[0], at, offset);
118 }
119 
120 Position
121 MSTransportable::Stage::getLanePosition(const MSLane* lane, double at, double offset) const {
122  return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
123 }
124 
125 double
126 MSTransportable::Stage::getEdgeAngle(const MSEdge* e, double at) const {
127  return e->getLanes()[0]->getShape().rotationAtOffset(at);
128 }
129 
130 
131 /* -------------------------------------------------------------------------
132 * MSTransportable::Stage_Waiting - methods
133 * ----------------------------------------------------------------------- */
135  SUMOTime duration, SUMOTime until, double pos, const std::string& actType,
136  const bool initial) :
137  MSTransportable::Stage(destination, 0, SUMOVehicleParameter::interpretEdgePos(
138  pos, destination->getLength(), SUMO_ATTR_DEPARTPOS, "stopping at " + destination->getID()),
139  initial ? WAITING_FOR_DEPART : WAITING),
140  myWaitingDuration(duration),
141  myWaitingUntil(until),
142  myActType(actType) {
143 }
144 
145 
147 
148 
149 SUMOTime
151  return myWaitingUntil;
152 }
153 
154 
155 Position
158  ROADSIDE_OFFSET * (MSNet::getInstance()->lefthand() ? -1 : 1));
159 }
160 
161 
162 double
164  return getEdgeAngle(myDestination, myArrivalPos) + M_PI / 2 * (MSNet::getInstance()->lefthand() ? -1 : 1);
165 }
166 
167 
168 void
170  myDeparted = now;
171  const SUMOTime until = MAX3(now, now + myWaitingDuration, myWaitingUntil);
172  if (dynamic_cast<MSPerson*>(transportable) != 0) {
173  previous->getEdge()->addPerson(transportable);
174  net->getPersonControl().setWaitEnd(until, transportable);
175  } else {
176  previous->getEdge()->addContainer(transportable);
177  net->getContainerControl().setWaitEnd(until, transportable);
178  }
179 }
180 
181 
182 void
184  if (myType != WAITING_FOR_DEPART) {
185  os.openTag("stop");
186  os.writeAttr("duration", time2string(myArrived - myDeparted));
187  os.writeAttr("arrival", time2string(myArrived));
188  os.writeAttr("arrivalPos", toString(myArrivalPos));
189  os.writeAttr("actType", toString(myActType));
190  os.closeTag();
191  }
192 }
193 
194 
195 void
197  if (myType != WAITING_FOR_DEPART) {
198  // lane index is arbitrary
199  os.openTag("stop").writeAttr(SUMO_ATTR_LANE, getDestination()->getID() + "_0");
200  if (myWaitingDuration >= 0) {
202  }
203  if (myWaitingUntil >= 0) {
205  }
206  os.closeTag();
207  }
208 }
209 
210 
211 void
213  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "actstart " + myActType)
214  .writeAttr("agent", p.getID()).writeAttr("link", getEdge()->getID()).closeTag();
215 }
216 
217 
218 void
220  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "actend " + myActType).writeAttr("agent", p.getID())
221  .writeAttr("link", getEdge()->getID()).closeTag();
222 }
223 
224 
225 SUMOTime
227  return now - myDeparted;
228 }
229 
230 
231 void
233  MSTransportableControl& tc = (dynamic_cast<MSPerson*>(t) != 0 ?
236  tc.abortWaiting(t);
237 }
238 
239 
240 std::string
242  std::string timeInfo;
243  if (myWaitingUntil >= 0) {
244  timeInfo += " until " + time2string(myWaitingUntil);
245  }
246  if (myWaitingDuration >= 0) {
247  timeInfo += " duration " + time2string(myWaitingDuration);
248  }
249  return "stopping at edge '" + getDestination()->getID() + "' " + timeInfo + " (" + myActType + ")";
250 }
251 
252 
253 /* -------------------------------------------------------------------------
254 * MSTransportable::Stage_Driving - methods
255 * ----------------------------------------------------------------------- */
257  MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
258  const std::string& intendedVeh, SUMOTime intendedDepart) :
259  MSTransportable::Stage(destination, toStop, arrivalPos, DRIVING),
260  myLines(lines.begin(), lines.end()),
261  myVehicle(nullptr),
262  myVehicleID("NULL"),
263  myVehicleDistance(-1.),
264  myWaitingEdge(nullptr),
265  myStopWaitPos(Position::INVALID),
266  myIntendedVehicleID(intendedVeh),
267  myIntendedDepart(intendedDepart) {
268 }
269 
270 
272 
273 const MSEdge*
275  if (myVehicle != nullptr) {
276  if (myVehicle->getLane() != nullptr) {
277  return &myVehicle->getLane()->getEdge();
278  }
279  return myVehicle->getEdge();
280  }
281  return myWaitingEdge;
282 }
283 
284 
285 const MSEdge*
287  return myWaitingEdge;
288 }
289 
290 
291 double
293  if (isWaiting4Vehicle()) {
294  return myWaitingPos;
295  }
296  // vehicle may already have passed the lane (check whether this is correct)
298 }
299 
300 
301 Position
303  if (isWaiting4Vehicle()) {
305  return myStopWaitPos;
306  }
308  ROADSIDE_OFFSET * (MSNet::getInstance()->lefthand() ? -1 : 1));
309  }
310  return myVehicle->getPosition();
311 }
312 
313 
314 double
316  if (!isWaiting4Vehicle()) {
317  MSVehicle* veh = dynamic_cast<MSVehicle*>(myVehicle);
318  if (veh != 0) {
319  return veh->getAngle();
320  } else {
321  return 0;
322  }
323  }
324  return getEdgeAngle(myWaitingEdge, myWaitingPos) + M_PI / 2. * (MSNet::getInstance()->lefthand() ? -1 : 1);
325 }
326 
327 
328 bool
329 MSTransportable::Stage_Driving::isWaitingFor(const std::string& line) const {
330  return myLines.count(line) > 0;
331 }
332 
333 
334 bool
336  return myVehicle == 0;
337 }
338 
339 
340 SUMOTime
342  return isWaiting4Vehicle() ? now - myDeparted : 0;
343 }
344 
345 
346 double
348  return isWaiting4Vehicle() ? 0 : myVehicle->getSpeed();
349 }
350 
351 
354  ConstMSEdgeVector result;
355  result.push_back(getFromEdge());
356  result.push_back(getDestination());
357  return result;
358 }
359 
360 void
363  if (myVehicle != 0) {
364  // distance was previously set to driven distance upon embarking
368  } else {
369  myVehicleDistance = -1.;
370  }
371 }
372 
373 void
375  myVehicle = v;
376  myVehicleID = v->getID();
378  myVehicleVClass = v->getVClass();
382 }
383 
384 void
386  myDestination = newDestination;
387  myDestinationStop = newDestStop;
388  if (newDestStop != 0) {
389  myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
390  }
391 }
392 
393 
394 void
396  if (myVehicle != 0) {
397  // jumping out of a moving vehicle!
398  dynamic_cast<MSVehicle*>(myVehicle)->removeTransportable(t);
399  }
400 }
401 
402 
403 std::string
405  return isWaiting4Vehicle() ? ("waiting for " + joinToString(myLines, ",")
406  + " at " + (myDestinationStop == 0
407  ? ("edge '" + myWaitingEdge->getID() + "'")
408  : ("busStop '" + myDestinationStop->getID() + "'"))
409  ) : "";
410 }
411 
412 
413 void
415  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "arrival").writeAttr("agent", p.getID()).writeAttr("link", getEdge()->getID()).closeTag();
416 }
417 
418 
419 void
421  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "arrival").writeAttr("agent", p.getID()).writeAttr("link", getEdge()->getID()).closeTag();
422 }
423 
424 
425 
426 /* -------------------------------------------------------------------------
427  * MSTransportable - methods
428  * ----------------------------------------------------------------------- */
430  : myParameter(pars), myVType(vtype), myPlan(plan) {
431  myStep = myPlan->begin();
432 }
433 
435  if (myPlan != 0) {
436  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
437  delete *i;
438  }
439  delete myPlan;
440  myPlan = 0;
441  }
442  delete myParameter;
443  if (myVType->isVehicleSpecific()) {
445  }
446 }
447 
448 const std::string&
450  return myParameter->id;
451 }
452 
453 SUMOTime
455  return myParameter->depart;
456 }
457 
458 void
460  (*myStep)->setDeparted(now);
461 }
462 
463 double
465  return (*myStep)->getEdgePos(MSNet::getInstance()->getCurrentTimeStep());
466 }
467 
468 Position
470  return (*myStep)->getPosition(MSNet::getInstance()->getCurrentTimeStep());
471 }
472 
473 double
475  return (*myStep)->getAngle(MSNet::getInstance()->getCurrentTimeStep());
476 }
477 
478 double
480  return STEPS2TIME((*myStep)->getWaitingTime(MSNet::getInstance()->getCurrentTimeStep()));
481 }
482 
483 double
485  return (*myStep)->getSpeed();
486 }
487 
488 
489 int
491  return (int)(myPlan->end() - myStep);
492 }
493 
494 int
496  return (int)myPlan->size();
497 }
498 
499 void
501  // myStep is invalidated upon modifying myPlan
502  const int stepIndex = (int)(myStep - myPlan->begin());
503  if (next < 0) {
504  myPlan->push_back(stage);
505  } else {
506  if (stepIndex + next > (int)myPlan->size()) {
507  throw ProcessError("invalid index '" + toString(next) + "' for inserting new stage into plan of '" + getID() + "'");
508  }
509  myPlan->insert(myPlan->begin() + stepIndex + next, stage);
510  }
511  myStep = myPlan->begin() + stepIndex;
512 }
513 
514 
515 void
517  assert(myStep + next < myPlan->end());
518  assert(next >= 0);
519  if (next > 0) {
520  // myStep is invalidated upon modifying myPlan
521  int stepIndex = (int)(myStep - myPlan->begin());
522  delete *(myStep + next);
523  myPlan->erase(myStep + next);
524  myStep = myPlan->begin() + stepIndex;
525  } else {
526  if (myStep + 1 == myPlan->end()) {
527  // stay in the simulation until the start of simStep to allow appending new stages (at the correct position)
528  appendStage(new Stage_Waiting(getEdge(), 0, 0, getEdgePos(), "last stage removed", false));
529  }
530  (*myStep)->abort(this);
531  proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep());
532  }
533 }
534 
535 
536 void
538  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
539  (*i)->setSpeed(speed);
540  }
541 }
542 
543 
544 void
546  if (myVType->isVehicleSpecific()) {
548  }
549  myVType = type;
550 }
551 
552 
555  if (myVType->isVehicleSpecific()) {
556  return *myVType;
557  }
558  MSVehicleType* type = myVType->buildSingularType(myVType->getID() + "@" + getID());
559  replaceVehicleType(type);
560  return *type;
561 }
562 
563 
566  PositionVector centerLine;
567  const Position p = getPosition();
568  const double angle = getAngle();
569  const double length = getVehicleType().getLength();
570  const Position back = p + Position(-cos(angle) * length, -sin(angle) * length);
571  centerLine.push_back(p);
572  centerLine.push_back(back);
573  centerLine.move2side(0.5 * getVehicleType().getWidth());
574  PositionVector result = centerLine;
575  centerLine.move2side(-getVehicleType().getWidth());
576  result.append(centerLine.reverse(), POSITION_EPS);
577  //std::cout << " transp=" << getID() << " p=" << p << " angle=" << GeomHelper::naviDegree(angle) << " back=" << back << " result=" << result << "\n";
578  return result;
579 }
580 
581 
582 std::string
583 MSTransportable::getStageSummary(int stageIndex) const {
584  assert(stageIndex < (int)myPlan->size());
585  assert(stageIndex >= 0);
586  return (*myPlan)[stageIndex]->getStageSummary();
587 }
588 
589 bool
591  return myStep == myPlan->end();
592 }
593 
594 
595 void
597  // check whether the transportable was riding to the orignal stop
598  // @note: parkingArea can currently not be set as myDestinationStop so we
599  // check for stops on the edge instead
600  assert(getCurrentStageType() == DRIVING);
601  if (getDestination() == &orig->getLane().getEdge()) {
602  Stage_Driving* stage = dynamic_cast<Stage_Driving*>(*myStep);
603  assert(stage != 0);
604  assert(stage->getVehicle() != 0);
605  // adapt plan
606  stage->setDestination(&replacement->getLane().getEdge(), replacement);
607  if (myStep + 1 == myPlan->end()) {
608  return;
609  }
610  // if the next step is a walk, adapt the route
611  Stage* nextStage = *(myStep + 1);
612  if (nextStage->getStageType() == MOVING_WITHOUT_VEHICLE) {
613  MSPerson* p = dynamic_cast<MSPerson*>(this);
614  if (p != 0) {
615  const MSEdge* to = nextStage->getDestination();
616  double departPos = stage->getArrivalPos();
617  double arrivalPos = nextStage->getArrivalPos();
618  double speed = p->getVehicleType().getMaxSpeed();
619  ConstMSEdgeVector newEdges;
620  MSNet::getInstance()->getPedestrianRouter().compute(stage->getDestination(), to, departPos, arrivalPos, speed, 0, 0, newEdges);
621  if (newEdges.empty()) {
622  WRITE_WARNING("Could not reroute person '" + getID()
623  + "' when rerouting vehicle '" + stage->getVehicle()->getID()
624  + "' to new parkingArea '" + replacement->getID() + "'.");
625  } else {
626  //std::cout << SIMTIME << " plan before rerouting " << getID() << ":\n";
627  //for (int stage = 0; stage < p->getNumStages(); stage++) {
628  // std::cout << stage << ": " << p->getStageSummary(stage) << "\n";;
629  //}
630  p->reroute(newEdges, departPos, 1, 2);
631  //std::cout << SIMTIME << " plan after rerouting " << getID() << ":\n";
632  //for (int stage = 0; stage < p->getNumStages(); stage++) {
633  // std::cout << stage << ": " << p->getStageSummary(stage) << "\n";;
634  //}
635  }
636  }
637  }
638  };
639  return;
640 }
641 /****************************************************************************/
void setArrived(SUMOTime now)
marks arrival time and records driven distance
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
virtual void setArrived(SUMOTime now)
logs end of the step
void abort(MSTransportable *)
abort this stage (TraCI)
Stage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, StageType type)
constructor
std::string getStageSummary() const
return string summary of the current stage
Stage_Waiting(const MSEdge *destination, SUMOTime duration, SUMOTime until, double pos, const std::string &actType, const bool initial)
constructor
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:617
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
long long int SUMOTime
Definition: SUMOTime.h:36
double getBeginLanePosition() const
Returns the begin position of this stop.
std::string getWaitingDescription() const
Return where the person waits and for what.
std::string myActType
The type of activity.
double getAngle(SUMOTime now) const
returns the angle of the transportable
double getAngle() const
Returns the vehicle&#39;s direction in radians.
Definition: MSVehicle.h:681
virtual const MSEdge * getFromEdge() const
void append(const PositionVector &v, double sameThreshold=2.0)
const MSEdge * getEdge() const
Returns the current edge.
virtual const MSRoute & getRoute() const =0
Returns the current route.
A lane area vehicles can halt at.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
virtual double getEdgePos() const
Return the position on the edge.
bool hasArrived() const
return whether the person has reached the end of its plan
PositionVector getBoundingBox() const
return the bounding box of the person
virtual bool isWaitingFor(const std::string &line) const
Whether the transportable waits for a vehicle of the line specified.
const MSEdge * getDestination() const
returns the destination edge
void abort(MSTransportable *)
abort this stage (TraCI)
virtual const MSEdge * getEdge() const
Returns the current edge.
const MSEdge * getEdge() const
Returns the current edge.
virtual double getEdgePos(SUMOTime now) const
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
#define INVALID
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
Definition: MSRoute.cpp:274
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
ConstMSEdgeVector getEdges() const
the edges of the current stage
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:160
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:449
const std::set< std::string > myLines
the lines to choose from
double getSpeed() const
the speed of the transportable
PositionVector reverse() const
reverse position vector
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
virtual bool proceed(MSNet *net, SUMOTime time)=0
const std::string & getID() const
Returns the id.
Definition: Named.h:69
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
virtual double getSpeed() const
the current speed of the transportable
const MSEdge * myDestination
the next edge to reach by getting transported
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
MSTransportablePlan::iterator myStep
the iterator over the route
double getEdgePos(SUMOTime now) const
double getLength() const
return the length of the edge
Definition: MSEdge.h:563
const MSEdge * getFromEdge() const
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
T MAX3(T a, T b, T c)
Definition: StdDefs.h:90
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
The simulated network and simulation perfomer.
Definition: MSNet.h:85
The car-following model and parameter.
Definition: MSVehicleType.h:66
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:756
const SUMOVehicleParameter * myParameter
the plan of the transportable
void removeStage(int next)
removes the nth next stage
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
A road/street connecting two junctions.
Definition: MSEdge.h:75
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
double getEndLanePosition() const
Returns the end position of this stop.
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
MSVehicleType * myVType
This transportable&#39;s type. (mainly used for drawing related information Note sure if it is really nec...
SUMOTime myArrived
the time at which this stage ended
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
SUMOTime myDeparted
the time at which this stage started
void setDeparted(SUMOTime now)
logs depart time of the current stage
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:748
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
SUMOTime getDesiredDepart() const
Returns the desired departure time.
A list of positions.
Position getPosition(SUMOTime now) const
returns the position of the transportable
double compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, std::vector< const E *> &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual double getAngle() const
return the current angle of the transportable
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.h:590
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:309
void removeVType(const MSVehicleType *vehType)
virtual ~MSTransportable()
destructor
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
SUMOTime depart
The vehicle&#39;s departure time.
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:256
double getArrivalPos() const
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
T MIN2(T a, T b)
Definition: StdDefs.h:70
std::string myVehicleID
cached vehicle data for output after the vehicle has been removed
#define POSITION_EPS
Definition: config.h:172
const std::string & getID() const
returns the id of the transportable
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
virtual ~Stage_Driving()
destructor
SUMOTime myWaitingUntil
the time until the person is waiting
SUMOVehicle * myVehicle
The taken vehicle.
Position getPosition(SUMOTime now) const
returns the position of the transportable
std::string getStageSummary(int stageIndex) const
return textual summary for the given stage
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
MSPedestrianRouter & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:906
bool lefthand() const
return whether the network was built for lefthand traffic
Definition: MSNet.h:608
void move2side(double amount)
move position vector to side using certain ammount
std::string line
The vehicle&#39;s line (mainly for public transport)
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
virtual void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
virtual double getSpeed() const
the speed of the transportable
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
virtual double getDepartPos() const =0
Returns this vehicle&#39;s real departure position.
double getAngle(SUMOTime now) const
returns the angle of the transportable
void rerouteParkingArea(MSStoppingPlace *orig, MSStoppingPlace *replacement)
adapt plan when the vehicle reroutes and now stops at replacement instead of orig ...
StageType myType
The type of this stage.
Structure representing possible vehicle parameter.
MSTransportable(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:602
#define M_PI
Definition: odrSpiral.cpp:40
virtual Position getPosition() const
Return the Network coordinate of the transportable.
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex, nextIndex[
Definition: MSPerson.cpp:656
Stage_Driving(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
StageType getStageType() const
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:465
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
double getLength() const
Get vehicle&#39;s length [m].
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
const MSVehicleType & getVehicleType() const
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setDeparted(SUMOTime now)
logs end of the step
const MSEdge * getDestination() const
Returns the current destination.
MSTransportablePlan * myPlan
the plan of the transportable
virtual ~Stage_Waiting()
destructor
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:67
virtual ~Stage()
destructor
const MSLane & getLane() const
Returns the lane this stop is located at.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
bool isWaitingFor(const std::string &line) const
Whether the person waits for a vehicle of the line specified.
virtual double getSpeed() const =0
Returns the vehicle&#39;s current speed.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:230
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOTime myWaitingDuration
the time the person is waiting
int getNumStages() const
Return the total number stages in this persons plan.
std::string id
The vehicle&#39;s id.
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:274
double myArrivalPos
the position at which we want to arrive
StageType getCurrentStageType() const
the current stage type of the transportable