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