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