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)) {
755  MSPerson::MSPersonStage_Walking* s = dynamic_cast<MSPerson::MSPersonStage_Walking*>(p->getCurrentStage());
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 /****************************************************************************/
RGBColor::alpha
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:83
MSTransportableControl::constVehIt
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
Definition: MSTransportableControl.h:58
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSVehicleType::setHeight
void setHeight(const double &height)
Set a new value for this type's height.
Definition: MSVehicleType.cpp:101
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
MSNet::getStoppingPlace
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:899
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
MSStoppingPlace
A lane area vehicles can halt at.
Definition: MSStoppingPlace.h:60
MSCFModel::getMaxAccel
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Definition: MSCFModel.h:210
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:74
Person
C++ TraCI client API implementation.
libsumo::Person::getLanePosition
static double getLanePosition(const std::string &personID)
Definition: Person.cpp:118
MSVehicleType::setPreferredLateralAlignment
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle's preferred lateral alignment.
Definition: MSVehicleType.cpp:162
SUMOVehicleParameter::parametersSet
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color)
Definition: SUMOVehicleParameter.h:650
MSCFModel::getMaxDecel
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:218
MSVehicleType::setMinGapLat
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
Definition: MSVehicleType.cpp:123
getVehicleClassID
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
Definition: SUMOVehicleClass.cpp:201
MSVehicleType::setAccel
void setAccel(double accel)
Set a new value for this type's acceleration.
Definition: MSVehicleType.cpp:390
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
SUMOTime.h
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
libsumo::INVALID_DOUBLE_VALUE
TRACI_CONST double INVALID_DOUBLE_VALUE
Definition: TraCIConstants.h:363
MSCFModel::getImperfection
virtual double getImperfection() const
Get the driver's imperfection.
Definition: MSCFModel.h:251
libsumo::Person::setSpeed
static void setSpeed(const std::string &personID, double speed)
Definition: Person.cpp:378
libsumo::VAR_POSITION
TRACI_CONST int VAR_POSITION
Definition: TraCIConstants.h:616
MSPerson::getNextEdge
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
libsumo::VariableWrapper::wrapString
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
SUMOVehicleParameter::color
RGBColor color
The vehicle's color, TraCI may change this.
Definition: SUMOVehicleParameter.h:471
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:348
libsumo::VAR_STAGES_REMAINING
TRACI_CONST int VAR_STAGES_REMAINING
Definition: TraCIConstants.h:974
PedestrianRouter::compute
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...
Definition: PedestrianRouter.h:85
MSTransportable::appendStage
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
Definition: MSTransportable.cpp:745
libsumo::VAR_ROAD_ID
TRACI_CONST int VAR_ROAD_ID
Definition: TraCIConstants.h:673
libsumo::Person::getPosition
static TraCIPosition getPosition(const std::string &personID, const bool includeZ=false)
Definition: Person.cpp:75
libsumo::TraCIPosition
A 3D-position.
Definition: TraCIDefs.h:110
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:145
SUMOVehicleParserHelper.h
libsumo::VariableWrapper
Definition: Subscription.h:114
MSTransportable::getArrivalEdge
const MSEdge * getArrivalEdge() const
returns the final arrival edge
Definition: MSTransportable.h:746
MSTransportable::Stage_Driving
Definition: MSTransportable.h:436
SUMOTrafficObject::getVehicleType
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
MSTransportable::getEdges
ConstMSEdgeVector getEdges(int next) const
Return the edges of the nth next stage.
Definition: MSTransportable.h:690
libsumo::Person::getVehicle
static std::string getVehicle(const std::string &personID)
Definition: Person.cpp:238
libsumo::VAR_COLOR
TRACI_CONST int VAR_COLOR
Definition: TraCIConstants.h:628
SUMOVehicleParameter::departPosProcedure
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Definition: SUMOVehicleParameter.h:491
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
MSTransportable::Stage::getDistance
virtual double getDistance() const =0
get travel distance in this stage
MSVehicleType::setVClass
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
Definition: MSVehicleType.cpp:156
MSCFModel::getApparentDecel
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
Definition: MSCFModel.h:234
libsumo::TraCIColor::a
int a
Definition: TraCIDefs.h:144
MSPerson
Definition: MSPerson.h:64
MSVehicleType::getMaxSpeedLat
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
Definition: MSVehicleType.h:314
libsumo::VAR_WAITING_TIME
TRACI_CONST int VAR_WAITING_TIME
Definition: TraCIConstants.h:823
libsumo::TraCIColor::g
int g
Definition: TraCIDefs.h:144
MSVehicleType::setEmergencyDecel
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
Definition: MSVehicleType.cpp:408
MSTransportable::Stage
Definition: MSTransportable.h:74
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
libsumo::Helper::moveToXYMap
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
GeomHelper::naviDegree
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:194
DepartDefinition
DepartDefinition
Possible ways to depart.
Definition: SUMOVehicleParameter.h:94
PositionVector::slopeDegreeAtOffset
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
Definition: PositionVector.cpp:317
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
SUMOVehicleParameter::departProcedure
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
Definition: SUMOVehicleParameter.h:479
libsumo::ContextSubscriptionResults
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:205
MSTransportableControl::size
int size() const
Returns the number of known transportables.
Definition: MSTransportableControl.h:166
libsumo::Person::moveTo
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
Definition: Person.cpp:689
MSTransportable::Stage::getEdges
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSTransportable.cpp:94
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
RGBColor::red
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:62
MSEdge.h
VehicleType.h
libsumo::TraCIStage::intended
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:366
libsumo::Helper::makeTraCIPosition
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition: Helper.cpp:264
libsumo::TraCIColor
A color.
Definition: TraCIDefs.h:136
MSVehicleType::setMinGap
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
Definition: MSVehicleType.cpp:112
libsumo::VAR_VEHICLE
TRACI_CONST int VAR_VEHICLE
Definition: TraCIConstants.h:977
MSTransportable
Definition: MSTransportable.h:59
MSVehicleType::setWidth
void setWidth(const double &width)
Set a new value for this type's width.
Definition: MSVehicleType.cpp:252
PollutantsInterface::getName
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
Definition: PollutantsInterface.cpp:100
MSTransportableControl::add
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occurred.
Definition: MSTransportableControl.cpp:62
PositionVector
A list of positions.
Definition: PositionVector.h:46
libsumo::Person::getEdges
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:154
MSVehicleType::getPersonCapacity
int getPersonCapacity() const
Get this vehicle type's person capacity.
Definition: MSVehicleType.h:285
libsumo::Person::appendWalkingStage
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
MSEdge::getLength
double getLength() const
return the length of the edge
Definition: MSEdge.h:582
getVehicleShapeName
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
Definition: SUMOVehicleClass.cpp:359
MSVehicleType::getMinGapLat
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
Definition: MSVehicleType.h:133
libsumo::TraCIColor::b
int b
Definition: TraCIDefs.h:144
MSTransportable::getStageType
StageType getStageType(int next) const
the stage type for the nth next stage
Definition: MSTransportable.h:663
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:476
MSTransportable::getCurrentStageType
StageType getCurrentStageType() const
the current stage type of the transportable
Definition: MSTransportable.h:658
MSPerson::MSPersonStage_Walking::getRouteStep
const std::vector< const MSEdge * >::iterator getRouteStep() const
Definition: MSPerson.h:165
libsumo::TraCIStage::arrivalPos
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:372
libsumo::VariableWrapper::wrapColor
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
Parameterised::getParameter
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
Definition: Parameterised.cpp:71
MSGlobals::gLateralResolution
static double gLateralResolution
Definition: MSGlobals.h:85
libsumo
Definition: Edge.cpp:30
MSTransportableControl
Definition: MSTransportableControl.h:52
MSVehicleType::getHeight
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
Definition: MSVehicleType.h:254
libsumo::Person::getRoadID
static std::string getRoadID(const std::string &personID)
Definition: Person.cpp:112
MSTransportableControl::get
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
Definition: MSTransportableControl.cpp:76
Person.h
SUMOVehicleParserHelper::processActionStepLength
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
Definition: SUMOVehicleParserHelper.cpp:1390
RGBColor
Definition: RGBColor.h:40
MSTransportable::getEdge
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSTransportable.h:628
libsumo::VariableWrapper::wrapDouble
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
libsumo::Person::storeShape
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
libsumo::TraCIStage::travelTime
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:360
Distribution_Parameterized::getParameter
std::vector< double > & getParameter()
Returns the parameters of this distribution.
Definition: Distribution_Parameterized.cpp:111
libsumo::Person::getSpeed
static double getSpeed(const std::string &personID)
Definition: Person.cpp:106
libsumo::Person::getSlope
static double getSlope(const std::string &personID)
Definition: Person.cpp:93
MSTransportable::getCurrentStage
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
Definition: MSTransportable.h:678
TraCIConstants.h
MSTransportable::Stage::getStageDescription
virtual std::string getStageDescription() const =0
return (brief) string representation of the current stage
MSVehicleType::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
Definition: MSVehicleType.h:141
MSTransportable::WAITING
Definition: MSTransportable.h:63
libsumo::TraCIStage::description
std::string description
arbitrary description string
Definition: TraCIDefs.h:374
libsumo::VAR_ANGLE
TRACI_CONST int VAR_ANGLE
Definition: TraCIConstants.h:622
MSVehicleType::getWidth
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
Definition: MSVehicleType.h:247
MSTransportableControl.h
PollutantsInterface.h
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
PedestrianRouter.h
libsumo::VAR_NEXT_EDGE
TRACI_CONST int VAR_NEXT_EDGE
Definition: TraCIConstants.h:971
GeomHelper::INVALID_OFFSET
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:52
MSTransportable::getNumStages
int getNumStages() const
Return the total number stages in this persons plan.
Definition: MSTransportable.cpp:740
libsumo::VariableWrapper::wrapStringList
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
MSTransportable::getWaitingSeconds
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
Definition: MSTransportable.cpp:724
VEHPARS_COLOR_SET
const int VEHPARS_COLOR_SET
Definition: SUMOVehicleParameter.h:46
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
StringTokenizer
Definition: StringTokenizer.h:62
MSEdge::dictionary
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:804
MSTransportableControl::buildPerson
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
Definition: MSTransportableControl.cpp:311
libsumo::TraCIStage::line
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:354
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
libsumo::VAR_SLOPE
TRACI_CONST int VAR_SLOPE
Definition: TraCIConstants.h:604
libsumo::STAGE_WALKING
TRACI_CONST int STAGE_WALKING
Definition: TraCIConstants.h:401
SUMOVehicleParameter::id
std::string id
The vehicle's id.
Definition: SUMOVehicleParameter.h:462
MSTransportable::getVehicle
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
Definition: MSTransportable.h:727
MSLane::interpolateLanePosToGeometryPos
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:499
libsumo::TraCIStage
Definition: TraCIDefs.h:345
libsumo::Person::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Person.cpp:988
MSVehicleType::setActionStepLength
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
Definition: MSVehicleType.cpp:202
libsumo::Helper::moveToXYMap_matchingRoutePosition
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
ProcessError
Definition: UtilExceptions.h:40
libsumo::TraCIStage::length
double length
length in m
Definition: TraCIDefs.h:364
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
MSTransportableControl::loadedBegin
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
Definition: MSTransportableControl.h:150
libsumo::Person::getPerson
static MSPerson * getPerson(const std::string &id)
Definition: Person.cpp:965
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
libsumo::TRACI_ID_LIST
TRACI_CONST int TRACI_ID_LIST
Definition: TraCIConstants.h:496
MSVehicleType::setLength
void setLength(const double &length)
Set a new value for this type's length.
Definition: MSVehicleType.cpp:90
MSVehicleType::getMinGap
double getMinGap() const
Get the free space in front of vehicles of this class.
Definition: MSVehicleType.h:126
libsumo::TraCIColor::r
int r
Definition: TraCIDefs.h:144
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
LIBSUMO_SUBSCRIPTION_IMPLEMENTATION
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: TraCIDefs.h:51
MSTransportable::Stage::getVehicle
virtual SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
Definition: MSTransportable.h:148
MSVehicleType::setDecel
void setDecel(double decel)
Set a new value for this type's deceleration.
Definition: MSVehicleType.cpp:399
MSTransportable::getPosition
Position getPosition(const double) const
Return current position (x/y, cartesian)
Definition: MSTransportable.h:582
DEPART_DEF_MAX
Tag for the last element in the enum for safe int casting.
Definition: SUMOVehicleParameter.h:104
libsumo::ID_COUNT
TRACI_CONST int ID_COUNT
Definition: TraCIConstants.h:499
libsumo::Person::getPosition3D
static TraCIPosition getPosition3D(const std::string &personID)
Definition: Person.cpp:81
EDGEFUNC_NORMAL
Definition: SUMOXMLDefinitions.h:1076
RGBColor::green
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:69
MSTransportable::Stage::getStageType
StageType getStageType() const
Definition: MSTransportable.h:111
libsumo::Person::moveToXY
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
libsumo::Person::getStage
static TraCIStage getStage(const std::string &personID, int nextStageIndex=0)
Definition: Person.cpp:173
libsumo::TraCIStage::depart
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
Definition: TraCIDefs.h:368
libsumo::Person::getIDCount
static int getIDCount()
Definition: Person.cpp:69
libsumo::TraCIException
Definition: TraCIDefs.h:90
MSVehicleType::getSpeedFactor
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
Definition: MSVehicleType.h:210
MSTransportable::Stage::getArrivalPos
double getArrivalPos() const
Definition: MSTransportable.h:95
MSTransportable::getEdgePos
virtual double getEdgePos() const
Return the position on the edge.
Definition: MSTransportable.cpp:709
MSVehicleType::setShape
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
Definition: MSVehicleType.cpp:273
MSTransportable::Stage_Waiting
Definition: MSTransportable.h:350
MSPerson.h
PositionVector::distance2D
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)
Definition: PositionVector.cpp:1242
libsumo::Person::makeWrapper
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Person.cpp:982
libsumo::Person::getWaitingTime
static double getWaitingTime(const std::string &personID)
Definition: Person.cpp:142
MSVehicleType::setMaxSpeedLat
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
Definition: MSVehicleType.cpp:145
Position::angleTo2D
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
Position::distanceTo2D
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:244
PollutantsInterface::getClassByName
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
Definition: PollutantsInterface.cpp:54
libsumo::Person::getTypeID
static std::string getTypeID(const std::string &personID)
Definition: Person.cpp:136
libsumo::VAR_TYPE
TRACI_CONST int VAR_TYPE
Definition: TraCIConstants.h:670
libsumo::Person::mySubscriptionResults
static SubscriptionResults mySubscriptionResults
Definition: Person.h:106
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
SUMO_TAG_BUS_STOP
A bus stop.
Definition: SUMOXMLDefinitions.h:98
MSLane::getShape
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
libsumo::Person::add
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
MSTransportable::MSTransportablePlan
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
Definition: MSTransportable.h:588
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
MSTransportable::getNumRemainingStages
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
Definition: MSTransportable.cpp:735
MSTransportableControl::loadedEnd
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
Definition: MSTransportableControl.h:158
MSNet::getPersonControl
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:798
libsumo::TraCIStage::type
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:350
RGBColor::blue
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:76
MSCFModel::getHeadwayTime
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
Definition: MSCFModel.h:259
libsumo::Person::setType
static void setType(const std::string &personID, const std::string &typeID)
Definition: Person.cpp:384
libsumo::Person::getNextEdge
static std::string getNextEdge(const std::string &personID)
Definition: Person.cpp:148
MSPerson::MSPersonStage_Driving
Definition: MSPerson.h:246
MSVehicleType::getActionStepLengthSecs
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
Definition: MSVehicleType.h:226
MSTransportable::getSpeed
virtual double getSpeed() const
the current speed of the transportable
Definition: MSTransportable.cpp:729
MSTransportable::getArrivalPos
double getArrivalPos() const
returns the final arrival pos
Definition: MSTransportable.h:741
MSPerson::MSPersonStage_Walking::getRoute
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:175
PositionVector::rotationAtOffset
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Definition: PositionVector.cpp:286
libsumo::Helper::setRemoteControlled
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
libsumo::Person::getRemainingStages
static int getRemainingStages(const std::string &personID)
Definition: Person.cpp:232
MSTransportable::getVehicleType
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
Definition: MSTransportable.h:607
MSVehicleType::getLength
double getLength() const
Get vehicle's length [m].
Definition: MSVehicleType.h:110
MSTransportable::getNextStage
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
Definition: MSTransportable.h:683
libsumo::TraCIStage::edges
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:358
MSVehicleType::setApparentDecel
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
Definition: MSVehicleType.cpp:417
MSTransportable::getVClass
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
Definition: MSTransportable.cpp:930
libsumo::VariableWrapper::wrapInt
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
libsumo::Person::removeStage
static void removeStage(const std::string &personID, int nextStageIndex)
Definition: Person.cpp:624
libsumo::Person::appendStage
static void appendStage(const TraCIStage &stage, const std::string &personID)
Definition: Person.cpp:533
libsumo::VAR_LANEPOSITION
TRACI_CONST int VAR_LANEPOSITION
Definition: TraCIConstants.h:697
libsumo::VAR_POSITION3D
TRACI_CONST int VAR_POSITION3D
Definition: TraCIConstants.h:619
MSPerson::MSPersonStage_Walking
Definition: MSPerson.h:71
MSTransportable::setSpeed
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSTransportable.cpp:782
MSTransportable::getID
const std::string & getID() const
returns the id of the transportable
Definition: MSTransportable.cpp:694
MSEdge::parseEdgesList
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
MSCFModel::getEmergencyDecel
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
Definition: MSCFModel.h:226
libsumo::Person::rerouteTraveltime
static void rerouteTraveltime(const std::string &personID)
Definition: Person.cpp:637
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:165
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:162
MSLane::getWidth
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:557
libsumo::Person::replaceStage
static void replaceStage(const std::string &personID, const int stageIndex, const TraCIStage &stage)
Definition: Person.cpp:540
libsumo::STAGE_DRIVING
TRACI_CONST int STAGE_DRIVING
Definition: TraCIConstants.h:403
getVehicleShapeID
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
Definition: SUMOVehicleClass.cpp:343
StringTokenizer::getVector
std::vector< std::string > getVector()
return vector of strings
Definition: StringTokenizer.cpp:192
config.h
MSVehicleType::setMaxSpeed
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
Definition: MSVehicleType.cpp:134
Named::getIDSecure
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
GeomHelper.h
MSTransportable::MOVING_WITHOUT_VEHICLE
Definition: MSTransportable.h:64
StringTokenizer.h
MSTransportable::Stage::getDestinationStop
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSTransportable.h:86
MSTransportable::removeStage
void removeStage(int next)
removes the nth next stage
Definition: MSTransportable.cpp:761
libsumo::VAR_SPEED
TRACI_CONST int VAR_SPEED
Definition: TraCIConstants.h:607
MSLane::geometryPositionAtOffset
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
libsumo::TraCIStage::departPos
double departPos
position on the lane when starting the stage
Definition: TraCIDefs.h:370
SUMOXMLDefinitions::LateralAlignments
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
Definition: SUMOXMLDefinitions.h:1396
DEPART_POS_GIVEN
The position is given.
Definition: SUMOVehicleParameter.h:140
MSVehicleType::setSpeedFactor
void setSpeedFactor(const double &factor)
Set a new value for this type's speed factor.
Definition: MSVehicleType.cpp:180
libsumo::TraCIStage::vType
std::string vType
The vehicle type when using a private car or bike.
Definition: TraCIDefs.h:352
libsumo::Person::getIDList
static std::vector< std::string > getIDList()
Definition: Person.cpp:56
MSPerson::reroute
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex,...
Definition: MSPerson.cpp:715
libsumo::VariableWrapper::wrapPosition
virtual bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)=0
libsumo::TraCIStage::destStop
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:356
MSPerson::MSPersonStage_Walking::getEdges
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:138
libsumo::Person::appendWaitingStage
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: Person.cpp:575
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:136
MSTransportable::WAITING_FOR_DEPART
Definition: MSTransportable.h:62
MSTransportable::getParameter
const SUMOVehicleParameter & getParameter() const
Definition: MSTransportable.h:603
MSVehicleControl.h
libsumo::Person::myContextSubscriptionResults
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Person.h:107
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
libsumo::Person::setParameter
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
Definition: Person.cpp:834
MSTransportable::replaceVehicleType
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
Definition: MSTransportable.cpp:790
MSNet::getVehicleControl
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:337
libsumo::Person::appendDrivingStage
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: Person.cpp:554
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204
libsumo::TraCIStage::cost
double cost
effort needed
Definition: TraCIDefs.h:362
libsumo::Person::convertTraCIStage
static MSTransportable::Stage * convertTraCIStage(const TraCIStage &stage, const std::string personID)
Definition: Person.cpp:459
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:488
PositionVector::move2side
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Definition: PositionVector.cpp:1086
MSVehicleType::setTau
void setTau(double tau)
Set a new value for this type's headway.
Definition: MSVehicleType.cpp:435
RGBColor::set
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition: RGBColor.cpp:80
MSVehicleType::setEmissionClass
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
Definition: MSVehicleType.cpp:238
MSVehicleType::setImperfection
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
Definition: MSVehicleType.cpp:426
MSNet::getPedestrianRouter
MSPedestrianRouter & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:985
libsumo::Person::getParameter
static std::string getParameter(const std::string &routeID, const std::string &param)
Definition: Person.cpp:249
MSTransportable::getSingularType
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
Definition: MSTransportable.cpp:799
MSTransportable::getCurrentStageDescription
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
Definition: MSTransportable.h:673
libsumo::Person::getAngle
static double getAngle(const std::string &personID)
Definition: Person.cpp:87