Eclipse 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-2019 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 /****************************************************************************/
16 // The common superclass for modelling transportable objects like persons and containers
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
26 #include <utils/geom/GeomHelper.h>
30 #include "MSEdge.h"
31 #include "MSLane.h"
32 #include "MSNet.h"
35 #include "MSVehicleControl.h"
36 #include "MSTransportableControl.h"
37 #include "MSTransportable.h"
38 
39 /* -------------------------------------------------------------------------
40 * static member definitions
41 * ----------------------------------------------------------------------- */
42 const double MSTransportable::ROADSIDE_OFFSET(3);
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 /* -------------------------------------------------------------------------
49  * MSTransportable::Stage - methods
50  * ----------------------------------------------------------------------- */
51 MSTransportable::Stage::Stage(const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, StageType type)
52  : myDestination(destination), myDestinationStop(toStop), myArrivalPos(arrivalPos), myDeparted(-1), myArrived(-1), myType(type) {}
53 
55 
56 const MSEdge*
58  return myDestination;
59 }
60 
61 
62 const MSEdge*
64  return myDestination;
65 }
66 
67 
68 const MSEdge*
70  return myDestination;
71 }
72 
73 
74 double
76  return myArrivalPos;
77 }
78 
79 
82  return 0;
83 }
84 
85 
86 double
88  return 0.;
89 }
90 
91 
94  ConstMSEdgeVector result;
95  result.push_back(getDestination());
96  return result;
97 }
98 
99 
100 void
102  if (myDeparted < 0) {
103  myDeparted = now;
104  }
105 }
106 
107 SUMOTime
109  return myDeparted;
110 }
111 
112 void
113 MSTransportable::Stage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now) {
114  myArrived = now;
115 }
116 
117 bool
119  return false;
120 }
121 
122 Position
123 MSTransportable::Stage::getEdgePosition(const MSEdge* e, double at, double offset) const {
124  return getLanePosition(e->getLanes()[0], at, offset);
125 }
126 
127 Position
128 MSTransportable::Stage::getLanePosition(const MSLane* lane, double at, double offset) const {
129  return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
130 }
131 
132 double
133 MSTransportable::Stage::getEdgeAngle(const MSEdge* e, double at) const {
134  return e->getLanes()[0]->getShape().rotationAtOffset(at);
135 }
136 
137 
138 void
139 MSTransportable::Stage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
140  myDestination = newDestination;
141  myDestinationStop = newDestStop;
142  if (newDestStop != nullptr) {
143  myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
144  }
145 }
146 
147 
148 
149 /* -------------------------------------------------------------------------
150 * MSTransportable::Stage_Trip - methods
151 * ----------------------------------------------------------------------- */
153  const MSEdge* destination, MSStoppingPlace* toStop,
154  const SUMOTime duration, const SVCPermissions modeSet,
155  const std::string& vTypes, const double speed, const double walkFactor,
156  const double departPosLat, const bool hasArrivalPos, const double arrivalPos):
157  MSTransportable::Stage(destination, toStop, arrivalPos, TRIP),
158  myOrigin(origin),
159  myOriginStop(fromStop),
160  myDuration(duration),
161  myModeSet(modeSet),
162  myVTypes(vTypes),
163  mySpeed(speed),
164  myWalkFactor(walkFactor),
165  myDepartPosLat(departPosLat),
166  myHaveArrivalPos(hasArrivalPos) {
167 }
168 
169 
171 
174  return new Stage_Trip(myOrigin, const_cast<MSStoppingPlace*>(myOriginStop),
175  myDestination, myDestinationStop, myDuration,
176  myModeSet, myVTypes, mySpeed, myWalkFactor, myDepartPosLat, myHaveArrivalPos, myArrivalPos);
177 }
178 
179 
180 Position
182  // may be called concurrently while the trip is still being routed
183  return getEdgePosition(myOrigin, myDepartPos, ROADSIDE_OFFSET * (MSNet::getInstance()->lefthand() ? -1 : 1));
184 }
185 
186 
187 double
189  // may be called concurrently while the trip is still being routed
190  return getEdgeAngle(myOrigin, myDepartPos) + M_PI / 2 * (MSNet::getInstance()->lefthand() ? -1 : 1);
191 }
192 
193 
194 const MSEdge*
196  return myOrigin;
197 }
198 
199 
200 double
202  return myDepartPos;
203 }
204 
205 
206 void
208  MSTransportable::Stage::setArrived(net, transportable, now);
209  MSVehicleControl& vehControl = net->getVehicleControl();
210  std::vector<SUMOVehicleParameter*> pars;
211  for (StringTokenizer st(myVTypes); st.hasNext();) {
212  pars.push_back(new SUMOVehicleParameter());
213  pars.back()->vtypeid = st.next();
214  pars.back()->parametersSet |= VEHPARS_VTYPE_SET;
215  pars.back()->departProcedure = DEPART_TRIGGERED;
216  pars.back()->id = transportable->getID() + "_" + toString(pars.size() - 1);
217  }
218  if (pars.empty()) {
219  if ((myModeSet & SVC_PASSENGER) != 0) {
220  pars.push_back(new SUMOVehicleParameter());
221  pars.back()->id = transportable->getID() + "_0";
222  pars.back()->departProcedure = DEPART_TRIGGERED;
223  } else if ((myModeSet & SVC_BICYCLE) != 0) {
224  pars.push_back(new SUMOVehicleParameter());
225  pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
226  pars.back()->id = transportable->getID() + "_b0";
227  pars.back()->departProcedure = DEPART_TRIGGERED;
228  } else {
229  // allow shortcut via busStop even when not intending to ride
230  pars.push_back(nullptr);
231  }
232  }
233  MSTransportable::Stage* previous;
235  if (transportable->getNumStages() == transportable->getNumRemainingStages()) { // this is a difficult way to check that we are the first stage
236  myDepartPos = transportable->getParameter().departPos;
237  if (transportable->getParameter().departPosProcedure == DEPART_POS_RANDOM) {
238  myDepartPos = RandHelper::rand(myOrigin->getLength());
239  }
240  previous = new MSTransportable::Stage_Waiting(myOrigin, nullptr, -1, transportable->getParameter().depart, myDepartPos, "start", true);
241  time = transportable->getParameter().depart;
242  } else {
243  previous = transportable->getNextStage(-1);
244  myDepartPos = previous->getArrivalPos();
245  }
246  // TODO This works currently only for a single vehicle type
247  for (SUMOVehicleParameter* vehPar : pars) {
248  SUMOVehicle* vehicle = nullptr;
249  if (vehPar != nullptr) {
250  if (myDepartPos != 0) {
251  vehPar->departPosProcedure = DEPART_POS_GIVEN;
252  vehPar->departPos = myDepartPos;
253  vehPar->parametersSet |= VEHPARS_DEPARTPOS_SET;
254  }
255  MSVehicleType* type = vehControl.getVType(vehPar->vtypeid);
256  if (type->getVehicleClass() != SVC_IGNORING && (myOrigin->getPermissions() & type->getVehicleClass()) == 0) {
257  WRITE_WARNING("Ignoring vehicle type '" + type->getID() + "' when routing person '" + transportable->getID() + "' because it is not allowed on the start edge.");
258  } else {
259  const MSRoute* const routeDummy = new MSRoute(vehPar->id, ConstMSEdgeVector({ myOrigin }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
260  vehicle = vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes);
261  }
262  }
263  bool carUsed = false;
264  std::vector<MSNet::MSIntermodalRouter::TripItem> result;
265  int stageIndex = 1;
266  if (net->getIntermodalRouter(0).compute(myOrigin, myDestination, previous->getArrivalPos(), myArrivalPos, myDestinationStop == nullptr ? "" : myDestinationStop->getID(),
267  transportable->getMaxSpeed() * myWalkFactor, vehicle, myModeSet, time, result)) {
268  for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = result.begin(); it != result.end(); ++it) {
269  if (!it->edges.empty()) {
271  double localArrivalPos = bs != nullptr ? bs->getAccessPos(it->edges.back()) : it->edges.back()->getLength() / 2.;
272  if (it + 1 == result.end() && myHaveArrivalPos) {
273  localArrivalPos = myArrivalPos;
274  }
275  if (it->line == "") {
276  double depPos = previous->getArrivalPos();
277  if (previous->getDestinationStop() != nullptr) {
278  depPos = previous->getDestinationStop()->getAccessPos(it->edges.front());
279  } else if (previous->getEdge() != it->edges.front()) {
280 // if (previous->getEdge()->getToJunction() == it->edges.front()->getToJunction()) {
281 // depPos = it->edges.front()->getLength();
282 // } else {
283  depPos = 0.;
284 // }
285  }
286  previous = new MSPerson::MSPersonStage_Walking(transportable->getID(), it->edges, bs, myDuration, mySpeed, depPos, localArrivalPos, myDepartPosLat);
287  transportable->appendStage(previous, stageIndex++);
288  } else if (vehicle != nullptr && it->line == vehicle->getID()) {
289  if (bs == nullptr && it + 1 != result.end()) {
290  // we have no defined endpoint and are in the middle of the trip, drive as far as possible
291  localArrivalPos = it->edges.back()->getLength();
292  }
293  previous = new MSPerson::MSPersonStage_Driving(it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }));
294  transportable->appendStage(previous, stageIndex++);
295  vehicle->replaceRouteEdges(it->edges, -1, 0, "person:" + transportable->getID(), true);
296  vehicle->setArrivalPos(localArrivalPos);
297  vehControl.addVehicle(vehPar->id, vehicle);
298  carUsed = true;
299  } else {
300  previous = new MSPerson::MSPersonStage_Driving(it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }), it->intended, TIME2STEPS(it->depart));
301  transportable->appendStage(previous, stageIndex++);
302  }
303  }
304  }
305  } else {
306  // append stage so the GUI won't crash due to inconsistent state
307  transportable->appendStage(new MSPerson::MSPersonStage_Walking(transportable->getID(), ConstMSEdgeVector({ myOrigin, myDestination }), myDestinationStop, myDuration, mySpeed, previous->getArrivalPos(), myArrivalPos, myDepartPosLat), stageIndex++);
309  const std::string error = "No connection found between edge '" + myOrigin->getID() + "' and edge '" + (myDestinationStop != nullptr ? myDestinationStop->getID() : myDestination->getID()) + "' for person '" + transportable->getID() + "'.";
310  transportable->myStep++;
311  throw ProcessError(error);
312  } else {
313  // pedestrian will teleport
314  }
315  }
316  if (vehicle != nullptr && !carUsed) {
317  vehControl.deleteVehicle(vehicle, true);
318  }
319  }
320 }
321 
322 
323 void
324 MSTransportable::Stage_Trip::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, Stage* /* previous */) {
325  // just skip the stage, every interesting happens in setArrived
326  transportable->proceed(net, now);
327 }
328 
329 
330 void
332 }
333 
334 
335 void
336 MSTransportable::Stage_Trip::routeOutput(OutputDevice&, const bool /* withRouteLength */) const {
337 }
338 
339 
340 void
342 }
343 
344 
345 void
347 }
348 
349 
350 std::string
352  return "trip from '" + myOrigin->getID() + "' to '" + getDestination()->getID() + "'";
353 }
354 
355 
356 
357 /* -------------------------------------------------------------------------
358 * MSTransportable::Stage_Waiting - methods
359 * ----------------------------------------------------------------------- */
361  SUMOTime duration, SUMOTime until, double pos, const std::string& actType,
362  const bool initial) :
363  MSTransportable::Stage(destination, toStop, SUMOVehicleParameter::interpretEdgePos(
364  pos, destination->getLength(), SUMO_ATTR_DEPARTPOS, "stopping at " + destination->getID()),
365  initial ? WAITING_FOR_DEPART : WAITING),
366  myWaitingDuration(duration),
367  myWaitingUntil(until),
368  myActType(actType) {
369 }
370 
371 
373 
376  return new Stage_Waiting(myDestination, myDestinationStop, myWaitingDuration, myWaitingUntil, myArrivalPos, myActType, myType == WAITING_FOR_DEPART);
377 }
378 
379 SUMOTime
381  return myWaitingUntil;
382 }
383 
384 
385 Position
387  return getEdgePosition(myDestination, myArrivalPos,
388  ROADSIDE_OFFSET * (MSNet::getInstance()->lefthand() ? -1 : 1));
389 }
390 
391 
392 double
394  return getEdgeAngle(myDestination, myArrivalPos) + M_PI / 2 * (MSNet::getInstance()->lefthand() ? -1 : 1);
395 }
396 
397 
398 void
400  myDeparted = now;
401  const SUMOTime until = MAX3(now, now + myWaitingDuration, myWaitingUntil);
402  if (myDestinationStop != nullptr) {
403  myDestinationStop->addTransportable(transportable);
404  }
405  if (dynamic_cast<MSPerson*>(transportable) != nullptr) {
406  previous->getEdge()->addPerson(transportable);
407  net->getPersonControl().setWaitEnd(until, transportable);
408  } else {
409  previous->getEdge()->addContainer(transportable);
410  net->getContainerControl().setWaitEnd(until, transportable);
411  }
412 }
413 
414 
415 void
417  if (myType != WAITING_FOR_DEPART) {
418  os.openTag("stop");
419  os.writeAttr("duration", time2string(myArrived - myDeparted));
420  os.writeAttr("arrival", time2string(myArrived));
421  os.writeAttr("arrivalPos", toString(myArrivalPos));
422  os.writeAttr("actType", toString(myActType));
423  os.closeTag();
424  }
425 }
426 
427 
428 void
429 MSTransportable::Stage_Waiting::routeOutput(OutputDevice& os, const bool /* withRouteLength */) const {
430  if (myType != WAITING_FOR_DEPART) {
431  // lane index is arbitrary
432  os.openTag("stop").writeAttr(SUMO_ATTR_LANE, getDestination()->getID() + "_0");
433  if (myWaitingDuration >= 0) {
434  os.writeAttr(SUMO_ATTR_DURATION, time2string(myWaitingDuration));
435  }
436  if (myWaitingUntil >= 0) {
437  os.writeAttr(SUMO_ATTR_UNTIL, time2string(myWaitingUntil));
438  }
439  os.closeTag();
440  }
441 }
442 
443 
444 void
446  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "actstart " + myActType)
447  .writeAttr("agent", p.getID()).writeAttr("link", getEdge()->getID()).closeTag();
448 }
449 
450 
451 void
453  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "actend " + myActType).writeAttr("agent", p.getID())
454  .writeAttr("link", getEdge()->getID()).closeTag();
455 }
456 
457 
458 SUMOTime
460  return now - myDeparted;
461 }
462 
463 
464 void
466  MSTransportableControl& tc = (dynamic_cast<MSPerson*>(t) != nullptr ?
469  tc.abortWaiting(t);
470 }
471 
472 
473 std::string
475  std::string timeInfo;
476  if (myWaitingUntil >= 0) {
477  timeInfo += " until " + time2string(myWaitingUntil);
478  }
479  if (myWaitingDuration >= 0) {
480  timeInfo += " duration " + time2string(myWaitingDuration);
481  }
482  return "stopping at edge '" + getDestination()->getID() + "' " + timeInfo + " (" + myActType + ")";
483 }
484 
485 
486 /* -------------------------------------------------------------------------
487 * MSTransportable::Stage_Driving - methods
488 * ----------------------------------------------------------------------- */
490  MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
491  const std::string& intendedVeh, SUMOTime intendedDepart) :
492  MSTransportable::Stage(destination, toStop, arrivalPos, DRIVING),
493  myLines(lines.begin(), lines.end()),
494  myVehicle(nullptr),
495  myVehicleID("NULL"),
496  myVehicleVClass(SVC_IGNORING),
497  myVehicleDistance(-1.),
498  myWaitingSince(-1),
499  myWaitingEdge(nullptr),
500  myStopWaitPos(Position::INVALID),
501  myIntendedVehicleID(intendedVeh),
502  myIntendedDepart(intendedDepart) {
503 }
504 
505 
507 
508 const MSEdge*
510  if (myVehicle != nullptr) {
511  if (myVehicle->getLane() != nullptr) {
512  return &myVehicle->getLane()->getEdge();
513  }
514  return myVehicle->getEdge();
515  }
516  return myWaitingEdge;
517 }
518 
519 
520 const MSEdge*
522  return myWaitingEdge;
523 }
524 
525 
526 double
528  if (isWaiting4Vehicle()) {
529  return myWaitingPos;
530  }
531  // vehicle may already have passed the lane (check whether this is correct)
532  return MIN2(myVehicle->getPositionOnLane(), getEdge()->getLength());
533 }
534 
535 
536 Position
538  if (isWaiting4Vehicle()) {
539  if (myStopWaitPos != Position::INVALID) {
540  return myStopWaitPos;
541  }
542  return getEdgePosition(myWaitingEdge, myWaitingPos,
543  ROADSIDE_OFFSET * (MSNet::getInstance()->lefthand() ? -1 : 1));
544  }
545  return myVehicle->getPosition();
546 }
547 
548 
549 double
551  if (!isWaiting4Vehicle()) {
552  MSVehicle* veh = dynamic_cast<MSVehicle*>(myVehicle);
553  if (veh != nullptr) {
554  return veh->getAngle();
555  } else {
556  return 0;
557  }
558  }
559  return getEdgeAngle(myWaitingEdge, myWaitingPos) + M_PI / 2. * (MSNet::getInstance()->lefthand() ? -1 : 1);
560 }
561 
562 
563 bool
565  return (myLines.count(vehicle->getID()) > 0
566  || myLines.count(vehicle->getParameter().line) > 0
567  || (myLines.count("ANY") > 0 && (
568  myDestinationStop == nullptr
569  ? vehicle->stopsAtEdge(myDestination)
570  : vehicle->stopsAt(myDestinationStop))));
571 }
572 
573 
574 bool
576  return myVehicle == nullptr;
577 }
578 
579 
580 SUMOTime
582  return isWaiting4Vehicle() ? now - myWaitingSince : 0;
583 }
584 
585 
586 double
588  return isWaiting4Vehicle() ? 0 : myVehicle->getSpeed();
589 }
590 
591 
594  ConstMSEdgeVector result;
595  result.push_back(getFromEdge());
596  result.push_back(getDestination());
597  return result;
598 }
599 
600 void
602  MSTransportable::Stage::setArrived(net, transportable, now);
603  if (myVehicle != nullptr) {
604  // distance was previously set to driven distance upon embarking
605  myVehicleDistance = myVehicle->getRoute().getDistanceBetween(
606  myVehicle->getDepartPos(), myVehicle->getPositionOnLane(),
607  myVehicle->getRoute().begin(), myVehicle->getCurrentRouteEdge()) - myVehicleDistance;
608  if (myVehicle->isStopped()) {
609  myArrivalPos = myVehicle->getPositionOnLane();
610  }
611  } else {
612  myVehicleDistance = -1.;
613  }
614 }
615 
616 void
618  myVehicle = v;
619  myVehicleID = v->getID();
620  myVehicleLine = v->getParameter().line;
621  myVehicleVClass = v->getVClass();
622  myVehicleDistance = myVehicle->getRoute().getDistanceBetween(
623  myVehicle->getDepartPos(), myVehicle->getPositionOnLane(),
624  myVehicle->getRoute().begin(), myVehicle->getCurrentRouteEdge());
625 }
626 
627 void
629  if (myVehicle != nullptr) {
630  // jumping out of a moving vehicle!
631  dynamic_cast<MSVehicle*>(myVehicle)->removeTransportable(t);
632  } else {
633  MSTransportableControl& tc = (dynamic_cast<MSPerson*>(t) != nullptr ?
637  }
638 }
639 
640 
641 std::string
643  return isWaiting4Vehicle() ? ("waiting for " + joinToString(myLines, ",")
644  + " at " + (myDestinationStop == nullptr
645  ? ("edge '" + myWaitingEdge->getID() + "'")
646  : ("busStop '" + myDestinationStop->getID() + "'"))
647  ) : "";
648 }
649 
650 
651 void
653  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "arrival").writeAttr("agent", p.getID()).writeAttr("link", getEdge()->getID()).closeTag();
654 }
655 
656 
657 void
659  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "arrival").writeAttr("agent", p.getID()).writeAttr("link", getEdge()->getID()).closeTag();
660 }
661 
662 
663 
664 /* -------------------------------------------------------------------------
665  * MSTransportable - methods
666  * ----------------------------------------------------------------------- */
668  : myParameter(pars), myVType(vtype), myPlan(plan) {
669  myStep = myPlan->begin();
670  // init devices
672 }
673 
674 
676  if (myStep != myPlan->end() && getCurrentStageType() == DRIVING) {
677  Stage_Driving* const stage = dynamic_cast<Stage_Driving*>(*myStep);
678  if (stage->getVehicle() != nullptr) {
679  stage->getVehicle()->removeTransportable(this);
680  }
681  }
682  if (myPlan != nullptr) {
683  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
684  delete *i;
685  }
686  delete myPlan;
687  myPlan = nullptr;
688  }
689  for (MSTransportableDevice* dev : myDevices) {
690  delete dev;
691  }
692  delete myParameter;
693  if (myVType->isVehicleSpecific()) {
695  }
696 }
697 
698 const std::string&
700  return myParameter->id;
701 }
702 
703 SUMOTime
705  return myParameter->depart;
706 }
707 
708 void
710  (*myStep)->setDeparted(now);
711 }
712 
713 double
715  return (*myStep)->getEdgePos(MSNet::getInstance()->getCurrentTimeStep());
716 }
717 
718 Position
720  return (*myStep)->getPosition(MSNet::getInstance()->getCurrentTimeStep());
721 }
722 
723 double
725  return (*myStep)->getAngle(MSNet::getInstance()->getCurrentTimeStep());
726 }
727 
728 double
730  return STEPS2TIME((*myStep)->getWaitingTime(MSNet::getInstance()->getCurrentTimeStep()));
731 }
732 
733 double
735  return (*myStep)->getSpeed();
736 }
737 
738 
739 int
741  return (int)(myPlan->end() - myStep);
742 }
743 
744 int
746  return (int)myPlan->size();
747 }
748 
749 void
751  // myStep is invalidated upon modifying myPlan
752  const int stepIndex = (int)(myStep - myPlan->begin());
753  if (next < 0) {
754  myPlan->push_back(stage);
755  } else {
756  if (stepIndex + next > (int)myPlan->size()) {
757  throw ProcessError("invalid index '" + toString(next) + "' for inserting new stage into plan of '" + getID() + "'");
758  }
759  myPlan->insert(myPlan->begin() + stepIndex + next, stage);
760  }
761  myStep = myPlan->begin() + stepIndex;
762 }
763 
764 
765 void
767  assert(myStep + next < myPlan->end());
768  assert(next >= 0);
769  if (next > 0) {
770  // myStep is invalidated upon modifying myPlan
771  int stepIndex = (int)(myStep - myPlan->begin());
772  delete *(myStep + next);
773  myPlan->erase(myStep + next);
774  myStep = myPlan->begin() + stepIndex;
775  } else {
776  if (myStep + 1 == myPlan->end()) {
777  // stay in the simulation until the start of simStep to allow appending new stages (at the correct position)
778  appendStage(new Stage_Waiting(getEdge(), nullptr, 0, 0, getEdgePos(), "last stage removed", false));
779  }
780  (*myStep)->abort(this);
781  proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep());
782  }
783 }
784 
785 
786 void
788  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
789  (*i)->setSpeed(speed);
790  }
791 }
792 
793 
794 void
796  if (myVType->isVehicleSpecific()) {
798  }
799  myVType = type;
800 }
801 
802 
805  if (myVType->isVehicleSpecific()) {
806  return *myVType;
807  }
808  MSVehicleType* type = myVType->buildSingularType(myVType->getID() + "@" + getID());
809  replaceVehicleType(type);
810  return *type;
811 }
812 
813 
816  PositionVector centerLine;
817  const Position p = getPosition();
818  const double angle = getAngle();
819  const double length = getVehicleType().getLength();
820  const Position back = p + Position(-cos(angle) * length, -sin(angle) * length);
821  centerLine.push_back(p);
822  centerLine.push_back(back);
823  centerLine.move2side(0.5 * getVehicleType().getWidth());
824  PositionVector result = centerLine;
825  centerLine.move2side(-getVehicleType().getWidth());
826  result.append(centerLine.reverse(), POSITION_EPS);
827  //std::cout << " transp=" << getID() << " p=" << p << " angle=" << GeomHelper::naviDegree(angle) << " back=" << back << " result=" << result << "\n";
828  return result;
829 }
830 
831 
832 std::string
833 MSTransportable::getStageSummary(int stageIndex) const {
834  assert(stageIndex < (int)myPlan->size());
835  assert(stageIndex >= 0);
836  return (*myPlan)[stageIndex]->getStageSummary();
837 }
838 
839 
840 bool
842  return myStep == myPlan->end();
843 }
844 
845 bool
847  return myPlan->size() > 0 && myPlan->front()->getDeparted() >= 0;
848 }
849 
850 
851 void
853  // check whether the transportable was riding to the orignal stop
854  // @note: parkingArea can currently not be set as myDestinationStop so we
855  // check for stops on the edge instead
856  assert(getCurrentStageType() == DRIVING);
857  if (dynamic_cast<MSPerson*>(this) == nullptr) {
858  WRITE_WARNING("parkingAreaReroute not support for containers");
859  return;
860  }
861  if (getDestination() == &orig->getLane().getEdge()) {
862  Stage_Driving* const stage = dynamic_cast<Stage_Driving*>(*myStep);
863  assert(stage != 0);
864  assert(stage->getVehicle() != 0);
865  // adapt plan
866  stage->setDestination(&replacement->getLane().getEdge(), replacement);
867  if (myStep + 1 == myPlan->end()) {
868  return;
869  }
870  // if the next step is a walk, adapt the route
871  Stage* nextStage = *(myStep + 1);
872  if (nextStage->getStageType() == TRIP) {
873  dynamic_cast<MSTransportable::Stage_Trip*>(nextStage)->setOrigin(stage->getDestination());
874  } else if (nextStage->getStageType() == MOVING_WITHOUT_VEHICLE) {
875  Stage_Trip* newStage = new Stage_Trip(stage->getDestination(), nullptr, nextStage->getDestination(),
876  nextStage->getDestinationStop(), -1, 0, "", -1, 1, 0, true, nextStage->getArrivalPos());
877  removeStage(1);
878  appendStage(newStage, 1);
879  }
880  // if the plan contains another ride with the same vehicle from the same
881  // parking area, adapt the preceeding walk to end at the replacement
882  // (ride origin is set implicitly from the walk destination)
883  for (auto it = myStep + 2; it != myPlan->end(); it++) {
884  const Stage* const futureStage = *it;
885  Stage* const prevStage = *(it - 1);
886  if (futureStage->getStageType() == DRIVING) {
887  const MSPerson::MSPersonStage_Driving* const ds = dynamic_cast<const MSPerson::MSPersonStage_Driving* const>(futureStage);
888  if (ds->getLines() == stage->getLines()
889  && prevStage->getDestination() == &orig->getLane().getEdge()) {
890  if (prevStage->getStageType() == TRIP) {
891  dynamic_cast<MSTransportable::Stage_Trip*>(prevStage)->setDestination(stage->getDestination(), replacement);
892  } else if (prevStage->getStageType() == MOVING_WITHOUT_VEHICLE) {
893  Stage_Trip* newStage = new Stage_Trip(prevStage->getFromEdge(), nullptr, stage->getDestination(),
894  replacement, -1, 0, "", -1, 1, 0, true, stage->getArrivalPos());
895  int prevStageRelIndex = (int)(it - 1 - myStep);
896  removeStage(prevStageRelIndex);
897  appendStage(newStage, prevStageRelIndex);
898  }
899  break;
900  }
901  }
902  }
903  }
904 }
905 
907 MSTransportable::getDevice(const std::type_info& type) const {
908  for (MSTransportableDevice* const dev : myDevices) {
909  if (typeid(*dev) == type) {
910  return dev;
911  }
912  }
913  return nullptr;
914 }
915 
916 double
918  const MSEdge* edge = getEdge();
919  const double ep = getEdgePos();
920  const double gp = edge->getLanes()[0]->interpolateLanePosToGeometryPos(ep);
921  return edge->getLanes()[0]->getShape().slopeDegreeAtOffset(gp);
922 }
923 
924 SUMOTime
926  return (*myStep)->getWaitingTime(MSNet::getInstance()->getCurrentTimeStep());
927 }
928 
929 double
932 }
933 
936  return getVehicleType().getVehicleClass();
937 }
938 
939 /****************************************************************************/
MSTransportable::Stage::setDeparted
void setDeparted(SUMOTime now)
logs end of the step
Definition: MSTransportable.cpp:101
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:65
MSTransportableControl::abortWaitingForVehicle
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI)
Definition: MSTransportableControl.cpp:278
MSStoppingPlace::getLane
const MSLane & getLane() const
Returns the lane this stop is located at.
Definition: MSStoppingPlace.cpp:57
MSTransportable::Stage::getFromEdge
virtual const MSEdge * getFromEdge() const
Definition: MSTransportable.cpp:69
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
MSTransportable::Stage_Driving::isWaitingFor
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the person waits for the given vehicle.
Definition: MSTransportable.cpp:564
MSVehicleType::buildSingularType
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
Definition: MSVehicleType.cpp:363
MSNet::getStoppingPlace
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:911
MSTransportable::Stage_Driving::getEdges
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSTransportable.cpp:593
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:93
MSStoppingPlace
A lane area vehicles can halt at.
Definition: MSStoppingPlace.h:59
MSTransportable::hasDeparted
bool hasDeparted() const
return whether the transportable has started it's plan
Definition: MSTransportable.cpp:846
MSDevice::buildTransportableDevices
static void buildTransportableDevices(MSTransportable &p, std::vector< MSTransportableDevice * > &into)
Build devices for the given person, if needed.
Definition: MSDevice.cpp:112
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
MSTransportable::getDestination
const MSEdge * getDestination() const
Returns the current destination.
Definition: MSTransportable.h:617
MSTransportable::Stage_Trip::getPosition
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSTransportable.cpp:181
MSTransportable::Stage_Trip::routeOutput
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSTransportable.cpp:336
MSTransportable::Stage_Trip::getEdge
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSTransportable.cpp:195
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
MSTransportable::Stage_Driving::isWaiting4Vehicle
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
Definition: MSTransportable.cpp:575
MSNet.h
MSTransportable::getStageSummary
std::string getStageSummary(int stageIndex) const
return textual summary for the given stage
Definition: MSTransportable.cpp:833
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
SUMOVehicle::replaceRouteEdges
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.
MSVehicleType::isVehicleSpecific
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
Definition: MSVehicleType.h:547
MSVehicleControl::getVType
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.
Definition: MSVehicleControl.cpp:353
MSTransportable::Stage::Stage
Stage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, StageType type)
constructor
Definition: MSTransportable.cpp:51
MSTransportable::Stage_Waiting::routeOutput
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSTransportable.cpp:429
MSVehicleControl::removeVType
void removeVType(const MSVehicleType *vehType)
Definition: MSVehicleControl.cpp:311
SUMOVehicle::getParameter
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSTransportable::appendStage
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
Definition: MSTransportable.cpp:750
MSStoppingPlace::getEndLanePosition
double getEndLanePosition() const
Returns the end position of this stop.
Definition: MSStoppingPlace.cpp:69
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSTransportable::Stage_Waiting::getWaitingTime
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSTransportable.cpp:459
SUMO_ATTR_UNTIL
@ SUMO_ATTR_UNTIL
Definition: SUMOXMLDefinitions.h:668
MSTransportable::Stage::getLanePosition
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition: MSTransportable.cpp:128
Position::INVALID
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:284
MSTransportable::Stage_Driving
Definition: MSTransportable.h:435
StringTokenizer::hasNext
bool hasNext()
returns the information whether further substrings exist
Definition: StringTokenizer.cpp:94
MSNet::getContainerControl
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:818
SUMOVehicleParameter::departPosProcedure
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Definition: SUMOVehicleParameter.h:497
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
MSTransportable::myParameter
const SUMOVehicleParameter * myParameter
the plan of the transportable
Definition: MSTransportable.h:797
MSTransportable::Stage_Trip::beginEventOutput
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSTransportable.cpp:341
MSTransportable::Stage::setDestination
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition: MSTransportable.cpp:139
MSTransportable::~MSTransportable
virtual ~MSTransportable()
destructor
Definition: MSTransportable.cpp:675
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
MSStoppingPlace::getBeginLanePosition
double getBeginLanePosition() const
Returns the begin position of this stop.
Definition: MSStoppingPlace.cpp:63
MSPerson
Definition: MSPerson.h:63
MSTransportable::Stage_Trip::proceed
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSTransportable.cpp:324
MSTransportable::Stage
Definition: MSTransportable.h:73
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
SUMOTrafficObject::getVClass
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
SVC_BICYCLE
@ SVC_BICYCLE
vehicle is a bicycle
Definition: SUMOVehicleClass.h:179
SUMOVehicle::stopsAt
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.
MSEdge::addPerson
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.h:616
MSTransportable::StageType
StageType
Definition: MSTransportable.h:60
MSTransportable::Stage::getEdges
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSTransportable.cpp:93
MSTransportable::Stage::setArrived
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
Definition: MSTransportable.cpp:113
MSTransportable::Stage::getEdgePos
virtual double getEdgePos(SUMOTime now) const
Definition: MSTransportable.cpp:75
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
MSTransportable::Stage_Driving::getEdge
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSTransportable.cpp:509
MSEdge.h
MAX3
T MAX3(T a, T b, T c)
Definition: StdDefs.h:93
SUMO_ATTR_LANE
@ SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:637
MSTransportable
Definition: MSTransportable.h:58
MSTransportable::proceed
virtual bool proceed(MSNet *net, SUMOTime time)=0
PositionVector
A list of positions.
Definition: PositionVector.h:45
MSTransportableControl::setWaitEnd
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
Definition: MSTransportableControl.cpp:106
MSRoute
Definition: MSRoute.h:66
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:482
MSTransportable::getCurrentStageType
StageType getCurrentStageType() const
the current stage type of the transportable
Definition: MSTransportable.h:657
MSTransportable::Stage::getDestination
const MSEdge * getDestination() const
returns the destination edge
Definition: MSTransportable.cpp:57
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
SUMOVehicleParameter.h
INVALID
#define INVALID
Definition: MSDevice_SSM.cpp:70
MSTransportable::Stage::getEdge
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition: MSTransportable.cpp:63
MSTransportable::getDevice
MSTransportableDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
Definition: MSTransportable.cpp:907
MSTransportable::getSpeedFactor
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSTransportable.h:652
MSTransportable::Stage_Trip::~Stage_Trip
virtual ~Stage_Trip()
destructor
Definition: MSTransportable.cpp:170
MSTransportableControl
Definition: MSTransportableControl.h:51
MSTransportable::Stage_Driving::abort
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSTransportable.cpp:628
MSTransportable::Stage::getWaitingTime
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSTransportable.cpp:81
MSTransportable::setDeparted
void setDeparted(SUMOTime now)
logs depart time of the current stage
Definition: MSTransportable.cpp:709
SUMOVehicleParameter::line
std::string line
The vehicle's line (mainly for public transport)
Definition: SUMOVehicleParameter.h:561
MSVehicleControl::buildVehicle
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.
Definition: MSVehicleControl.cpp:100
MSTransportable::Stage_Waiting::getUntil
SUMOTime getUntil() const
Definition: MSTransportable.cpp:380
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
SUMOVehicle::stopsAtEdge
virtual bool stopsAtEdge(const MSEdge *edge) const =0
Returns whether the vehicle stops at the given edge.
MSTransportable::Stage_Driving::getAngle
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSTransportable.cpp:550
MSTransportable::getEdge
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSTransportable.h:627
MSVehicleControl::addVehicle
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
Definition: MSVehicleControl.cpp:215
MSTransportable::Stage_Driving::getLines
const std::set< std::string > & getLines() const
Definition: MSTransportable.h:500
MSTransportable::Stage_Trip::getAngle
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSTransportable.cpp:188
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
MSTransportable::Stage_Trip::Stage_Trip
Stage_Trip(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 double departPosLat, const bool hasArrivalPos, const double arrivalPos)
constructor
Definition: MSTransportable.cpp:152
MSNet::getIntermodalRouter
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1006
MSTransportable::Stage_Driving::setVehicle
void setVehicle(SUMOVehicle *v)
Definition: MSTransportable.cpp:617
MSTransportable::MSTransportable
MSTransportable(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
Definition: MSTransportable.cpp:667
MSTransportable::WAITING
@ WAITING
Definition: MSTransportable.h:62
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
MSTransportableControl.h
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:58
MSTransportable::Stage_Driving::getSpeed
double getSpeed() const
the speed of the transportable
Definition: MSTransportable.cpp:587
PedestrianRouter.h
MSNet::lefthand
bool lefthand() const
return whether the network was built for lefthand traffic
Definition: MSNet.h:663
MSTransportable::Stage_Driving::getVehicle
SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
Definition: MSTransportable.h:472
MSTransportable::getNumStages
int getNumStages() const
Return the total number stages in this persons plan.
Definition: MSTransportable.cpp:745
MSTransportable::getWaitingSeconds
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
Definition: MSTransportable.cpp:729
MSTransportable::getMaxSpeed
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition: MSTransportable.cpp:930
SUMOVehicle::setArrivalPos
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
StringTokenizer
Definition: StringTokenizer.h:61
MSTransportable::Stage_Waiting::tripInfoOutput
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSTransportable.cpp:416
MSTransportableDevice.h
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
SVC_PASSENGER
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:159
PositionVector::positionAtOffset
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Definition: PositionVector.cpp:248
SUMOVehicleParameter::id
std::string id
The vehicle's id.
Definition: SUMOVehicleParameter.h:468
MSTransportable::Stage_Waiting::Stage_Waiting
Stage_Waiting(const MSEdge *destination, MSStoppingPlace *toStop, SUMOTime duration, SUMOTime until, double pos, const std::string &actType, const bool initial)
constructor
Definition: MSTransportable.cpp:360
MSTransportable::Stage_Trip::getEdgePos
double getEdgePos(SUMOTime now) const
Definition: MSTransportable.cpp:201
MSLane::interpolateLanePosToGeometryPos
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:498
MSTransportable::Stage_Driving::getFromEdge
const MSEdge * getFromEdge() const
Definition: MSTransportable.cpp:521
MSTransportable::Stage_Driving::~Stage_Driving
virtual ~Stage_Driving()
destructor
Definition: MSTransportable.cpp:506
MSTransportable::Stage_Waiting::getAngle
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSTransportable.cpp:393
MSVehicleControl::deleteVehicle
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
Definition: MSVehicleControl.cpp:250
MSTransportable::Stage_Waiting::beginEventOutput
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSTransportable.cpp:445
ProcessError
Definition: UtilExceptions.h:39
MSTransportable::Stage_Driving::Stage_Driving
Stage_Driving(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
Definition: MSTransportable.cpp:489
MSVehicle::getAngle
double getAngle() const
Returns the vehicle's direction in radians.
Definition: MSVehicle.h:680
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
MSTransportable::rerouteParkingArea
void rerouteParkingArea(MSStoppingPlace *orig, MSStoppingPlace *replacement)
adapt plan when the vehicle reroutes and now stops at replacement instead of orig
Definition: MSTransportable.cpp:852
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
MSTransportable::isWaiting4Vehicle
bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
Definition: MSTransportable.h:721
PositionVector::append
void append(const PositionVector &v, double sameThreshold=2.0)
Definition: PositionVector.cpp:696
MSTransportable::Stage_Driving::setArrived
void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
marks arrival time and records driven distance
Definition: MSTransportable.cpp:601
MSTransportable::Stage_Waiting::clone
Stage * clone() const
Definition: MSTransportable.cpp:375
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSTransportable::Stage_Trip::tripInfoOutput
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSTransportable.cpp:331
DEPART_TRIGGERED
@ DEPART_TRIGGERED
The departure is person triggered.
Definition: SUMOVehicleParameter.h:102
MSTransportable::getSlope
double getSlope() const
Returns the slope of the road at vehicle's position.
Definition: MSTransportable.cpp:917
DEPART_POS_RANDOM
@ DEPART_POS_RANDOM
The position is chosen randomly.
Definition: SUMOVehicleParameter.h:146
MSGlobals::gCheckRoutes
static bool gCheckRoutes
Definition: MSGlobals.h:78
SUMOVehicle::removeTransportable
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
MSTransportable::Stage::getDeparted
SUMOTime getDeparted() const
get departure time of stage
Definition: MSTransportable.cpp:108
MSTransportable::DRIVING
@ DRIVING
Definition: MSTransportable.h:64
MSTransportable::Stage::getSpeed
virtual double getSpeed() const
the speed of the transportable
Definition: MSTransportable.cpp:87
MSTransportable::Stage::getStageType
StageType getStageType() const
Definition: MSTransportable.h:110
MSTransportable::Stage_Trip::setArrived
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
Definition: MSTransportable.cpp:207
MSTransportableDevice
Abstract in-person device.
Definition: MSTransportableDevice.h:52
MSTransportable::Stage_Driving::getWaitingTime
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
Definition: MSTransportable.cpp:581
MSTransportable::Stage::getArrivalPos
double getArrivalPos() const
Definition: MSTransportable.h:94
MSTransportable::Stage_Driving::getEdgePos
double getEdgePos(SUMOTime now) const
Definition: MSTransportable.cpp:527
MSTransportable::getEdgePos
virtual double getEdgePos() const
Return the position on the edge.
Definition: MSTransportable.cpp:714
MSTransportable::Stage_Waiting
Definition: MSTransportable.h:349
MSTransportable::Stage_Trip::getStageSummary
std::string getStageSummary() const
return string summary of the current stage
Definition: MSTransportable.cpp:351
MSPerson.h
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
MSTransportable::Stage::isWaitingFor
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition: MSTransportable.cpp:118
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
VEHPARS_VTYPE_SET
const int VEHPARS_VTYPE_SET
Definition: SUMOVehicleParameter.h:46
SUMO_TAG_BUS_STOP
@ SUMO_TAG_BUS_STOP
A bus stop.
Definition: SUMOXMLDefinitions.h:97
MSLane::getShape
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:477
MSTransportable::getBoundingBox
PositionVector getBoundingBox() const
return the bounding box of the person
Definition: MSTransportable.cpp:815
MSTransportable::MSTransportablePlan
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
Definition: MSTransportable.h:587
SUMO_ATTR_DURATION
@ SUMO_ATTR_DURATION
Definition: SUMOXMLDefinitions.h:667
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSTransportable::getNumRemainingStages
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
Definition: MSTransportable.cpp:740
MSNet::getPersonControl
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:810
MSTransportable::Stage_Waiting::endEventOutput
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSTransportable.cpp:452
MSTransportable::Stage::getEdgePosition
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition: MSTransportable.cpp:123
MSPerson::MSPersonStage_Driving
Definition: MSPerson.h:245
M_PI
#define M_PI
Definition: odrSpiral.cpp:40
MSTransportable::getSpeed
virtual double getSpeed() const
the current speed of the transportable
Definition: MSTransportable.cpp:734
MSTransportable::Stage_Waiting::getPosition
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSTransportable.cpp:386
PositionVector::reverse
PositionVector reverse() const
reverse position vector
Definition: PositionVector.cpp:1086
MSTransportable::getVehicleType
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
Definition: MSTransportable.h:606
MSVehicleType::getLength
double getLength() const
Get vehicle's length [m].
Definition: MSVehicleType.h:109
VEHPARS_DEPARTPOS_SET
const int VEHPARS_DEPARTPOS_SET
Definition: SUMOVehicleParameter.h:48
MSTransportable::getNextStage
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
Definition: MSTransportable.h:682
MSTransportable::Stage_Driving::endEventOutput
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSTransportable.cpp:658
MSTransportable::hasArrived
bool hasArrived() const
return whether the person has reached the end of its plan
Definition: MSTransportable.cpp:841
MSTransportable.h
MSTransportable::getVClass
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
Definition: MSTransportable.cpp:935
MSEdge::addContainer
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:628
MSTransportable::Stage::getEdgeAngle
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition: MSTransportable.cpp:133
MSPerson::MSPersonStage_Walking
Definition: MSPerson.h:70
MSTransportable::getDesiredDepart
SUMOTime getDesiredDepart() const
Returns the desired departure time.
Definition: MSTransportable.cpp:704
MSTransportable::setSpeed
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSTransportable.cpp:787
MSTransportable::Stage_Trip
Definition: MSTransportable.h:232
MSTransportable::getID
const std::string & getID() const
returns the id of the transportable
Definition: MSTransportable.cpp:699
MSStoppingPlace::getAccessPos
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
Definition: MSStoppingPlace.cpp:230
MSTransportable::myDevices
std::vector< MSTransportableDevice * > myDevices
The devices this transportable has.
Definition: MSTransportable.h:813
joinToString
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:246
MSTransportable::getPosition
virtual Position getPosition() const
Return the Network coordinate of the transportable.
Definition: MSTransportable.cpp:719
MSTransportable::Stage_Waiting::~Stage_Waiting
virtual ~Stage_Waiting()
destructor
Definition: MSTransportable.cpp:372
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:167
MSTransportable::TRIP
@ TRIP
Definition: MSTransportable.h:66
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:161
MSTransportable::Stage_Waiting::proceed
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSTransportable.cpp:399
MSTransportable::Stage::~Stage
virtual ~Stage()
destructor
Definition: MSTransportable.cpp:54
MSTransportable::Stage_Waiting::abort
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSTransportable.cpp:465
config.h
MSTransportable::myStep
MSTransportablePlan::iterator myStep
the iterator over the route
Definition: MSTransportable.h:810
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:71
GeomHelper.h
MSTransportable::MOVING_WITHOUT_VEHICLE
@ MOVING_WITHOUT_VEHICLE
Definition: MSTransportable.h:63
StringTokenizer.h
MSTransportable::Stage::getDestinationStop
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSTransportable.h:85
MSTransportable::Stage_Driving::getWaitingDescription
std::string getWaitingDescription() const
Return where the person waits and for what.
Definition: MSTransportable.cpp:642
MSTransportable::removeStage
void removeStage(int next)
removes the nth next stage
Definition: MSTransportable.cpp:766
MSTransportable::myPlan
MSTransportablePlan * myPlan
the plan of the transportable
Definition: MSTransportable.h:807
MSTransportable::Stage_Trip::clone
Stage * clone() const
Definition: MSTransportable.cpp:173
MSTransportable::getWaitingTime
SUMOTime getWaitingTime() const
Definition: MSTransportable.cpp:925
SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_DEPARTPOS
Definition: SUMOXMLDefinitions.h:433
MSTransportable::Stage_Waiting::getStageSummary
std::string getStageSummary() const
return string summary of the current stage
Definition: MSTransportable.cpp:474
MSTransportableControl::abortWaiting
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
Definition: MSTransportableControl.cpp:291
DEPART_POS_GIVEN
@ DEPART_POS_GIVEN
The position is given.
Definition: SUMOVehicleParameter.h:144
MSTransportable::getFromEdge
const MSEdge * getFromEdge() const
Returns the departure edge.
Definition: MSTransportable.h:632
MSLane.h
MSVehicleType::getVehicleClass
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
Definition: MSVehicleType.h:184
MSTransportable::myVType
MSVehicleType * myVType
This transportable's type. (mainly used for drawing related information Note sure if it is really nec...
Definition: MSTransportable.h:801
IntermodalRouter::compute
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...
Definition: IntermodalRouter.h:108
SVC_IGNORING
@ SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:135
DEFAULT_BIKETYPE_ID
const std::string DEFAULT_BIKETYPE_ID
MSTransportable::WAITING_FOR_DEPART
@ WAITING_FOR_DEPART
Definition: MSTransportable.h:61
MSTransportable::Stage_Driving::getPosition
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSTransportable.cpp:537
MSTransportable::Stage_Trip::endEventOutput
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSTransportable.cpp:346
MSTransportable::getParameter
const SUMOVehicleParameter & getParameter() const
Definition: MSTransportable.h:602
MSVehicleControl.h
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSTransportable::getAngle
virtual double getAngle() const
return the current angle of the transportable
Definition: MSTransportable.cpp:724
POSITION_EPS
#define POSITION_EPS
Definition: config.h:172
MSTransportable::ROADSIDE_OFFSET
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition: MSTransportable.h:794
MSTransportable::replaceVehicleType
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
Definition: MSTransportable.cpp:795
MSNet::getVehicleControl
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:336
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:494
IntermodalRouter.h
PositionVector::move2side
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Definition: PositionVector.cpp:1103
MSTransportable::Stage_Driving::beginEventOutput
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSTransportable.cpp:652
MSTransportable::getSingularType
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
Definition: MSTransportable.cpp:804
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79