SUMO - Simulation of Urban MObility
Person.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2017-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // C++ TraCI client API implementation
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
32 #include <microsim/MSEdge.h>
33 #include <microsim/MSNet.h>
35 #include <utils/geom/GeomHelper.h>
37 #include "VehicleType.h"
38 #include "Person.h"
39 
40 #define FAR_AWAY 1000.0
41 
42 //#define DEBUG_MOVEXY
43 //#define DEBUG_MOVEXY_ANGLE
44 
45 // ===========================================================================
46 // member definitions
47 // ===========================================================================
48 namespace libsumo {
49 std::vector<std::string>
52  std::vector<std::string> ids;
53  for (MSTransportableControl::constVehIt i = c.loadedBegin(); i != c.loadedEnd(); ++i) {
54  if (i->second->getCurrentStageType() != MSTransportable::WAITING_FOR_DEPART) {
55  ids.push_back(i->first);
56  }
57  }
58  return std::move(ids);
59 }
60 
61 
62 int
65 }
66 
67 
69 Person::getPosition(const std::string& personID) {
70  MSTransportable* p = getPerson(personID);
71  TraCIPosition pos;
72  pos.x = p->getPosition().x();
73  pos.y = p->getPosition().y();
74  pos.z = p->getPosition().z();
75  return pos;
76 }
77 
78 
79 double
80 Person::getAngle(const std::string& personID) {
81  return GeomHelper::naviDegree(getPerson(personID)->getAngle());
82 }
83 
84 
85 double
86 Person::getSpeed(const std::string& personID) {
87  return getPerson(personID)->getSpeed();
88 }
89 
90 
91 std::string
92 Person::getRoadID(const std::string& personID) {
93  return getPerson(personID)->getEdge()->getID();
94 }
95 
96 
97 double
98 Person::getLanePosition(const std::string& personID) {
99  return getPerson(personID)->getEdgePos();
100 }
101 
102 
104 Person::getColor(const std::string& personID) {
105  const RGBColor& col = getPerson(personID)->getParameter().color;
106  TraCIColor tcol;
107  tcol.r = col.red();
108  tcol.g = col.green();
109  tcol.b = col.blue();
110  tcol.a = col.alpha();
111  return tcol;
112 }
113 
114 
115 std::string
116 Person::getTypeID(const std::string& personID) {
117  return getPerson(personID)->getVehicleType().getID();
118 }
119 
120 
121 double
122 Person::getWaitingTime(const std::string& personID) {
123  return getPerson(personID)->getWaitingSeconds();
124 }
125 
126 
127 std::string
128 Person::getNextEdge(const std::string& personID) {
129  return getPerson(personID)->getNextEdge();
130 }
131 
132 
133 std::vector<std::string>
134 Person::getEdges(const std::string& personID, int nextStageIndex) {
135  MSTransportable* p = getPerson(personID);
136  if (nextStageIndex >= p->getNumRemainingStages()) {
137  throw TraCIException("The stage index must be lower than the number of remaining stages.");
138  }
139  if (nextStageIndex < (p->getNumRemainingStages() - p->getNumStages())) {
140  throw TraCIException("The negative stage index must refer to a valid previous stage.");
141  }
142  std::vector<std::string> edgeIDs;
143  for (auto& e : p->getEdges(nextStageIndex)) {
144  edgeIDs.push_back(e->getID());
145  }
146  return edgeIDs;
147 }
148 
149 
150 int
151 Person::getStage(const std::string& personID, int nextStageIndex) {
152  MSTransportable* p = getPerson(personID);
153  if (nextStageIndex >= p->getNumRemainingStages()) {
154  throw TraCIException("The stage index must be lower than the number of remaining stages.");
155  }
156  if (nextStageIndex < (p->getNumRemainingStages() - p->getNumStages())) {
157  throw TraCIException("The negative stage index must refer to a valid previous stage.");
158  }
159  return p->getStageType(nextStageIndex);
160 }
161 
162 
163 int
164 Person::getRemainingStages(const std::string& personID) {
165  return getPerson(personID)->getNumRemainingStages();
166 }
167 
168 
169 std::string
170 Person::getVehicle(const std::string& personID) {
171  const SUMOVehicle* veh = getPerson(personID)->getVehicle();
172  if (veh == nullptr) {
173  return "";
174  } else {
175  return veh->getID();
176  }
177 }
178 
179 
180 std::string
181 Person::getParameter(const std::string& personID, const std::string& param) {
182  return getPerson(personID)->getParameter().getParameter(param, "");
183 }
184 
185 
186 
187 
188 void
189 Person::setSpeed(const std::string& personID, double speed) {
190  getPerson(personID)->setSpeed(speed);
191 }
192 
193 
194 void
195 Person::setType(const std::string& personID, const std::string& typeID) {
196  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
197  if (vehicleType == 0) {
198  throw TraCIException("The vehicle type '" + typeID + "' is not known.");
199  }
200  getPerson(personID)->replaceVehicleType(vehicleType);
201 }
202 
203 
204 void
205 Person::add(const std::string& personID, const std::string& edgeID, double pos, double departInSecs, const std::string typeID) {
206  MSTransportable* p;
207  try {
208  p = getPerson(personID);
209  } catch (TraCIException&) {
210  p = nullptr;
211  }
212 
213  if (p != nullptr) {
214  throw TraCIException("The person " + personID + " to add already exists.");
215  }
216 
217  SUMOTime depart = TIME2STEPS(departInSecs);
218  SUMOVehicleParameter vehicleParams;
219  vehicleParams.id = personID;
220 
221  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
222  if (!vehicleType) {
223  throw TraCIException("Invalid type '" + typeID + "' for person '" + personID + "'");
224  }
225 
226  const MSEdge* edge = MSEdge::dictionary(edgeID);
227  if (!edge) {
228  throw TraCIException("Invalid edge '" + edgeID + "' for person: '" + personID + "'");
229  }
230 
231  if (depart < 0) {
232  const int proc = (int) - depart;
233  if (proc >= static_cast<int>(DEPART_DEF_MAX)) {
234  throw TraCIException("Invalid departure time.");
235  }
236  vehicleParams.departProcedure = (DepartDefinition)proc;
237  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
238  } else if (depart < MSNet::getInstance()->getCurrentTimeStep()) {
239  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
240  WRITE_WARNING("Departure time " + toString(departInSecs) + " for person '" + personID
241  + "' is in the past; using current time " + time2string(vehicleParams.depart) + " instead.");
242  } else {
243  vehicleParams.depart = depart;
244  }
245 
246  vehicleParams.departPosProcedure = DEPART_POS_GIVEN;
247  if (fabs(pos) > edge->getLength()) {
248  throw TraCIException("Invalid departure position.");
249  }
250  if (pos < 0) {
251  pos += edge->getLength();
252  }
253  vehicleParams.departPos = pos;
254 
255  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
257  plan->push_back(new MSTransportable::Stage_Waiting(*edge, 0, depart, pos, "awaiting departure", true));
258 
259  try {
260  MSTransportable* person = MSNet::getInstance()->getPersonControl().buildPerson(params, vehicleType, plan, 0);
262  } catch (ProcessError& e) {
263  delete params;
264  delete plan;
265  throw TraCIException(e.what());
266  }
267 }
268 
269 
270 void
271 Person::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
272  MSTransportable* p = getPerson(personID);
273  const MSEdge* edge = MSEdge::dictionary(toEdge);
274  if (!edge) {
275  throw TraCIException("Invalid edge '" + toEdge + "' for person: '" + personID + "'");
276  }
277  if (lines.size() == 0) {
278  return throw TraCIException("Empty lines parameter for person: '" + personID + "'");
279  }
280  MSStoppingPlace* bs = 0;
281  if (stopID != "") {
283  if (bs == 0) {
284  throw TraCIException("Invalid stopping place id '" + stopID + "' for person: '" + personID + "'");
285  }
286  }
287  p->appendStage(new MSPerson::MSPersonStage_Driving(*edge, bs, -NUMERICAL_EPS, StringTokenizer(lines).getVector()));
288 }
289 
290 
291 void
292 Person::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
293  MSTransportable* p = getPerson(personID);
294  if (duration < 0) {
295  throw TraCIException("Duration for person: '" + personID + "' must not be negative");
296  }
297  MSStoppingPlace* bs = 0;
298  if (stopID != "") {
300  if (bs == 0) {
301  throw TraCIException("Invalid stopping place id '" + stopID + "' for person: '" + personID + "'");
302  }
303  }
304  p->appendStage(new MSTransportable::Stage_Waiting(*p->getArrivalEdge(), TIME2STEPS(duration), 0, p->getArrivalPos(), description, false));
305 }
306 
307 
308 void
309 Person::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edgeIDs, double arrivalPos, double duration, double speed, const std::string& stopID) {
310  MSTransportable* p = getPerson(personID);
311  ConstMSEdgeVector edges;
312  try {
313  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
314  } catch (ProcessError& e) {
315  throw TraCIException(e.what());
316  }
317  if (edges.empty()) {
318  throw TraCIException("Empty edge list for walking stage of person '" + personID + "'.");
319  }
320  if (fabs(arrivalPos) > edges.back()->getLength()) {
321  throw TraCIException("Invalid arrivalPos for walking stage of person '" + personID + "'.");
322  }
323  if (arrivalPos < 0) {
324  arrivalPos += edges.back()->getLength();
325  }
326  if (speed < 0) {
327  speed = p->getVehicleType().getMaxSpeed();
328  }
329  MSStoppingPlace* bs = 0;
330  if (stopID != "") {
332  if (bs == 0) {
333  throw TraCIException("Invalid stopping place id '" + stopID + "' for person: '" + personID + "'");
334  }
335  }
336  p->appendStage(new MSPerson::MSPersonStage_Walking(p->getID(), edges, bs, TIME2STEPS(duration), speed, p->getArrivalPos(), arrivalPos, 0));
337 }
338 
339 
340 void
341 Person::removeStage(const std::string& personID, int nextStageIndex) {
342  MSTransportable* p = getPerson(personID);
343  if (nextStageIndex >= p->getNumRemainingStages()) {
344  throw TraCIException("The stage index must be lower than the number of remaining stages.");
345  }
346  if (nextStageIndex < 0) {
347  throw TraCIException("The stage index may not be negative.");
348  }
349  p->removeStage(nextStageIndex);
350 }
351 
352 
353 void
354 Person::rerouteTraveltime(const std::string& personID) {
355  MSPerson* p = getPerson(personID);
357  throw TraCIException("Person '" + personID + "' is not currenlty walking.");
358  }
359  const MSEdge* from = p->getEdge();
360  double departPos = p->getEdgePos();
361  const MSEdge* to = p->getArrivalEdge();
362  double arrivalPos = p->getArrivalPos();
363  double speed = p->getVehicleType().getMaxSpeed();
364  ConstMSEdgeVector newEdges;
365  MSNet::getInstance()->getPedestrianRouter().compute(from, to, departPos, arrivalPos, speed, 0, 0, newEdges);
366  if (newEdges.empty()) {
367  throw TraCIException("Could not find new route for person '" + personID + "'.");
368  }
369  ConstMSEdgeVector oldEdges = p->getEdges(0);
370  assert(!oldEdges.empty());
371  if (oldEdges.front()->getFunction() != EDGEFUNC_NORMAL) {
372  oldEdges.erase(oldEdges.begin());
373  }
374  if (newEdges == oldEdges) {
375  return;
376  }
377  if (newEdges.front() != from) {
378  // @note: maybe this should be done automatically by the router
379  newEdges.insert(newEdges.begin(), from);
380  }
381  p->reroute(newEdges);
382 }
383 
384 
385 void
386 Person::moveTo(const std::string& personID, const std::string& edgeID, double /* position */) {
387  MSPerson* p = getPerson(personID);
388  MSEdge* e = MSEdge::dictionary(edgeID);
389  if (e == 0) {
390  throw TraCIException("Unknown edge '" + edgeID + "'.");
391  }
392  /*
393  switch (p->getStageType(0)) {
394  case MSTransportable::MOVING_WITHOUT_VEHICLE: {
395  MSPerson::MSPersonStage_Walking* s = dynamic_cast<MSPerson::MSPersonStage_Walking*>(p->getCurrentStage());
396  assert(s != 0);
397  const std::string error = s->moveTo(p, Simulation::getCurrentTime());
398  if (error != "") {
399  throw TraCIException("Command moveTo failed for person '" + personID + "' (" + error + ").");
400  }
401  break;
402  }
403  default:
404  */
405  throw TraCIException("Command moveTo is not supported for person '" + personID + "' while " + p->getCurrentStageDescription() + ".");
406  //}
407 }
408 
409 
410 void
411 Person::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRouteFlag) {
412  MSPerson* p = getPerson(personID);
413  bool keepRoute = (keepRouteFlag == 1);
414  bool mayLeaveNetwork = (keepRouteFlag == 2);
415  Position pos(x, y);
416 #ifdef DEBUG_MOVEXY
417  const double origAngle = angle;
418 #endif
419  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
420  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
421  if (angle != INVALID_DOUBLE_VALUE) {
422  while (angle >= 360.) {
423  angle -= 360.;
424  }
425  while (angle < 0.) {
426  angle += 360.;
427  }
428  }
429  Position currentPos = p->getPosition();
430 #ifdef DEBUG_MOVEXY
431  std::cout << std::endl << "begin person " << p->getID() << " lanePos:" << p->getEdgePos() << " edge:" << Named::getIDSecure(p->getEdge()) << "\n";
432  std::cout << " want pos:" << pos << " edgeID:" << edgeID << " origAngle:" << origAngle << " angle:" << angle << " keepRoute:" << keepRoute << std::endl;
433 #endif
434 
435  ConstMSEdgeVector edges;
436  MSLane* lane = 0;
437  double lanePos;
438  double lanePosLat = 0;
439  double bestDistance = std::numeric_limits<double>::max();
440  int routeOffset = 0;
441  bool found = false;
442  double maxRouteDistance = 100;
443 
445  ev.push_back(p->getEdge());
446  int routeIndex = 0;
447  MSLane* currentLane = const_cast<MSLane*>(getSidewalk<MSEdge, MSLane>(p->getEdge()));
448  switch (p->getStageType(0)) {
451  assert(s != 0);
452  ev = s->getEdges();
453  routeIndex = (int)(s->getRouteStep() - s->getRoute().begin());
454  }
455  break;
456  default:
457  break;
458  }
459  if (keepRoute) {
460  // case a): vehicle is on its earlier route
461  // we additionally assume it is moving forward (SUMO-limit);
462  // note that the route ("edges") is not changed in this case
463  found = Helper::moveToXYMap_matchingRoutePosition(pos, edgeID,
464  ev, routeIndex,
465  bestDistance, &lane, lanePos, routeOffset);
466  // @note silenty ignoring mapping failure
467  } else {
468  double speed = pos.distanceTo2D(p->getPosition()); // !!!veh->getSpeed();
469  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, edgeID, angle,
470  speed, ev, routeIndex, currentLane, p->getEdgePos(), true,
471  bestDistance, &lane, lanePos, routeOffset, edges);
472  }
473  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
474  // compute lateral offset
475  if (found) {
476  const double perpDist = lane->getShape().distance2D(pos, false);
477  if (perpDist != GeomHelper::INVALID_OFFSET) {
478  lanePosLat = perpDist;
479  if (!mayLeaveNetwork) {
480  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + p->getVehicleType().getWidth()));
481  }
482  // figure out whether the offset is to the left or to the right
483  PositionVector tmp = lane->getShape();
484  try {
485  tmp.move2side(-lanePosLat); // moved to left
486  } catch (ProcessError&) {
487  WRITE_WARNING("Could not determine position on lane '" + lane->getID() + " at lateral position " + toString(-lanePosLat) + ".");
488  }
489  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
490  if (tmp.distance2D(pos) > perpDist) {
491  lanePosLat = -lanePosLat;
492  }
493  }
494  }
495  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
496  // mapped position may differ from pos
497  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
498  }
499  assert((found && lane != 0) || (!found && lane == 0));
500  if (angle == INVALID_DOUBLE_VALUE) {
501  if (lane != 0) {
502  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
503  } else {
504  // compute angle outside road network from old and new position
505  angle = GeomHelper::naviDegree(p->getPosition().angleTo2D(pos));
506  }
507  }
508  switch (p->getStageType(0)) {
510  Helper::setRemoteControlled(p, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
511  break;
512  }
513  default:
514  throw TraCIException("Command moveToXY is not supported for person '" + personID + "' while " + p->getCurrentStageDescription() + ".");
515  }
516  } else {
517  if (lane == 0) {
518  throw TraCIException("Could not map person '" + personID + "' no road found within " + toString(maxRouteDistance) + "m.");
519  } else {
520  throw TraCIException("Could not map person '" + personID + "' distance to road is " + toString(bestDistance) + ".");
521  }
522  }
523 }
524 
525 
528 void
529 Person::setParameter(const std::string& personID, const std::string& key, const std::string& value) {
530  MSTransportable* p = getPerson(personID);
531  ((SUMOVehicleParameter&)p->getParameter()).setParameter(key, value);
532 }
533 
534 void
535 Person::setLength(const std::string& personID, double length) {
537 }
538 
539 void
540 Person::setWidth(const std::string& personID, double width) {
542 }
543 
544 void
545 Person::setHeight(const std::string& personID, double height) {
547 }
548 
549 void
550 Person::setMinGap(const std::string& personID, double minGap) {
552 }
553 
554 void
555 Person::setColor(const std::string& personID, const TraCIColor& c) {
556  VehicleType::getVType(getSingularVType(personID))->setColor(RGBColor(c.r, c.g, c.b, c.a));
557 }
558 
559 
560 
561 /******** private functions *************/
562 
563 MSPerson*
564 Person::getPerson(const std::string& personID) {
566  MSPerson* p = dynamic_cast<MSPerson*>(c.get(personID));
567  if (p == 0) {
568  throw TraCIException("Person '" + personID + "' is not known");
569  }
570  return p;
571 }
572 
573 std::string
574 Person::getSingularVType(const std::string& personID) {
575  return getPerson(personID)->getSingularType().getID();
576 }
577 }
578 
579 
580 /****************************************************************************/
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
Definition: Person.cpp:386
unsigned char g
Definition: TraCIDefs.h:79
static std::string getNextEdge(const std::string &personID)
Definition: Person.cpp:128
void setMinGap(const double &minGap)
Set a new value for this type&#39;s minimum gap.
double getLength() const
return the length of the edge
Definition: MSEdge.h:569
static double gLateralResolution
Definition: MSGlobals.h:91
double z() const
Returns the z-position.
Definition: Position.h:72
RGBColor color
The vehicle&#39;s color, TraCI may change this.
virtual double getEdgePos() const
Return the position on the edge.
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:513
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:249
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition: Helper.cpp:283
A lane area vehicles can halt at.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
const SUMOVehicleParameter & getParameter() const
double x() const
Returns the x-position.
Definition: Position.h:62
The position is given.
static void setHeight(const std::string &personID, double height)
Definition: Person.cpp:545
static void setMinGap(const std::string &personID, double minGap)
Definition: Person.cpp:550
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
static void setType(const std::string &personID, const std::string &typeID)
Definition: Person.cpp:195
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:461
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:928
static int getIDCount()
Definition: Person.cpp:63
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
static void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle, const int keepRouteFlag)
Definition: Person.cpp:411
static std::string getSingularVType(const std::string &personID)
Definition: Person.cpp:574
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
static std::vector< std::string > getIDList()
Definition: Person.cpp:50
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:58
const std::string & getID() const
returns the id of the transportable
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:744
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
void setLength(const double &length)
Set a new value for this type&#39;s length.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
static std::string getTypeID(const std::string &personID)
Definition: Person.cpp:116
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
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...
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:253
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
Tag for the last element in the enum for safe int casting.
static double getLanePosition(const std::string &personID)
Definition: Person.cpp:98
void reroute(ConstMSEdgeVector &newEdges)
set new walk
Definition: MSPerson.cpp:494
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: Person.cpp:271
The car-following model and parameter.
Definition: MSVehicleType.h:72
virtual double getSpeed() const
the current speed of the transportable
static int getRemainingStages(const std::string &personID)
Definition: Person.cpp:164
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:133
static std::string getVehicle(const std::string &personID)
Definition: Person.cpp:170
int size() const
Returns the number of known transportables.
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:82
void removeStage(int next)
removes the nth next stage
static MSPerson * getPerson(const std::string &id)
Definition: Person.cpp:564
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:863
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
unsigned char b
Definition: TraCIDefs.h:79
const std::string & getID() const
Returns the id.
Definition: Named.h:65
A road/street connecting two junctions.
Definition: MSEdge.h:80
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:186
const MSVehicleType & getVehicleType() const
static MSVehicleType * getVType(std::string id)
static TraCIPosition getPosition(const std::string &personID)
Definition: Person.cpp:69
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
const MSEdge * getEdge() const
Returns the current edge.
static void add(const std::string &personID, const std::string &edgeID, double pos, double depart=DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Definition: Person.cpp:205
Representation of a vehicle.
Definition: SUMOVehicle.h:66
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:768
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:168
A list of positions.
StageType getCurrentStageType() const
the current stage type of the transportable
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:306
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:89
void setHeight(const double &height)
Set a new value for this type&#39;s height.
double y() const
Returns the y-position.
Definition: Position.h:67
unsigned char a
Definition: TraCIDefs.h:79
SUMOTime depart
The vehicle&#39;s departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
T MIN2(T a, T b)
Definition: StdDefs.h:67
unsigned char r
Definition: TraCIDefs.h:79
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
Definition: Person.cpp:529
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:58
static void setColor(const std::string &personID, const TraCIColor &c)
Definition: Person.cpp:555
static std::string getParameter(const std::string &routeID, const std::string &param)
Definition: Person.cpp:181
void move2side(double amount)
move position vector to side using certain ammount
static void setSpeed(const std::string &personID, double speed)
Definition: Person.cpp:189
Definition: Edge.cpp:31
#define INVALID_DOUBLE_VALUE
static TraCIColor getColor(const std::string &personID)
Definition: Person.cpp:104
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
static bool moveToXYMap(const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector &currentRoute, const int routePosition, MSLane *currentLane, double currentLanePos, bool onRoad, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
Definition: Helper.cpp:319
static std::string getRoadID(const std::string &personID)
Definition: Person.cpp:92
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double departPos
(optional) The position the vehicle shall depart from
static void removeStage(const std::string &personID, int nextStageIndex)
Definition: Person.cpp:341
Structure representing possible vehicle parameter.
static double getWaitingTime(const std::string &personID)
Definition: Person.cpp:122
StageType getStageType(int next) const
the stage type for the nth next stage
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occured.
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:437
void setWidth(const double &width)
Set a new value for this type&#39;s width.
const std::vector< const MSEdge * >::iterator getRouteStep() const
Definition: MSPerson.h:158
ConstMSEdgeVector getEdges(int next) const
Return the edges of the nth next stage.
const std::string & getID() const
Returns the name of the vehicle type.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
virtual Position getPosition() const
Return the Network coordinate of the transportable.
static int getStage(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:151
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: Person.cpp:292
double getArrivalPos() const
returns the final arrival pos
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:439
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:134
void setColor(const RGBColor &color)
Set a new value for this type&#39;s color.
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:75
int getNumStages() const
Return the total number stages in this persons plan.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
long long int SUMOTime
Definition: TraCIDefs.h:51
#define NUMERICAL_EPS
Definition: config.h:151
static void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edgeIDs, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
Definition: Person.cpp:309
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
static void setWidth(const std::string &personID, double width)
Definition: Person.cpp:540
static void setLength(const std::string &personID, double length)
Definition: Person.cpp:535
static double getSpeed(const std::string &personID)
Definition: Person.cpp:86
A 3D-position.
Definition: TraCIDefs.h:71
static void rerouteTraveltime(const std::string &personID)
Definition: Person.cpp:354
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:68
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
const MSEdge * getArrivalEdge() const
returns the final arrival edge
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition: MSEdge.cpp:801
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
DepartDefinition
Possible ways to depart.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
Definition: Helper.cpp:529
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
Definition: Position.h:259
static double getAngle(const std::string &personID)
Definition: Person.cpp:80
std::string id
The vehicle&#39;s id.