48#define FAR_AWAY 1000.0
64std::vector<std::string>
67 std::vector<std::string> ids;
70 ids.push_back(i->first);
84Person::getPosition(
const std::string& personID,
const bool includeZ) {
84Person::getPosition(
const std::string& personID,
const bool includeZ) {
…}
90Person::getPosition3D(
const std::string& personID) {
90Person::getPosition3D(
const std::string& personID) {
…}
96Person::getAngle(
const std::string& personID) {
96Person::getAngle(
const std::string& personID) {
…}
102Person::getSlope(
const std::string& personID) {
103 MSPerson* person = getPerson(personID);
105 const MSLane* lane = getSidewalk<MSEdge, MSLane>(person->
getEdge());
106 if (lane ==
nullptr) {
102Person::getSlope(
const std::string& personID) {
…}
115Person::getSpeed(
const std::string& personID) {
116 return getPerson(personID)->getSpeed();
115Person::getSpeed(
const std::string& personID) {
…}
121Person::getRoadID(
const std::string& personID) {
122 return getPerson(personID)->getEdge()->getID();
121Person::getRoadID(
const std::string& personID) {
…}
127Person::getLaneID(
const std::string& personID) {
127Person::getLaneID(
const std::string& personID) {
…}
133Person::getLanePosition(
const std::string& personID) {
134 return getPerson(personID)->getEdgePos();
133Person::getLanePosition(
const std::string& personID) {
…}
139Person::getWalkingDistance(
const std::string& personID,
const std::string& edgeID,
double pos,
int laneIndex) {
146 auto it = std::find(edges.begin(), edges.end(), &lane->
getEdge());
147 if (it == edges.end()) {
149 throw TraCIException(
TLF(
"Edge '%' does not occur within the remaining walk of person '%'.", edgeID, personID));
152 edges.erase(it + 1, edges.end());
156 if (distance == std::numeric_limits<double>::max()) {
162 throw TraCIException(
TLF(
"Person '%' is not walking", personID));
139Person::getWalkingDistance(
const std::string& personID,
const std::string& edgeID,
double pos,
int laneIndex) {
…}
168Person::getWalkingDistance2D(
const std::string& personID,
double x,
double y) {
171 return getWalkingDistance(personID, roadPos.first->getEdge().getID(), roadPos.second, roadPos.first->getIndex());
168Person::getWalkingDistance2D(
const std::string& personID,
double x,
double y) {
…}
176std::vector<TraCIReservation>
177Person::getTaxiReservations(
int onlyNew) {
178 std::vector<TraCIReservation> result;
180 if (dispatcher !=
nullptr) {
182 if (filterReservation(onlyNew, res, result)) {
189 if (includeRunning) {
191 filterReservation(onlyNew, res, result);
177Person::getTaxiReservations(
int onlyNew) {
…}
200Person::reservation_by_id_sorter::operator()(
const TraCIReservation& r1,
const TraCIReservation& r2)
const {
201 return r1.id < r2.id;
200Person::reservation_by_id_sorter::operator()(
const TraCIReservation& r1,
const TraCIReservation& r2)
const {
…}
206Person::splitTaxiReservation(std::string reservationID,
const std::vector<std::string>& personIDs) {
208 if (dispatcher !=
nullptr) {
210 if (traciDispatcher !=
nullptr) {
214 throw TraCIException(
"device.taxi.dispatch-algorithm 'traci' has not been loaded");
206Person::splitTaxiReservation(std::string reservationID,
const std::vector<std::string>& personIDs) {
…}
218Person::filterReservation(
int onlyNew,
const Reservation* res, std::vector<libsumo::TraCIReservation>& reservations) {
219 if (onlyNew != 0 && (onlyNew & res->
state) == 0) {
222 std::vector<std::string> personIDs;
224 personIDs.push_back(p->getID());
226 std::sort(personIDs.begin(), personIDs.end());
227 reservations.push_back(TraCIReservation(res->
id,
218Person::filterReservation(
int onlyNew,
const Reservation* res, std::vector<libsumo::TraCIReservation>& reservations) {
…}
243Person::getColor(
const std::string& personID) {
244 const RGBColor& col = getPerson(personID)->getParameter().color;
247 tcol.g = col.
green();
249 tcol.a = col.
alpha();
255Person::getTypeID(
const std::string& personID) {
256 return getPerson(personID)->getVehicleType().getID();
255Person::getTypeID(
const std::string& personID) {
…}
261Person::getWaitingTime(
const std::string& personID) {
262 return getPerson(personID)->getWaitingSeconds();
261Person::getWaitingTime(
const std::string& personID) {
…}
267Person::getNextEdge(
const std::string& personID) {
268 return getPerson(personID)->getNextEdge();
267Person::getNextEdge(
const std::string& personID) {
…}
272std::vector<std::string>
273Person::getEdges(
const std::string& personID,
int nextStageIndex) {
276 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
279 throw TraCIException(
"The negative stage index must refer to a valid previous stage.");
281 std::vector<std::string> edgeIDs;
284 edgeIDs.push_back(e->getID());
273Person::getEdges(
const std::string& personID,
int nextStageIndex) {
…}
292Person::getStage(
const std::string& personID,
int nextStageIndex) {
296 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
299 throw TraCIException(
"The negative stage index " +
toString(nextStageIndex) +
" must refer to a valid previous stage.");
307 result.edges.push_back(e->getID());
311 if (destinationStop !=
nullptr) {
312 result.destStop = destinationStop->
getID();
316 if (result.length == -1.) {
338 const std::set<std::string> lines = drivingStage->
getLines();
339 for (
auto line = lines.begin(); line != lines.end(); line++) {
340 if (line != lines.begin()) {
343 result.line += *line;
349 result.departPos = walkingStage->getDepartPos();
354 if (waitingStage->getPlannedDuration() > 0) {
355 result.travelTime =
STEPS2TIME(waitingStage->getPlannedDuration());
292Person::getStage(
const std::string& personID,
int nextStageIndex) {
…}
367Person::getRemainingStages(
const std::string& personID) {
368 return getPerson(personID)->getNumRemainingStages();
367Person::getRemainingStages(
const std::string& personID) {
…}
373Person::getVehicle(
const std::string& personID) {
374 const SUMOVehicle* veh = getPerson(personID)->getVehicle();
375 if (veh ==
nullptr) {
373Person::getVehicle(
const std::string& personID) {
…}
384Person::getParameter(
const std::string& personID,
const std::string& param) {
385 return getPerson(personID)->getParameter().getParameter(param,
"");
393Person::getEmissionClass(
const std::string& personID) {
399Person::getShapeClass(
const std::string& personID) {
405Person::getLength(
const std::string& personID) {
406 return getPerson(personID)->getVehicleType().getLength();
411Person::getSpeedFactor(
const std::string& personID) {
412 return getPerson(personID)->getChosenSpeedFactor();
417Person::getAccel(
const std::string& personID) {
418 return getPerson(personID)->getVehicleType().getCarFollowModel().getMaxAccel();
423Person::getDecel(
const std::string& personID) {
424 return getPerson(personID)->getVehicleType().getCarFollowModel().getMaxDecel();
428double Person::getEmergencyDecel(
const std::string& personID) {
429 return getPerson(personID)->getVehicleType().getCarFollowModel().getEmergencyDecel();
433double Person::getApparentDecel(
const std::string& personID) {
434 return getPerson(personID)->getVehicleType().getCarFollowModel().getApparentDecel();
438double Person::getActionStepLength(
const std::string& personID) {
439 return getPerson(personID)->getVehicleType().getActionStepLengthSecs();
444Person::getTau(
const std::string& personID) {
445 return getPerson(personID)->getVehicleType().getCarFollowModel().getHeadwayTime();
450Person::getImperfection(
const std::string& personID) {
451 return getPerson(personID)->getVehicleType().getCarFollowModel().getImperfection();
456Person::getSpeedDeviation(
const std::string& personID) {
457 return getPerson(personID)->getVehicleType().getSpeedFactor().getParameter(1);
462Person::getVehicleClass(
const std::string& personID) {
463 return toString(getPerson(personID)->getVehicleType().getVehicleClass());
468Person::getMinGap(
const std::string& personID) {
469 return getPerson(personID)->getVehicleType().getMinGap();
474Person::getMinGapLat(
const std::string& personID) {
475 return getPerson(personID)->getVehicleType().getMinGapLat();
480Person::getMaxSpeed(
const std::string& personID) {
481 return getPerson(personID)->getMaxSpeed();
486Person::getMaxSpeedLat(
const std::string& personID) {
487 return getPerson(personID)->getVehicleType().getMaxSpeedLat();
492Person::getLateralAlignment(
const std::string& personID) {
493 return toString(getPerson(personID)->getVehicleType().getPreferredLateralAlignment());
498Person::getWidth(
const std::string& personID) {
499 return getPerson(personID)->getVehicleType().getWidth();
504Person::getHeight(
const std::string& personID) {
505 return getPerson(personID)->getVehicleType().getHeight();
510Person::getMass(
const std::string& personID) {
511 return getPerson(personID)->getVehicleType().getMass();
516Person::getPersonCapacity(
const std::string& personID) {
517 return getPerson(personID)->getVehicleType().getPersonCapacity();
522Person::getBoardingDuration(
const std::string& personID) {
523 return STEPS2TIME(getPerson(personID)->getVehicleType().getBoardingDuration(
true));
528Person::getImpatience(
const std::string& personID) {
529 return getPerson(personID)->getImpatience();
534Person::setSpeed(
const std::string& personID,
double speed) {
535 getPerson(personID)->setSpeed(speed);
534Person::setSpeed(
const std::string& personID,
double speed) {
…}
540Person::setType(
const std::string& personID,
const std::string& typeID) {
542 if (vehicleType ==
nullptr) {
543 throw TraCIException(
"The vehicle type '" + typeID +
"' is not known.");
545 getPerson(personID)->replaceVehicleType(vehicleType);
540Person::setType(
const std::string& personID,
const std::string& typeID) {
…}
550Person::add(
const std::string& personID,
const std::string& edgeID,
double pos,
double departInSecs,
const std::string typeID) {
553 p = getPerson(personID);
554 }
catch (TraCIException&) {
559 throw TraCIException(
"The person " + personID +
" to add already exists.");
564 vehicleParams.
id = personID;
568 throw TraCIException(
"Invalid type '" + typeID +
"' for person '" + personID +
"'");
573 throw TraCIException(
"Invalid edge '" + edgeID +
"' for person: '" + personID +
"'");
576 if (departInSecs < 0.) {
577 const int proc = (int) - departInSecs;
579 throw TraCIException(
"Invalid departure time." +
toString(depart) +
" " +
toString(proc));
585 WRITE_WARNINGF(
TL(
"Departure time=% for person '%' is in the past; using current time=% instead."),
588 vehicleParams.
depart = depart;
593 throw TraCIException(
"Invalid departure position.");
602 plan->push_back(
new MSStageWaiting(edge,
nullptr, 0, depart, pos,
"awaiting departure",
true));
610 throw TraCIException(e.what());
550Person::add(
const std::string& personID,
const std::string& edgeID,
double pos,
double departInSecs,
const std::string typeID) {
…}
615Person::convertTraCIStage(
const TraCIStage& stage,
const std::string personID) {
617 if (!stage.destStop.empty()) {
620 throw TraCIException(
"Invalid stopping place id '" + stage.destStop +
"' for person: '" + personID +
"'");
623 switch (stage.type) {
625 if (stage.edges.empty()) {
626 throw TraCIException(
"The stage should have at least one edge");
628 std::string toId = stage.edges.back();
631 throw TraCIException(
"Invalid edge '" + toId +
"' for person: '" + personID +
"'");
638 if (stage.line.empty()) {
639 throw TraCIException(
"Empty lines parameter for person: '" + personID +
"'");
641 double arrivalPos = stage.arrivalPos;
658 throw TraCIException(e.what());
661 throw TraCIException(
"Empty edge list for walking stage of person '" + personID +
"'.");
663 double arrivalPos = stage.arrivalPos;
664 if (fabs(arrivalPos) > edges.back()->getLength()) {
665 throw TraCIException(
"Invalid arrivalPos for walking stage of person '" + personID +
"'.");
667 if (arrivalPos < 0) {
668 arrivalPos += edges.back()->getLength();
675 if (stage.travelTime < 0) {
676 throw TraCIException(
"Duration for person: '" + personID +
"' must not be negative");
686 throw TraCIException(e.what());
688 if ((edges.size() == 0 && bs ==
nullptr) || edges.size() > 1) {
689 throw TraCIException(
"A trip should be defined with a destination edge or a destination stop for person '" + personID +
"'.");
691 const MSEdge* to =
nullptr;
694 if (edges.size() > 0 && to != edges.back()) {
695 throw TraCIException(
"Mismatching destination edge and destination stop edge for person '" + personID +
"'.");
704 if (vType ==
nullptr) {
705 throw TraCIException(
"The vehicle type '" + vtypeid +
"' in a trip for person '" + personID +
"' is not known.");
709 if (stage.line.empty()) {
712 std::string errorMsg;
714 throw TraCIException(errorMsg);
718 double arrivalPos = stage.arrivalPos;
720 if (fabs(arrivalPos) > to->
getLength()) {
721 throw TraCIException(
"Invalid arrivalPos for walking stage of person '" + personID +
"'.");
723 if (arrivalPos < 0) {
729 std::string group = stage.intended;
731 const double speed = -1;
733 duration, modeSet, stage.vType, speed, walkfactor, group,
615Person::convertTraCIStage(
const TraCIStage& stage,
const std::string personID) {
…}
743Person::appendStage(
const std::string& personID,
const TraCIStage& stage) {
745 MSStage* personStage = convertTraCIStage(stage, personID);
743Person::appendStage(
const std::string& personID,
const TraCIStage& stage) {
…}
751Person::replaceStage(
const std::string& personID,
const int stageIndex,
const TraCIStage& stage) {
754 throw TraCIException(
"Specified stage index: is not valid for person " + personID);
756 MSStage* personStage = convertTraCIStage(stage, personID);
751Person::replaceStage(
const std::string& personID,
const int stageIndex,
const TraCIStage& stage) {
…}
765Person::appendDrivingStage(
const std::string& personID,
const std::string& toEdge,
const std::string& lines,
const std::string& stopID) {
769 throw TraCIException(
"Invalid edge '" + toEdge +
"' for person: '" + personID +
"'");
771 if (lines.size() == 0) {
772 throw TraCIException(
"Empty lines parameter for person: '" + personID +
"'");
778 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
765Person::appendDrivingStage(
const std::string& personID,
const std::string& toEdge,
const std::string& lines,
const std::string& stopID) {
…}
786Person::appendWaitingStage(
const std::string& personID,
double duration,
const std::string& description,
const std::string& stopID) {
789 throw TraCIException(
"Duration for person: '" + personID +
"' must not be negative");
795 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
786Person::appendWaitingStage(
const std::string& personID,
double duration,
const std::string& description,
const std::string& stopID) {
…}
803Person::appendWalkingStage(
const std::string& personID,
const std::vector<std::string>& edgeIDs,
double arrivalPos,
double duration,
double speed,
const std::string& stopID) {
809 throw TraCIException(e.what());
812 throw TraCIException(
"Empty edge list for walking stage of person '" + personID +
"'.");
814 if (fabs(arrivalPos) > edges.back()->getLength()) {
815 throw TraCIException(
"Invalid arrivalPos for walking stage of person '" + personID +
"'.");
817 if (arrivalPos < 0) {
818 arrivalPos += edges.back()->getLength();
824 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
803Person::appendWalkingStage(
const std::string& personID,
const std::vector<std::string>& edgeIDs,
double arrivalPos,
double duration,
double speed,
const std::string& stopID) {
…}
832Person::removeStage(
const std::string& personID,
int nextStageIndex) {
835 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
837 if (nextStageIndex < 0) {
838 throw TraCIException(
"The stage index may not be negative.");
832Person::removeStage(
const std::string& personID,
int nextStageIndex) {
…}
845Person::rerouteTraveltime(
const std::string& personID) {
848 throw TraCIException(
"Person '" + personID +
"' has no remaining stages.");
858 throw TraCIException(
"Person '" + personID +
"' cannot reroute after the current stop.");
864 int nextIndex = firstIndex + 1;
876 if (newEdges.empty()) {
877 throw TraCIException(
"Could not find new route for person '" + personID +
"'.");
880 assert(!oldEdges.empty());
882 oldEdges.erase(oldEdges.begin());
885 if (newEdges == oldEdges && (firstIndex + 1 == nextIndex)) {
888 if (newEdges.front() != from) {
890 newEdges.insert(newEdges.begin(), from);
892 p->
replaceWalk(newEdges, departPos, firstIndex, nextIndex);
845Person::rerouteTraveltime(
const std::string& personID) {
…}
897Person::moveTo(
const std::string& personID,
const std::string& laneID,
double pos,
double posLat) {
901 throw TraCIException(
"Unknown lane '" + laneID +
"'.");
907 throw TraCIException(
"Invalid lateral position " +
toString(posLat) +
" on lane '" + laneID +
"'.");
917 throw TraCIException(
"Command moveTo is not supported for person '" + personID +
"' while " + p->
getCurrentStageDescription() +
".");
897Person::moveTo(
const std::string& personID,
const std::string& laneID,
double pos,
double posLat) {
…}
923Person::moveToXY(
const std::string& personID,
const std::string& edgeID,
const double x,
const double y,
double angle,
const int keepRoute,
double matchThreshold) {
925 const bool doKeepRoute = (keepRoute & 1) != 0;
926 const bool mayLeaveNetwork = (keepRoute & 2) != 0;
927 const bool ignorePermissions = (keepRoute & 4) != 0;
931 const double origAngle = angle;
936 while (angle >= 360.) {
945 std::cout <<
" want pos:" << pos <<
" edgeID:" << edgeID <<
" origAngle:" << origAngle <<
" angle:" << angle <<
" keepRoute:" << keepRoute << std::endl;
951 double lanePosLat = 0;
952 double bestDistance = std::numeric_limits<double>::max();
955 double maxRouteDistance = matchThreshold;
977 ev, routeIndex, vClass,
true,
978 bestDistance, &lane, lanePos, routeOffset);
979 if (bestDistance > maxRouteDistance) {
986 speed, ev, routeIndex, currentLane, p->
getEdgePos(), currentLane !=
nullptr,
988 bestDistance, &lane, lanePos, routeOffset, edges);
989 if (edges.size() != 0 && ev.size() > 1) {
992 assert(lane !=
nullptr);
995 if (routeIndex == 0) {
1002 if (origEdge->
getToJunction() == ev[routeIndex - 1]->getToJunction() || origEdge->
getToJunction() == ev[routeIndex - 1]->getFromJunction()) {
1012 const MSEdge* newEdge = edges[0];
1013 if (edges[0]->getFromJunction() == originalTarget || edges[0]->getToJunction() == originalTarget) {
1015 edges[routeIndex] = newEdge;
1019 if (found || mayLeaveNetwork) {
1024 lanePosLat = perpDist;
1025 if (!mayLeaveNetwork) {
1037 lanePosLat = -lanePosLat;
1045 assert((found && lane !=
nullptr) || (!found && lane ==
nullptr));
1076 throw TraCIException(
"Command moveToXY is not supported for person '" + personID +
"' while " + p->
getCurrentStageDescription() +
".");
1080 if (lane ==
nullptr) {
1081 throw TraCIException(
"Could not map person '" + personID +
"' no road found within " +
toString(maxRouteDistance) +
"m.");
1083 throw TraCIException(
"Could not map person '" + personID +
"' distance to road is " +
toString(bestDistance) +
".");
923Person::moveToXY(
const std::string& personID,
const std::string& edgeID,
const double x,
const double y,
double angle,
const int keepRoute,
double matchThreshold) {
…}
1092Person::setParameter(
const std::string& personID,
const std::string& key,
const std::string& value) {
1095 throw TraCIException(
"Person '" + personID +
"' does not support device parameters\n");
1097 throw TraCIException(
"Person '" + personID +
"' does not support laneChangeModel parameters\n");
1099 throw TraCIException(
"Person '" + personID +
"' does not support carFollowModel parameters\n");
1106 throw TraCIException(e.what());
1109 throw TraCIException(
"Person '" + personID +
"' does not support chanigng device status\n");
1117Person::setLength(
const std::string& personID,
double length) {
1118 getPerson(personID)->getSingularType().setLength(length);
1123Person::setMaxSpeed(
const std::string& personID,
double speed) {
1124 getPerson(personID)->getSingularType().setMaxSpeed(speed);
1129Person::setVehicleClass(
const std::string& personID,
const std::string& clazz) {
1135Person::setShapeClass(
const std::string& personID,
const std::string& clazz) {
1141Person::setEmissionClass(
const std::string& personID,
const std::string& clazz) {
1147Person::setWidth(
const std::string& personID,
double width) {
1148 getPerson(personID)->getSingularType().setWidth(width);
1153Person::setHeight(
const std::string& personID,
double height) {
1154 getPerson(personID)->getSingularType().setHeight(height);
1159Person::setMass(
const std::string& personID,
double mass) {
1160 getPerson(personID)->getSingularType().setMass(mass);
1165Person::setMinGap(
const std::string& personID,
double minGap) {
1166 getPerson(personID)->getSingularType().setMinGap(minGap);
1171Person::setAccel(
const std::string& personID,
double accel) {
1172 getPerson(personID)->getSingularType().setAccel(accel);
1177Person::setDecel(
const std::string& personID,
double decel) {
1178 getPerson(personID)->getSingularType().setDecel(decel);
1183Person::setEmergencyDecel(
const std::string& personID,
double decel) {
1184 getPerson(personID)->getSingularType().setEmergencyDecel(decel);
1189Person::setApparentDecel(
const std::string& personID,
double decel) {
1190 getPerson(personID)->getSingularType().setApparentDecel(decel);
1195Person::setImperfection(
const std::string& personID,
double imperfection) {
1196 getPerson(personID)->getSingularType().setImperfection(imperfection);
1201Person::setBoardingDuration(
const std::string& personID,
double boardingDuration) {
1207Person::setImpatience(
const std::string& personID,
double impatience) {
1214Person::setTau(
const std::string& personID,
double tau) {
1215 getPerson(personID)->getSingularType().setTau(tau);
1220Person::setMinGapLat(
const std::string& personID,
double minGapLat) {
1221 getPerson(personID)->getSingularType().setMinGapLat(minGapLat);
1226Person::setMaxSpeedLat(
const std::string& personID,
double speed) {
1227 getPerson(personID)->getSingularType().setMaxSpeedLat(speed);
1232Person::setLateralAlignment(
const std::string& personID,
const std::string& latAlignment) {
1236 getPerson(personID)->getSingularType().setPreferredLateralAlignment(lad, lao);
1238 throw TraCIException(
"Unknown value '" + latAlignment +
"' when setting latAlignment for person '" + personID +
"';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
1244Person::setSpeedFactor(
const std::string& personID,
double factor) {
1245 getPerson(personID)->setChosenSpeedFactor(factor);
1250Person::setActionStepLength(
const std::string& personID,
double actionStepLength,
bool resetActionOffset) {
1255Person::remove(
const std::string& personID,
char ) {
1256 MSPerson* person = getPerson(personID);
1255Person::remove(
const std::string& personID,
char ) {
…}
1266Person::setColor(
const std::string& personID,
const TraCIColor& c) {
1268 p.
color.
set((
unsigned char)c.r, (
unsigned char)c.g, (
unsigned char)c.b, (
unsigned char)c.a);
1277Person::getPerson(
const std::string& personID) {
1277Person::getPerson(
const std::string& personID) {
…}
1284 shape.push_back(getPerson(
id)->getPosition());
1288std::shared_ptr<VariableWrapper>
1289Person::makeWrapper() {
1290 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
1289Person::makeWrapper() {
…}
1295Person::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
1298 return wrapper->wrapStringList(objID, variable, getIDList());
1300 return wrapper->wrapInt(objID, variable, getIDCount());
1302 return wrapper->wrapPosition(objID, variable, getPosition(objID));
1304 return wrapper->wrapPosition(objID, variable, getPosition(objID,
true));
1306 return wrapper->wrapDouble(objID, variable, getAngle(objID));
1308 return wrapper->wrapDouble(objID, variable, getSlope(objID));
1310 return wrapper->wrapDouble(objID, variable, getSpeed(objID));
1312 return wrapper->wrapString(objID, variable, getRoadID(objID));
1314 return wrapper->wrapString(objID, variable, getLaneID(objID));
1316 return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
1318 return wrapper->wrapColor(objID, variable, getColor(objID));
1320 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
1322 return wrapper->wrapDouble(objID, variable, getImpatience(objID));
1324 return wrapper->wrapString(objID, variable, getTypeID(objID));
1326 return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
1328 return wrapper->wrapString(objID, variable, getNextEdge(objID));
1330 return wrapper->wrapStringList(objID, variable, getEdges(objID,
StoHelp::readTypedInt(*paramData)));
1334 return wrapper->wrapInt(objID, variable, getRemainingStages(objID));
1336 return wrapper->wrapString(objID, variable, getVehicle(objID));
1339 return wrapper->wrapDouble(objID, variable, getMaxSpeed(objID));
1341 TraCIRoadPosition roadPos;
1344 return wrapper->wrapDouble(objID, variable, getWalkingDistance(objID, roadPos.edgeID, roadPos.pos, roadPos.laneIndex));
1346 return wrapper->wrapDouble(objID, variable, getWalkingDistance2D(objID, pos.
x(), pos.
y()));
1353 return wrapper->wrapReservationVector(objID, variable, getTaxiReservations(
StoHelp::readTypedInt(*paramData)));
1357 return libsumo::VehicleType::handleVariable(getTypeID(objID), variable, wrapper, paramData);
1295Person::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
…}
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ GIVEN
The position is given.
const long long int VEHPARS_COLOR_SET
DepartDefinition
Possible ways to depart.
@ DEF_MAX
Tag for the last element in the enum for safe int casting.
@ SUMO_TAG_BUS_STOP
A bus stop.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
static double naviDegree(const double angle)
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
static MSDispatch * getDispatchAlgorithm()
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
std::string splitReservation(std::string resID, std::vector< std::string > personIDs)
split existing reservations and return the new reservation id
An algorithm that performs distpach for a taxi fleet.
std::vector< Reservation * > getReservations()
retrieve all reservations
virtual std::vector< const Reservation * > getRunningReservations()
retrieve all reservations that were already dispatched and are still active
A road/street connecting two junctions.
bool isWalkingArea() const
return whether this edge is walking area
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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.
bool isNormal() const
return whether this edge is an internal edge
const MSJunction * getToJunction() const
double getLength() const
return the length of the edge
const MSJunction * getFromJunction() const
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....
static double gLateralResolution
The base class for an intersection.
Representation of a lane in the micro simulation.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
double interpolateLanePosToGeometryPos(double lanePos) const
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
double getWidth() const
Returns the lane's width.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSPedestrianRouter & getPedestrianRouter(int rngIndex, const Prohibitions &prohibited={}) const
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
static const double UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
void replaceWalk(const ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex,...
SUMOTime getIntendedDepart() const
std::string getIntendedVehicleID() const
const std::set< std::string > & getLines() const
std::string getVehicleType() const
const MSEdge * getDestination() const
returns the destination edge
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
virtual double getArrivalPos() const
SUMOTime getDeparted() const
get departure time of stage
virtual std::string getStageDescription(const bool isPerson) const =0
return (brief) string representation of the current stage
SUMOTime getArrived() const
get arrival time of stage
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
MSStageType getStageType() const
virtual double getDistance() const =0
get travel distance in this stage
ConstMSEdgeVector getEdges() const
the edges of the current stage
const std::vector< const MSEdge * > & getRoute() const
MSTransportableStateAdapter * getPState() const
const std::vector< constMSEdge * >::iterator getRouteStep() const
int getRoutePosition() const
return index of current edge within route
A lane area vehicles can halt at.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
int size() const
Returns the number of known transportables.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, SumoRNG *rng) const
Builds a new person.
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occurred.
virtual double getEdgePos() const
Return the position on the edge.
SUMOVehicleClass getVClass() const
Returns the object's access class.
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
virtual double getAngle() const
return the current angle of the transportable
const MSEdge * getArrivalEdge() const
returns the final arrival edge
MSStageType getStageType(int next) const
the stage type for the nth next stage
MSStage * getNextStage(int offset) const
Return the next (or previous) stage denoted by the offset.
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
MSStage * getCurrentStage() const
Return the current stage.
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
bool isPerson() const
Whether it is a person.
Position getPosition(const double) const
Return current position (x/y, cartesian)
double getArrivalPos() const
returns the final arrival pos
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
int getNumStages() const
Return the total number stages in this person's plan.
MSStageType getCurrentStageType() const
the current stage type of the transportable
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSEdge * getEdge() const
Returns the current edge.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical maximum speed)
virtual void moveTo(MSPerson *p, MSLane *lane, double lanePos, double lanePosLat, SUMOTime t)
try to move transportable to the given position
The class responsible for building and deletion of vehicles.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setBoardingDuration(SUMOTime duration, bool isPerson=true)
Set a new value for this type's boardingDuration.
void setImpatience(const double impatience)
Set a new value for this type's impatience.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
double recomputeWalkCosts(const std::vector< const E * > &edges, double speed, double fromPos, double toPos, SUMOTime msTime, double &length) const
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) const
Builds the route between the given edges using the minimum effort at the given time The definition of...
C++ TraCI client API implementation.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
double y() const
Returns the y-position.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
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)
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
unsigned char red() const
Returns the red-amount of the color.
unsigned char alpha() const
Returns the alpha-amount of the color.
unsigned char green() const
Returns the green-amount of the color.
unsigned char blue() const
Returns the blue-amount of the color.
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
Representation of a vehicle.
Structure representing possible vehicle parameter.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
SVCPermissions modes
The modes a person or container can use.
double departPos
(optional) The position the vehicle shall depart from
RGBColor color
The vehicle's color, TraCI may change this.
std::string id
The vehicle's id.
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
std::vector< std::string > getVector()
return vector of strings
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
static MSPerson * getPerson(const std::string &id)
static int readDistanceRequest(tcpip::Storage &data, TraCIRoadPosition &roadPos, Position &pos)
static MSBaseVehicle * getVehicle(const std::string &id)
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
static bool moveToXYMap(const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector ¤tRoute, const int routePosition, const MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, double currentAngle, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int VAR_EDGES
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int STAGE_TRIP
TRACI_CONST int VAR_VEHICLE
TRACI_CONST int VAR_WAITING_TIME
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int VAR_TAXI_RESERVATIONS
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_STAGE
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int STAGE_WAITING
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int STAGE_WALKING
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_NEXT_EDGE
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int STAGE_DRIVING
TRACI_CONST int VAR_STAGES_REMAINING
TRACI_CONST int SPLIT_TAXI_RESERVATIONS
std::set< const MSTransportable * > persons