Eclipse 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-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 /****************************************************************************/
15 // C++ TraCI client API implementation
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
26 #include <microsim/MSEdge.h>
27 #include <microsim/MSNet.h>
29 #include <libsumo/TraCIConstants.h>
30 #include <utils/geom/GeomHelper.h>
32 #include <utils/common/SUMOTime.h>
36 #include "VehicleType.h"
37 #include "Person.h"
38 
39 #define FAR_AWAY 1000.0
40 
41 //#define DEBUG_MOVEXY
42 //#define DEBUG_MOVEXY_ANGLE
43 
44 namespace libsumo {
45 // ===========================================================================
46 // static member initializations
47 // ===========================================================================
50 
51 
52 // ===========================================================================
53 // static member definitions
54 // ===========================================================================
55 std::vector<std::string>
58  std::vector<std::string> ids;
59  for (MSTransportableControl::constVehIt i = c.loadedBegin(); i != c.loadedEnd(); ++i) {
60  if (i->second->getCurrentStageType() != MSTransportable::WAITING_FOR_DEPART) {
61  ids.push_back(i->first);
62  }
63  }
64  return ids;
65 }
66 
67 
68 int
71 }
72 
73 
75 Person::getPosition(const std::string& personID, const bool includeZ) {
76  return Helper::makeTraCIPosition(getPerson(personID)->getPosition(), includeZ);
77 }
78 
79 
81 Person::getPosition3D(const std::string& personID) {
82  return Helper::makeTraCIPosition(getPerson(personID)->getPosition(), true);
83 }
84 
85 
86 double
87 Person::getAngle(const std::string& personID) {
88  return GeomHelper::naviDegree(getPerson(personID)->getAngle());
89 }
90 
91 
92 double
93 Person::getSlope(const std::string& personID) {
94  MSPerson* person = getPerson(personID);
95  const double ep = person->getEdgePos();
96  const MSLane* lane = getSidewalk<MSEdge, MSLane>(person->getEdge());
97  if (lane == nullptr) {
98  lane = person->getEdge()->getLanes()[0];
99  }
100  const double gp = lane->interpolateLanePosToGeometryPos(ep);
101  return lane->getShape().slopeDegreeAtOffset(gp);
102 }
103 
104 
105 double
106 Person::getSpeed(const std::string& personID) {
107  return getPerson(personID)->getSpeed();
108 }
109 
110 
111 std::string
112 Person::getRoadID(const std::string& personID) {
113  return getPerson(personID)->getEdge()->getID();
114 }
115 
116 
117 double
118 Person::getLanePosition(const std::string& personID) {
119  return getPerson(personID)->getEdgePos();
120 }
121 
122 
124 Person::getColor(const std::string& personID) {
125  const RGBColor& col = getPerson(personID)->getParameter().color;
126  TraCIColor tcol;
127  tcol.r = col.red();
128  tcol.g = col.green();
129  tcol.b = col.blue();
130  tcol.a = col.alpha();
131  return tcol;
132 }
133 
134 
135 std::string
136 Person::getTypeID(const std::string& personID) {
137  return getPerson(personID)->getVehicleType().getID();
138 }
139 
140 
141 double
142 Person::getWaitingTime(const std::string& personID) {
143  return getPerson(personID)->getWaitingSeconds();
144 }
145 
146 
147 std::string
148 Person::getNextEdge(const std::string& personID) {
149  return getPerson(personID)->getNextEdge();
150 }
151 
152 
153 std::vector<std::string>
154 Person::getEdges(const std::string& personID, int nextStageIndex) {
155  MSTransportable* p = getPerson(personID);
156  if (nextStageIndex >= p->getNumRemainingStages()) {
157  throw TraCIException("The stage index must be lower than the number of remaining stages.");
158  }
159  if (nextStageIndex < (p->getNumRemainingStages() - p->getNumStages())) {
160  throw TraCIException("The negative stage index must refer to a valid previous stage.");
161  }
162  std::vector<std::string> edgeIDs;
163  for (auto& e : p->getEdges(nextStageIndex)) {
164  if (e != nullptr) {
165  edgeIDs.push_back(e->getID());
166  }
167  }
168  return edgeIDs;
169 }
170 
171 
173 Person::getStage(const std::string& personID, int nextStageIndex) {
174  MSTransportable* p = getPerson(personID);
175  TraCIStage result;
176  if (nextStageIndex >= p->getNumRemainingStages()) {
177  throw TraCIException("The stage index must be lower than the number of remaining stages.");
178  }
179  if (nextStageIndex < (p->getNumRemainingStages() - p->getNumStages())) {
180  throw TraCIException("The negative stage index must refer to a valid previous stage.");
181  }
182  //stageType, arrivalPos, edges, destStop, vType, and description can be retrieved directly from the base Stage class.
183  MSTransportable::Stage* stage = p->getNextStage(nextStageIndex);
184  result.type = stage->getStageType();
185  result.arrivalPos = stage->getArrivalPos();
186  for (auto e : stage->getEdges()) {
187  if (e != nullptr) {
188  result.edges.push_back(e->getID());
189  }
190  }
191  MSStoppingPlace* destinationStop = stage->getDestinationStop();
192  if (destinationStop != nullptr) {
193  result.destStop = destinationStop->getID();
194  }
195  SUMOVehicle* vehicle = stage->getVehicle();
196  if (vehicle != nullptr) {
197  result.vType = vehicle->getVehicleType().getID();
198  }
199  result.description = stage->getStageDescription();
200  result.length = stage->getDistance();
201  // negative values indicate that the information is not available
202  result.cost = -1;
203  result.travelTime = -1;
204  // Some stage type dependant attributes
205  switch (stage->getStageType()) {
206  case STAGE_DRIVING: {
207  auto* drivingStage = (MSTransportable::Stage_Driving*) stage;
208  result.intended = drivingStage->getIntendedVehicleID();
209  result.depart = STEPS2TIME(drivingStage->getIntendedDepart());
210  const std::set<std::string> lines = drivingStage->getLines();
211  for (auto line = lines.begin(); line != lines.end(); line++) {
212  if (line != lines.begin()) {
213  result.line += " ";
214  }
215  result.line += *line;
216  }
217  break;
218  }
219  case STAGE_WALKING: {
220  auto* walkingStage = (MSPerson::MSPersonStage_Walking*) stage;
221  result.departPos = walkingStage->getDepartPos();
222  break;
223  }
224  default:
225  break;
226  }
227  return result;
228 }
229 
230 
231 int
232 Person::getRemainingStages(const std::string& personID) {
233  return getPerson(personID)->getNumRemainingStages();
234 }
235 
236 
237 std::string
238 Person::getVehicle(const std::string& personID) {
239  const SUMOVehicle* veh = getPerson(personID)->getVehicle();
240  if (veh == nullptr) {
241  return "";
242  } else {
243  return veh->getID();
244  }
245 }
246 
247 
248 std::string
249 Person::getParameter(const std::string& personID, const std::string& param) {
250  return getPerson(personID)->getParameter().getParameter(param, "");
251 }
252 
253 
254 std::string
255 Person::getEmissionClass(const std::string& personID) {
256  return PollutantsInterface::getName(getPerson(personID)->getVehicleType().getEmissionClass());
257 }
258 
259 
260 std::string
261 Person::getShapeClass(const std::string& personID) {
262  return getVehicleShapeName(getPerson(personID)->getVehicleType().getGuiShape());
263 }
264 
265 
266 double
267 Person::getLength(const std::string& personID) {
268  return getPerson(personID)->getVehicleType().getLength();
269 }
270 
271 
272 double
273 Person::getSpeedFactor(const std::string& personID) {
274  return getPerson(personID)->getVehicleType().getSpeedFactor().getParameter()[0];
275 }
276 
277 
278 double
279 Person::getAccel(const std::string& personID) {
280  return getPerson(personID)->getVehicleType().getCarFollowModel().getMaxAccel();
281 }
282 
283 
284 double
285 Person::getDecel(const std::string& personID) {
286  return getPerson(personID)->getVehicleType().getCarFollowModel().getMaxDecel();
287 }
288 
289 
290 double Person::getEmergencyDecel(const std::string& personID) {
292 }
293 
294 
295 double Person::getApparentDecel(const std::string& personID) {
297 }
298 
299 
300 double Person::getActionStepLength(const std::string& personID) {
301  return getPerson(personID)->getVehicleType().getActionStepLengthSecs();
302 }
303 
304 
305 double
306 Person::getTau(const std::string& personID) {
308 }
309 
310 
311 double
312 Person::getImperfection(const std::string& personID) {
314 }
315 
316 
317 double
318 Person::getSpeedDeviation(const std::string& personID) {
319  return getPerson(personID)->getVehicleType().getSpeedFactor().getParameter()[1];
320 }
321 
322 
323 std::string
324 Person::getVehicleClass(const std::string& personID) {
325  return toString(getPerson(personID)->getVehicleType().getVehicleClass());
326 }
327 
328 
329 double
330 Person::getMinGap(const std::string& personID) {
331  return getPerson(personID)->getVehicleType().getMinGap();
332 }
333 
334 
335 double
336 Person::getMinGapLat(const std::string& personID) {
337  return getPerson(personID)->getVehicleType().getMinGapLat();
338 }
339 
340 
341 double
342 Person::getMaxSpeed(const std::string& personID) {
343  return getPerson(personID)->getVehicleType().getMaxSpeed();
344 }
345 
346 
347 double
348 Person::getMaxSpeedLat(const std::string& personID) {
349  return getPerson(personID)->getVehicleType().getMaxSpeedLat();
350 }
351 
352 
353 std::string
354 Person::getLateralAlignment(const std::string& personID) {
355  return toString(getPerson(personID)->getVehicleType().getPreferredLateralAlignment());
356 }
357 
358 
359 double
360 Person::getWidth(const std::string& personID) {
361  return getPerson(personID)->getVehicleType().getWidth();
362 }
363 
364 
365 double
366 Person::getHeight(const std::string& personID) {
367  return getPerson(personID)->getVehicleType().getHeight();
368 }
369 
370 
371 int
372 Person::getPersonCapacity(const std::string& personID) {
373  return getPerson(personID)->getVehicleType().getPersonCapacity();
374 }
375 
376 
377 void
378 Person::setSpeed(const std::string& personID, double speed) {
379  getPerson(personID)->setSpeed(speed);
380 }
381 
382 
383 void
384 Person::setType(const std::string& personID, const std::string& typeID) {
385  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
386  if (vehicleType == nullptr) {
387  throw TraCIException("The vehicle type '" + typeID + "' is not known.");
388  }
389  getPerson(personID)->replaceVehicleType(vehicleType);
390 }
391 
392 
393 void
394 Person::add(const std::string& personID, const std::string& edgeID, double pos, double departInSecs, const std::string typeID) {
395  MSTransportable* p;
396  try {
397  p = getPerson(personID);
398  } catch (TraCIException&) {
399  p = nullptr;
400  }
401 
402  if (p != nullptr) {
403  throw TraCIException("The person " + personID + " to add already exists.");
404  }
405 
406  SUMOTime depart = TIME2STEPS(departInSecs);
407  SUMOVehicleParameter vehicleParams;
408  vehicleParams.id = personID;
409 
410  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
411  if (!vehicleType) {
412  throw TraCIException("Invalid type '" + typeID + "' for person '" + personID + "'");
413  }
414 
415  const MSEdge* edge = MSEdge::dictionary(edgeID);
416  if (!edge) {
417  throw TraCIException("Invalid edge '" + edgeID + "' for person: '" + personID + "'");
418  }
419 
420  if (departInSecs < 0.) {
421  const int proc = (int) - departInSecs;
422  if (proc >= static_cast<int>(DEPART_DEF_MAX)) {
423  throw TraCIException("Invalid departure time." + toString(depart) + " " + toString(proc));
424  }
425  vehicleParams.departProcedure = (DepartDefinition)proc;
426  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
427  } else if (depart < MSNet::getInstance()->getCurrentTimeStep()) {
428  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
429  WRITE_WARNING("Departure time " + toString(departInSecs) + " for person '" + personID
430  + "' is in the past; using current time " + time2string(vehicleParams.depart) + " instead.");
431  } else {
432  vehicleParams.depart = depart;
433  }
434 
435  vehicleParams.departPosProcedure = DEPART_POS_GIVEN;
436  if (fabs(pos) > edge->getLength()) {
437  throw TraCIException("Invalid departure position.");
438  }
439  if (pos < 0) {
440  pos += edge->getLength();
441  }
442  vehicleParams.departPos = pos;
443 
444  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
446  plan->push_back(new MSTransportable::Stage_Waiting(edge, nullptr, 0, depart, pos, "awaiting departure", true));
447 
448  try {
449  MSTransportable* person = MSNet::getInstance()->getPersonControl().buildPerson(params, vehicleType, plan, nullptr);
451  } catch (ProcessError& e) {
452  delete params;
453  delete plan;
454  throw TraCIException(e.what());
455  }
456 }
457 
459 Person::convertTraCIStage(const TraCIStage& stage, const std::string personID) {
460  switch (stage.type) {
461  case MSTransportable::StageType::DRIVING: {
462  if (stage.edges.empty()) {
463  throw TraCIException("The stage should have at least one edge");
464  }
465  std::string edgeId = stage.edges.back();
466  MSEdge* edge = MSEdge::dictionary(edgeId);
467  if (!edge) {
468  throw TraCIException("Invalid edge '" + edgeId + "' for person: '" + personID + "'");
469  }
470  MSStoppingPlace* bs = nullptr;
471  if (!stage.destStop.empty()) {
473  if (bs == nullptr) {
474  throw TraCIException("Invalid stopping place id '" + stage.destStop + "' for person: '" + personID + "'");
475  }
476  }
477  if (stage.line.empty()) {
478  throw TraCIException("Empty lines parameter for person: '" + personID + "'");
479  }
481  }
482 
483  case MSTransportable::StageType::MOVING_WITHOUT_VEHICLE: {
484  MSTransportable* p = getPerson(personID);
485  ConstMSEdgeVector edges;
486  try {
487  MSEdge::parseEdgesList(stage.edges, edges, "<unknown>");
488  } catch (ProcessError& e) {
489  throw TraCIException(e.what());
490  }
491  if (edges.empty()) {
492  throw TraCIException("Empty edge list for walking stage of person '" + personID + "'.");
493  }
494  double arrivalPos = stage.arrivalPos;
495  if (fabs(arrivalPos) > edges.back()->getLength()) {
496  throw TraCIException("Invalid arrivalPos for walking stage of person '" + personID + "'.");
497  }
498  if (arrivalPos < 0) {
499  arrivalPos += edges.back()->getLength();
500  }
501  double speed = p->getVehicleType().getMaxSpeed();
502  MSStoppingPlace* bs = nullptr;
503  if (!stage.destStop.empty()) {
505  if (bs == nullptr) {
506  throw TraCIException("Invalid stopping place id '" + stage.destStop + "' for person: '" + personID + "'");
507  }
508  }
509  return new MSPerson::MSPersonStage_Walking(p->getID(), edges, bs, -1, speed, p->getArrivalPos(), arrivalPos, 0);
510  }
511 
512  case MSTransportable::StageType::WAITING: {
513  MSTransportable* p = getPerson(personID);
514  if (stage.travelTime < 0) {
515  throw TraCIException("Duration for person: '" + personID + "' must not be negative");
516  }
517  MSStoppingPlace* bs = nullptr;
518  if (!stage.destStop.empty()) {
520  if (bs == nullptr) {
521  throw TraCIException("Invalid stopping place id '" + stage.destStop + "' for person: '" + personID + "'");
522  }
523  }
524  return new MSTransportable::Stage_Waiting(p->getArrivalEdge(), nullptr, TIME2STEPS(stage.travelTime), 0, p->getArrivalPos(), stage.description, false);
525  }
526  default:
527  return nullptr;
528  }
529 }
530 
531 
532 void
533 Person::appendStage(const TraCIStage& stage, const std::string& personID) {
534  MSTransportable* p = getPerson(personID);
535  MSTransportable::Stage* personStage = convertTraCIStage(stage, personID);
536  p->appendStage(personStage);
537 }
538 
539 void
540 Person::replaceStage(const std::string& personID, const int stageIndex, const TraCIStage& stage) {
541  MSTransportable* p = getPerson(personID);
542  if (stageIndex >= p->getNumRemainingStages()) {
543  throw TraCIException("Specified stage index: is not valid for person " + personID);
544  }
545  MSTransportable::Stage* personStage = convertTraCIStage(stage, personID);
546  // removing the current stage triggers abort+proceed so the replacement
547  // stage must be ready beforehand
548  p->appendStage(personStage, stageIndex + 1);
549  p->removeStage(stageIndex);
550 }
551 
552 
553 void
554 Person::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
555  MSTransportable* p = getPerson(personID);
556  const MSEdge* edge = MSEdge::dictionary(toEdge);
557  if (!edge) {
558  throw TraCIException("Invalid edge '" + toEdge + "' for person: '" + personID + "'");
559  }
560  if (lines.size() == 0) {
561  return throw TraCIException("Empty lines parameter for person: '" + personID + "'");
562  }
563  MSStoppingPlace* bs = nullptr;
564  if (stopID != "") {
566  if (bs == nullptr) {
567  throw TraCIException("Invalid stopping place id '" + stopID + "' for person: '" + personID + "'");
568  }
569  }
570  p->appendStage(new MSPerson::MSPersonStage_Driving(edge, bs, -NUMERICAL_EPS, StringTokenizer(lines).getVector()));
571 }
572 
573 
574 void
575 Person::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
576  MSTransportable* p = getPerson(personID);
577  if (duration < 0) {
578  throw TraCIException("Duration for person: '" + personID + "' must not be negative");
579  }
580  MSStoppingPlace* bs = nullptr;
581  if (stopID != "") {
583  if (bs == nullptr) {
584  throw TraCIException("Invalid stopping place id '" + stopID + "' for person: '" + personID + "'");
585  }
586  }
587  p->appendStage(new MSTransportable::Stage_Waiting(p->getArrivalEdge(), nullptr, TIME2STEPS(duration), 0, p->getArrivalPos(), description, false));
588 }
589 
590 
591 void
592 Person::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edgeIDs, double arrivalPos, double duration, double speed, const std::string& stopID) {
593  MSTransportable* p = getPerson(personID);
594  ConstMSEdgeVector edges;
595  try {
596  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
597  } catch (ProcessError& e) {
598  throw TraCIException(e.what());
599  }
600  if (edges.empty()) {
601  throw TraCIException("Empty edge list for walking stage of person '" + personID + "'.");
602  }
603  if (fabs(arrivalPos) > edges.back()->getLength()) {
604  throw TraCIException("Invalid arrivalPos for walking stage of person '" + personID + "'.");
605  }
606  if (arrivalPos < 0) {
607  arrivalPos += edges.back()->getLength();
608  }
609  if (speed < 0) {
610  speed = p->getVehicleType().getMaxSpeed();
611  }
612  MSStoppingPlace* bs = nullptr;
613  if (stopID != "") {
615  if (bs == nullptr) {
616  throw TraCIException("Invalid stopping place id '" + stopID + "' for person: '" + personID + "'");
617  }
618  }
619  p->appendStage(new MSPerson::MSPersonStage_Walking(p->getID(), edges, bs, TIME2STEPS(duration), speed, p->getArrivalPos(), arrivalPos, 0));
620 }
621 
622 
623 void
624 Person::removeStage(const std::string& personID, int nextStageIndex) {
625  MSTransportable* p = getPerson(personID);
626  if (nextStageIndex >= p->getNumRemainingStages()) {
627  throw TraCIException("The stage index must be lower than the number of remaining stages.");
628  }
629  if (nextStageIndex < 0) {
630  throw TraCIException("The stage index may not be negative.");
631  }
632  p->removeStage(nextStageIndex);
633 }
634 
635 
636 void
637 Person::rerouteTraveltime(const std::string& personID) {
638  MSPerson* p = getPerson(personID);
639  if (p->getNumRemainingStages() == 0) {
640  throw TraCIException("Person '" + personID + "' has no remaining stages.");
641  }
642  const MSEdge* from = p->getEdge();
643  double departPos = p->getEdgePos();
644  // reroute to the start of the next-non-walking stage
645  int firstIndex;
647  firstIndex = 0;
648  } else if (p->getCurrentStageType() == MSTransportable::WAITING) {
650  throw TraCIException("Person '" + personID + "' cannot reroute after the current stop.");
651  }
652  firstIndex = 1;
653  } else {
654  throw TraCIException("Person '" + personID + "' cannot reroute in stage type '" + toString(p->getCurrentStageType()) + "'.");
655  }
656  int nextIndex = firstIndex + 1;
657  for (; nextIndex < p->getNumRemainingStages(); nextIndex++) {
659  break;
660  }
661  }
662  MSTransportable::Stage* destStage = p->getNextStage(nextIndex - 1);
663  const MSEdge* to = destStage->getEdges().back();
664  double arrivalPos = destStage->getArrivalPos();
665  double speed = p->getVehicleType().getMaxSpeed();
666  ConstMSEdgeVector newEdges;
667  MSNet::getInstance()->getPedestrianRouter().compute(from, to, departPos, arrivalPos, speed, 0, nullptr, newEdges);
668  if (newEdges.empty()) {
669  throw TraCIException("Could not find new route for person '" + personID + "'.");
670  }
671  ConstMSEdgeVector oldEdges = p->getEdges(firstIndex);
672  assert(!oldEdges.empty());
673  if (oldEdges.front()->getFunction() != EDGEFUNC_NORMAL) {
674  oldEdges.erase(oldEdges.begin());
675  }
676  //std::cout << " remainingStages=" << p->getNumRemainingStages() << " oldEdges=" << toString(oldEdges) << " newEdges=" << toString(newEdges) << " firstIndex=" << firstIndex << " nextIndex=" << nextIndex << "\n";
677  if (newEdges == oldEdges && (firstIndex + 1 == nextIndex)) {
678  return;
679  }
680  if (newEdges.front() != from) {
681  // @note: maybe this should be done automatically by the router
682  newEdges.insert(newEdges.begin(), from);
683  }
684  p->reroute(newEdges, departPos, firstIndex, nextIndex);
685 }
686 
687 
688 void
689 Person::moveTo(const std::string& personID, const std::string& edgeID, double /* position */) {
690  MSPerson* p = getPerson(personID);
691  MSEdge* e = MSEdge::dictionary(edgeID);
692  if (e == nullptr) {
693  throw TraCIException("Unknown edge '" + edgeID + "'.");
694  }
695  /*
696  switch (p->getStageType(0)) {
697  case MSTransportable::MOVING_WITHOUT_VEHICLE: {
698  MSPerson::MSPersonStage_Walking* s = dynamic_cast<MSPerson::MSPersonStage_Walking*>(p->getCurrentStage());
699  assert(s != 0);
700  const std::string error = s->moveTo(p, Simulation::getCurrentTime());
701  if (error != "") {
702  throw TraCIException("Command moveTo failed for person '" + personID + "' (" + error + ").");
703  }
704  break;
705  }
706  default:
707  */
708  throw TraCIException("Command moveTo is not supported for person '" + personID + "' while " + p->getCurrentStageDescription() + ".");
709  //}
710 }
711 
712 
713 void
714 Person::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRoute) {
715  MSPerson* p = getPerson(personID);
716  const bool doKeepRoute = (keepRoute & 1) != 0;
717  const bool mayLeaveNetwork = (keepRoute & 2) != 0;
718  const bool ignorePermissions = (keepRoute & 4) != 0;
719  SUMOVehicleClass vClass = ignorePermissions ? SVC_IGNORING : p->getVClass();
720  Position pos(x, y);
721 #ifdef DEBUG_MOVEXY
722  const double origAngle = angle;
723 #endif
724  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
725  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
726  if (angle != INVALID_DOUBLE_VALUE) {
727  while (angle >= 360.) {
728  angle -= 360.;
729  }
730  while (angle < 0.) {
731  angle += 360.;
732  }
733  }
734  Position currentPos = p->getPosition();
735 #ifdef DEBUG_MOVEXY
736  std::cout << std::endl << "begin person " << p->getID() << " lanePos:" << p->getEdgePos() << " edge:" << Named::getIDSecure(p->getEdge()) << "\n";
737  std::cout << " want pos:" << pos << " edgeID:" << edgeID << " origAngle:" << origAngle << " angle:" << angle << " keepRoute:" << keepRoute << std::endl;
738 #endif
739 
740  ConstMSEdgeVector edges;
741  MSLane* lane = nullptr;
742  double lanePos;
743  double lanePosLat = 0;
744  double bestDistance = std::numeric_limits<double>::max();
745  int routeOffset = 0;
746  bool found = false;
747  double maxRouteDistance = 100;
748 
750  ev.push_back(p->getEdge());
751  int routeIndex = 0;
752  MSLane* currentLane = const_cast<MSLane*>(getSidewalk<MSEdge, MSLane>(p->getEdge()));
753  switch (p->getStageType(0)) {
756  assert(s != 0);
757  ev = s->getEdges();
758  routeIndex = (int)(s->getRouteStep() - s->getRoute().begin());
759  }
760  break;
761  default:
762  break;
763  }
764  if (doKeepRoute) {
765  // case a): vehicle is on its earlier route
766  // we additionally assume it is moving forward (SUMO-limit);
767  // note that the route ("edges") is not changed in this case
768  found = Helper::moveToXYMap_matchingRoutePosition(pos, edgeID,
769  ev, routeIndex, vClass,
770  bestDistance, &lane, lanePos, routeOffset);
771  } else {
772  double speed = pos.distanceTo2D(p->getPosition()); // !!!veh->getSpeed();
773  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, edgeID, angle,
774  speed, ev, routeIndex, currentLane, p->getEdgePos(), true,
775  vClass,
776  bestDistance, &lane, lanePos, routeOffset, edges);
777  }
778  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
779  // compute lateral offset
780  if (found) {
781  const double perpDist = lane->getShape().distance2D(pos, false);
782  if (perpDist != GeomHelper::INVALID_OFFSET) {
783  lanePosLat = perpDist;
784  if (!mayLeaveNetwork) {
785  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + p->getVehicleType().getWidth()));
786  }
787  // figure out whether the offset is to the left or to the right
788  PositionVector tmp = lane->getShape();
789  try {
790  tmp.move2side(-lanePosLat); // moved to left
791  } catch (ProcessError&) {
792  WRITE_WARNING("Could not determine position on lane '" + lane->getID() + " at lateral position " + toString(-lanePosLat) + ".");
793  }
794  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
795  if (tmp.distance2D(pos) > perpDist) {
796  lanePosLat = -lanePosLat;
797  }
798  }
799  }
800  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
801  // mapped position may differ from pos
802  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
803  }
804  assert((found && lane != 0) || (!found && lane == 0));
805  if (angle == INVALID_DOUBLE_VALUE) {
806  if (lane != nullptr) {
807  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
808  } else {
809  // compute angle outside road network from old and new position
810  angle = GeomHelper::naviDegree(p->getPosition().angleTo2D(pos));
811  }
812  }
813  switch (p->getStageType(0)) {
815  Helper::setRemoteControlled(p, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
816  break;
817  }
818  default:
819  throw TraCIException("Command moveToXY is not supported for person '" + personID + "' while " + p->getCurrentStageDescription() + ".");
820  }
821  } else {
822  if (lane == nullptr) {
823  throw TraCIException("Could not map person '" + personID + "' no road found within " + toString(maxRouteDistance) + "m.");
824  } else {
825  throw TraCIException("Could not map person '" + personID + "' distance to road is " + toString(bestDistance) + ".");
826  }
827  }
828 }
829 
830 
833 void
834 Person::setParameter(const std::string& personID, const std::string& key, const std::string& value) {
835  MSTransportable* p = getPerson(personID);
836  ((SUMOVehicleParameter&)p->getParameter()).setParameter(key, value);
837 }
838 
839 void
840 Person::setLength(const std::string& personID, double length) {
841  getPerson(personID)->getSingularType().setLength(length);
842 }
843 
844 
845 void
846 Person::setMaxSpeed(const std::string& personID, double speed) {
847  getPerson(personID)->getSingularType().setMaxSpeed(speed);
848 }
849 
850 
851 void
852 Person::setVehicleClass(const std::string& personID, const std::string& clazz) {
854 }
855 
856 
857 void
858 Person::setShapeClass(const std::string& personID, const std::string& clazz) {
860 }
861 
862 
863 void
864 Person::setEmissionClass(const std::string& personID, const std::string& clazz) {
866 }
867 
868 
869 void
870 Person::setWidth(const std::string& personID, double width) {
871  getPerson(personID)->getSingularType().setWidth(width);
872 }
873 
874 
875 void
876 Person::setHeight(const std::string& personID, double height) {
877  getPerson(personID)->getSingularType().setHeight(height);
878 }
879 
880 
881 void
882 Person::setMinGap(const std::string& personID, double minGap) {
883  getPerson(personID)->getSingularType().setMinGap(minGap);
884 }
885 
886 
887 void
888 Person::setAccel(const std::string& personID, double accel) {
889  getPerson(personID)->getSingularType().setAccel(accel);
890 }
891 
892 
893 void
894 Person::setDecel(const std::string& personID, double decel) {
895  getPerson(personID)->getSingularType().setDecel(decel);
896 }
897 
898 
899 void
900 Person::setEmergencyDecel(const std::string& personID, double decel) {
901  getPerson(personID)->getSingularType().setEmergencyDecel(decel);
902 }
903 
904 
905 void
906 Person::setApparentDecel(const std::string& personID, double decel) {
907  getPerson(personID)->getSingularType().setApparentDecel(decel);
908 }
909 
910 
911 void
912 Person::setImperfection(const std::string& personID, double imperfection) {
913  getPerson(personID)->getSingularType().setImperfection(imperfection);
914 }
915 
916 
917 void
918 Person::setTau(const std::string& personID, double tau) {
919  getPerson(personID)->getSingularType().setTau(tau);
920 }
921 
922 
923 void
924 Person::setMinGapLat(const std::string& personID, double minGapLat) {
925  getPerson(personID)->getSingularType().setMinGapLat(minGapLat);
926 }
927 
928 
929 void
930 Person::setMaxSpeedLat(const std::string& personID, double speed) {
931  getPerson(personID)->getSingularType().setMaxSpeedLat(speed);
932 }
933 
934 
935 void
936 Person::setLateralAlignment(const std::string& personID, const std::string& latAlignment) {
938 }
939 
940 
941 void
942 Person::setSpeedFactor(const std::string& personID, double factor) {
943  getPerson(personID)->getSingularType().setSpeedFactor(factor);
944 }
945 
946 
947 void
948 Person::setActionStepLength(const std::string& personID, double actionStepLength, bool resetActionOffset) {
949  getPerson(personID)->getSingularType().setActionStepLength(SUMOVehicleParserHelper::processActionStepLength(actionStepLength), resetActionOffset);
950 }
951 
952 
953 void
954 Person::setColor(const std::string& personID, const TraCIColor& c) {
955  const SUMOVehicleParameter& p = getPerson(personID)->getParameter();
956  p.color.set((unsigned char)c.r, (unsigned char)c.g, (unsigned char)c.b, (unsigned char)c.a);
958 }
959 
960 
962 
963 
964 MSPerson*
965 Person::getPerson(const std::string& personID) {
967  MSPerson* p = dynamic_cast<MSPerson*>(c.get(personID));
968  if (p == nullptr) {
969  throw TraCIException("Person '" + personID + "' is not known");
970  }
971  return p;
972 }
973 
974 
975 void
976 Person::storeShape(const std::string& id, PositionVector& shape) {
977  shape.push_back(getPerson(id)->getPosition());
978 }
979 
980 
981 std::shared_ptr<VariableWrapper>
983  return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
984 }
985 
986 
987 bool
988 Person::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper) {
989  switch (variable) {
990  case TRACI_ID_LIST:
991  return wrapper->wrapStringList(objID, variable, getIDList());
992  case ID_COUNT:
993  return wrapper->wrapInt(objID, variable, getIDCount());
994  case VAR_POSITION:
995  return wrapper->wrapPosition(objID, variable, getPosition(objID));
996  case VAR_POSITION3D:
997  return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
998  case VAR_ANGLE:
999  return wrapper->wrapDouble(objID, variable, getAngle(objID));
1000  case VAR_SLOPE:
1001  return wrapper->wrapDouble(objID, variable, getSlope(objID));
1002  case VAR_SPEED:
1003  return wrapper->wrapDouble(objID, variable, getSpeed(objID));
1004  case VAR_ROAD_ID:
1005  return wrapper->wrapString(objID, variable, getRoadID(objID));
1006  case VAR_LANEPOSITION:
1007  return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
1008  case VAR_COLOR:
1009  return wrapper->wrapColor(objID, variable, getColor(objID));
1010  case VAR_WAITING_TIME:
1011  return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
1012  case VAR_TYPE:
1013  return wrapper->wrapString(objID, variable, getTypeID(objID));
1014  case VAR_NEXT_EDGE:
1015  return wrapper->wrapString(objID, variable, getNextEdge(objID));
1016  case VAR_STAGES_REMAINING:
1017  return wrapper->wrapInt(objID, variable, getRemainingStages(objID));
1018  case VAR_VEHICLE:
1019  return wrapper->wrapString(objID, variable, getVehicle(objID));
1020  default:
1021  return false;
1022  }
1023 }
1024 
1025 
1026 }
1027 
1028 
1029 /****************************************************************************/
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
double getApparentDecel() const
Get the vehicle type&#39;s apparent deceleration [m/s^2] (the one regarded by its followers.
Definition: MSCFModel.h:234
void setMinGap(const double &minGap)
Set a new value for this type&#39;s minimum gap.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204
static double gLateralResolution
Definition: MSGlobals.h:85
static void rerouteTraveltime(const std::string &personID)
Definition: Person.cpp:637
RGBColor color
The vehicle&#39;s color, TraCI may change this.
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:350
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
long long int SUMOTime
Definition: SUMOTime.h:35
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
Definition: Person.cpp:689
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:354
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:154
double getArrivalPos() const
returns the final arrival pos
virtual double getDistance() const =0
get travel distance in this stage
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
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) ...
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
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:592
TRACI_CONST int VAR_COLOR
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
const MSEdge * getEdge() const
Returns the current edge.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:899
TRACI_CONST int VAR_VEHICLE
A lane area vehicles can halt at.
static std::string getParameter(const std::string &routeID, const std::string &param)
Definition: Person.cpp:249
TRACI_CONST int VAR_WAITING_TIME
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
void setTau(double tau)
Set a new value for this type&#39;s headway.
static void setType(const std::string &personID, const std::string &typeID)
Definition: Person.cpp:384
void setShape(SUMOVehicleShape shape)
Set a new value for this type&#39;s shape.
virtual double getEdgePos() const
Return the position on the edge.
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:372
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:244
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Person.cpp:976
double length
length in m
Definition: TraCIDefs.h:364
TRACI_CONST int VAR_ROAD_ID
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:83
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition: Helper.cpp:264
virtual double getImperfection() const
Get the driver&#39;s imperfection.
Definition: MSCFModel.h:251
static double getSpeed(const std::string &personID)
Definition: Person.cpp:106
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:356
static int getIDCount()
Definition: Person.cpp:69
The position is given.
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.
void setDecel(double decel)
Set a new value for this type&#39;s deceleration.
static void appendStage(const TraCIStage &stage, const std::string &personID)
Definition: Person.cpp:533
static MSPerson * getPerson(const std::string &id)
Definition: Person.cpp:965
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
static MSTransportable::Stage * convertTraCIStage(const TraCIStage &stage, const std::string personID)
Definition: Person.cpp:459
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
TRACI_CONST int VAR_POSITION
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:165
static void replaceStage(const std::string &personID, const int stageIndex, const TraCIStage &stage)
Definition: Person.cpp:540
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:254
int size() const
Returns the number of known transportables.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
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:655
std::vector< double > & getParameter()
Returns the parameters of this distribution.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:478
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:70
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
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:804
TRACI_CONST int VAR_STAGES_REMAINING
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void setApparentDecel(double apparentDecel)
Set a new value for this type&#39;s apparent deceleration.
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:76
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:205
TRACI_CONST int VAR_ANGLE
static double getSlope(const std::string &personID)
Definition: Person.cpp:93
void setLength(const double &length)
Set a new value for this type&#39;s length.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
const std::string & getID() const
Returns the id.
Definition: Named.h:77
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
virtual double getSpeed() const
the current speed of the transportable
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
Definition: TraCIDefs.h:368
ConstMSEdgeVector getEdges(int next) const
Return the edges of the nth next stage.
const SUMOVehicleParameter & getParameter() const
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type&#39;s maximum speed.
double getLength() const
return the length of the edge
Definition: MSEdge.h:582
void setImperfection(double imperfection)
Set a new value for this type&#39;s imperfection.
SUMOVehicleClass getVClass() const
Returns the vehicle&#39;s access class.
Tag for the last element in the enum for safe int casting.
int getPersonCapacity() const
Get this vehicle type&#39;s person capacity.
double departPos
position on the lane when starting the stage
Definition: TraCIDefs.h:370
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:557
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
double cost
effort needed
Definition: TraCIDefs.h:362
std::string description
arbitrary description string
Definition: TraCIDefs.h:374
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
The car-following model and parameter.
Definition: MSVehicleType.h:66
static void setSpeed(const std::string &personID, double speed)
Definition: Person.cpp:378
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
Definition: Helper.cpp:1045
static void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle=INVALID_DOUBLE_VALUE, const int keepRoute=1)
Definition: Person.cpp:714
void removeStage(int next)
removes the nth next stage
double getMaxAccel() const
Get the vehicle type&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:210
void setMinGapLat(const double &minGapLat)
Set a new value for this type&#39;s minimum lataral gap.
static SubscriptionResults mySubscriptionResults
Definition: Person.h:106
TRACI_CONST int TRACI_ID_LIST
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
A road/street connecting two junctions.
Definition: MSEdge.h:76
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:194
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type&#39;s car following model definition (const version)
TRACI_CONST int ID_COUNT
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
static LIBSUMO_VEHICLE_TYPE_GETTER 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:394
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, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
Definition: Helper.cpp:822
void setAccel(double accel)
Set a new value for this type&#39;s acceleration.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static std::string getTypeID(const std::string &personID)
Definition: Person.cpp:136
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: Person.cpp:554
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:798
static double getAngle(const std::string &personID)
Definition: Person.cpp:87
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
TRACI_CONST int VAR_NEXT_EDGE
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition: RGBColor.cpp:80
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:138
A list of positions.
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...
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:358
double getEmergencyDecel() const
Get the vehicle type&#39;s maximal phisically possible deceleration [m/s^2].
Definition: MSCFModel.h:226
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:337
virtual SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
void setHeight(const double &height)
Set a new value for this type&#39;s height.
static TraCIStage getStage(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:173
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
static std::string getNextEdge(const std::string &personID)
Definition: Person.cpp:148
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
double getArrivalPos() const
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Person.h:107
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
T MIN2(T a, T b)
Definition: StdDefs.h:74
TRACI_CONST int VAR_SLOPE
static double getWaitingTime(const std::string &personID)
Definition: Person.cpp:142
const std::string & getID() const
returns the id of the transportable
static int getRemainingStages(const std::string &personID)
Definition: Person.cpp:232
static std::string getVehicle(const std::string &personID)
Definition: Person.cpp:238
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type&#39;s emission class.
double getMinGap() const
Get the free space in front of vehicles of this class.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
double getMaxDecel() const
Get the vehicle type&#39;s maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:218
virtual std::string getStageDescription() const =0
return (brief) string representation of the current stage
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: TraCIDefs.h:51
TRACI_CONST int VAR_POSITION3D
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:52
static void removeStage(const std::string &personID, int nextStageIndex)
Definition: Person.cpp:624
const int VEHPARS_COLOR_SET
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:175
void setSpeedFactor(const double &factor)
Set a new value for this type&#39;s speed factor.
MSPedestrianRouter & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:985
static std::vector< std::string > getIDList()
Definition: Person.cpp:56
Definition: Edge.cpp:30
TRACI_CONST int STAGE_WALKING
std::string vType
The vehicle type when using a private car or bike.
Definition: TraCIDefs.h:352
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type&#39;s action step length.
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
std::vector< std::string > getVector()
return vector of strings
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
Definition: Person.cpp:834
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
virtual bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)=0
double getMaxSpeedLat() const
Get vehicle&#39;s maximum lateral speed [m/s].
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition: Helper.cpp:786
const std::vector< const MSEdge * >::iterator getRouteStep() const
Definition: MSPerson.h:165
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
static TraCIPosition getPosition(const std::string &personID, const bool includeZ=false)
Definition: Person.cpp:75
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
TRACI_CONST int VAR_SPEED
double departPos
(optional) The position the vehicle shall depart from
Structure representing possible vehicle parameter.
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type&#39;s emergency deceleration.
TRACI_CONST int VAR_TYPE
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
TRACI_CONST int VAR_LANEPOSITION
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex, nextIndex[
Definition: MSPerson.cpp:715
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
virtual double getHeadwayTime() const
Get the driver&#39;s desired headway [s].
Definition: MSCFModel.h:259
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:69
static TraCIPosition getPosition3D(const std::string &personID)
Definition: Person.cpp:81
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occurred.
StageType getStageType() const
TRACI_CONST int STAGE_DRIVING
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:499
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:360
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void setWidth(const double &width)
Set a new value for this type&#39;s width.
double getActionStepLengthSecs() const
Returns this type&#39;s default action step length in seconds.
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: Person.cpp:575
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
StageType getStageType(int next) const
the stage type for the nth next stage
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
double getLength() const
Get vehicle&#39;s length [m].
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Person.cpp:988
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type&#39;s vehicle class.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
const MSEdge * getArrivalEdge() const
returns the final arrival edge
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:62
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
Position getPosition(const double) const
Return current position (x/y, cartesian)
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Person.cpp:982
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
#define NUMERICAL_EPS
Definition: config.h:145
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:366
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type&#39;s maximum lateral speed.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle&#39;s preferred lateral alignment.
A 3D-position.
Definition: TraCIDefs.h:110
TRACI_CONST double INVALID_DOUBLE_VALUE
static std::string getRoadID(const std::string &personID)
Definition: Person.cpp:112
static double getLanePosition(const std::string &personID)
Definition: Person.cpp:118
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
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:861
DepartDefinition
Possible ways to depart.
vehicles ignoring classes
int getNumStages() const
Return the total number stages in this persons plan.
std::string id
The vehicle&#39;s id.
StageType getCurrentStageType() const
the current stage type of the transportable