72#define FAR_AWAY 1000.0
100 std::cout <<
" '" << veh->
getID() <<
"' on lane '" << ((
SUMOVehicle*)veh)->getLane()->getID() <<
"'\n";
102 std::cout <<
" '" << veh->
getID() <<
"' on edge '" << veh->
getEdge()->
getID() <<
"'\n";
111 const int contextDomain,
const double range) {
112 if (variables.empty()) {
114 if (j->id ==
id && j->commandId == commandId && j->contextDomain == contextDomain) {
123 std::vector<std::shared_ptr<tcpip::Storage> > parameters;
124 for (
const int var : variables) {
125 const auto& p = params.find(var);
126 if (p == params.end()) {
127 parameters.push_back(std::make_shared<tcpip::Storage>());
136 s.
range = std::numeric_limits<double>::max();
139 if (contextDomain == 0) {
143 s.
parameters.push_back(std::make_shared<tcpip::Storage>());
174 wrapper.second->clear();
183 if (s.
endTime < t || isArrivedVehicle || isArrivedPerson) {
190 if (s.beginTime <= t) {
203 std::vector<std::shared_ptr<tcpip::Storage> >::const_iterator k = s.
parameters.begin();
205 const int offset = (int)(std::find(o.variables.begin(), o.variables.end(), v) - o.variables.begin());
206 if (offset == (
int)o.variables.size() || o.parameters[offset]->size() != (*k)->size() || !std::equal((*k)->begin(), (*k)->end(), o.parameters[offset]->begin())) {
207 o.variables.push_back(v);
208 o.parameters.push_back(*k);
212 modifiedSubscription = &o;
216 subscriptions.push_back(s);
217 modifiedSubscription = &subscriptions.back();
222std::vector<Subscription>::iterator
224 std::vector<Subscription>::iterator position,
Subscription*& lastContextSubscription) {
225 const auto removedIndex = position - subscriptions.begin();
226 const auto contextIndex = lastContextSubscription ==
nullptr
227 ? -1 : lastContextSubscription - subscriptions.data();
228 if (contextIndex == removedIndex) {
229 lastContextSubscription =
nullptr;
231 auto next = subscriptions.erase(position);
232 if (contextIndex > removedIndex) {
234 lastContextSubscription = &subscriptions[contextIndex - 1];
243 wrapper.second->clear();
258 int index = (int)filter;
262 while (index >>= 1) {
266 throw TraCIException(
"No previous vehicle context subscription exists to apply filter type " +
toHex(filterType, 2));
275 std::set<std::string> objIDs;
291#ifdef HAVE_LIBSUMOGUI
314 auto wrapper =
myWrapper.find(getCommandId);
318 std::shared_ptr<VariableWrapper> handler = wrapper->second;
322 if (containerWrapper ==
myWrapper.end()) {
325 container = containerWrapper->second.get();
330 for (
const std::string& objID : objIDs) {
332 std::vector<std::shared_ptr<tcpip::Storage> >::const_iterator k = s.
parameters.begin();
335 container->
empty(objID);
339 if (!handler->handle(objID, variable, container, k->get())) {
342 }
catch (
const std::invalid_argument&) {
350 container->
empty(objID);
357Helper::fuseLaneCoverage(std::shared_ptr<LaneCoverageInfo> aggregatedLaneCoverage,
const std::shared_ptr<LaneCoverageInfo> newLaneCoverage) {
358 for (
auto& p : *newLaneCoverage) {
359 const MSLane* lane = p.first;
360 if (aggregatedLaneCoverage->find(lane) == aggregatedLaneCoverage->end()) {
362 (*aggregatedLaneCoverage)[lane] = (*newLaneCoverage)[lane];
365 std::pair<double, double>& range1 = (*aggregatedLaneCoverage)[lane];
366 std::pair<double, double>& range2 = (*newLaneCoverage)[lane];
367 std::pair<double, double> hull = std::make_pair(
MIN2(range1.first, range2.first),
MAX2(range1.second, range2.second));
368 (*aggregatedLaneCoverage)[lane] = hull;
377 for (
int i = 0; i < (int)positionVector.size(); ++i) {
388 if (std::isnan(pos.x) || std::isnan(pos.y)) {
391 pv.push_back(
Position(pos.x, pos.y));
410 return RGBColor((
unsigned char)c.
r, (
unsigned char)c.
g, (
unsigned char)c.
b, (
unsigned char)c.
a);
433 if (edge ==
nullptr) {
434 throw TraCIException(
"Referenced edge '" + edgeID +
"' is not known.");
443 if (edge ==
nullptr) {
446 if (laneIndex < 0 || laneIndex >= (
int)edge->
getLanes().size()) {
450 if (pos < 0 || pos > lane->
getLength()) {
457std::pair<MSLane*, double>
460 std::pair<MSLane*, double> result(
nullptr, -1);
461 double range = 1000.;
464 while (range < maxRange) {
465 std::set<const Named*> lanes;
467 double minDistance = std::numeric_limits<double>::max();
468 for (
const Named* named : lanes) {
474 if (newDistance < minDistance ||
475 (newDistance == minDistance
476 && result.first !=
nullptr
477 && lane->
getID() < result.first->getID())) {
478 minDistance = newDistance;
483 if (minDistance < std::numeric_limits<double>::max()) {
495 if (roadPos1.first == roadPos2.first && roadPos1.second <= roadPos2.second) {
497 return roadPos2.second - roadPos1.second;
499 double distance = 0.0;
501 while (roadPos2.first->isInternal() && roadPos2.first != roadPos1.first) {
502 distance += roadPos2.second;
503 roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
504 roadPos2.second = roadPos2.first->getLength();
507 if (newRoute.empty()) {
511 return distance + route.
getDistanceBetween(roadPos1.second, roadPos2.second, roadPos1.first, roadPos2.first);
518 if (sumoVehicle ==
nullptr) {
523 throw TraCIException(
"Vehicle '" +
id +
"' is not a proper vehicle.");
577 double pos,
int laneIndex,
double startPos,
int flags,
double duration,
double until) {
583 throw TraCIException(
"Duration or until parameter exceed the time value range.");
591 if (newStop.
until >= 0) {
594 if ((flags & 1) != 0) {
598 if ((flags & 2) != 0) {
602 if ((flags & 4) != 0) {
608 if ((flags & 8) != 0) {
611 if ((flags & 16) != 0) {
614 if ((flags & 32) != 0) {
617 if ((flags & 64) != 0) {
620 if ((flags & 128) != 0) {
627 throw TraCIException(
"The " +
toString(stoppingPlaceType) +
" '" + edgeOrStoppingPlaceID +
"' is not known");
633 switch (stoppingPlaceType) {
635 newStop.
busstop = edgeOrStoppingPlaceID;
654 startPos =
MAX2(0.0, pos - POSITION_EPS);
659 if (pos < startPos) {
660 throw TraCIException(
"End position on lane must be after start position.");
664 if (road ==
nullptr) {
665 throw TraCIException(
"Edge '" + edgeOrStoppingPlaceID +
"' is not known.");
667 const std::vector<MSLane*>& allLanes = road->
getLanes();
668 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
669 throw TraCIException(
"No lane with index '" +
toString(laneIndex) +
"' on edge '" + edgeOrStoppingPlaceID +
"'.");
671 newStop.
lane = allLanes[laneIndex]->getID();
672 newStop.
edge = allLanes[laneIndex]->getEdge().getID();
683 std::string stoppingPlaceID =
"";
685 stoppingPlaceID = stopPar.
busstop;
724 InductionLoop::cleanup();
747const std::vector<std::string>&
753const std::vector<std::string>&
790 MSCalibrator*
const calib = Calibrator::getCalibrator(
id);
801 Edge::storeShape(
id, shape);
804 InductionLoop::storeShape(
id, shape);
807 Junction::storeShape(
id, shape);
810 Lane::storeShape(
id, shape);
813 LaneArea::storeShape(
id, shape);
818 shape.push_back(cs.myLane->getShape().positionAtOffset(cs.myPosition));
821 shape.push_back(cs.myLane->getShape().positionAtOffset(cs.myPosition));
832 Person::storeShape(
id, shape);
835 POI::storeShape(
id, shape);
838 Polygon::storeShape(
id, shape);
841 Vehicle::storeShape(
id, shape);
844 Simulation::storeShape(shape);
852 std::set<const Named*> objects;
854 for (
const Named* obj : objects) {
855 into.insert(obj->getID());
863 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
864 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
868 if (shape.
distance2D(stop.second->getCenterPos()) <= range) {
869 into.insert(stop.second);
875 if (shape.
distance2D(stop.second->getCenterPos()) <= range) {
876 into.insert(stop.second);
882 if (shape.
distance2D(calib.second->getLane()->getShape()[0]) <= range) {
883 into.insert(calib.second);
898 if (shape.
distance2D(stop.second->getCenterPos()) <= range) {
899 into.insert(stop.second);
932#ifdef DEBUG_SURROUNDING
934 std::cout <<
SIMTIME <<
" applySubscriptionFilters for vehicle '" << _veh->
getID() <<
"' on lane '" << _veh->
getLane()->
getID() <<
"'"
936 <<
"objIDs = " <<
toString(objIDs) << std::endl;
951 WRITE_WARNINGF(
TL(
"Ignoring veh '%' no-opposite subscription filter for geographic range object collection. Consider using the 'lanes' filter."), v->
getID())
955 std::set<const SUMOTrafficObject*> vehs;
958 double downstreamDist = s.
range, upstreamDist = s.
range, lateralDist = s.
range;
972 throw TraCIException(
"Subscription filter not yet implemented for meso vehicle");
978 if (vehLane ==
nullptr) {
982 std::vector<int> filterLanes;
993#ifdef DEBUG_SURROUNDING
994 std::cout <<
"Filter lanes: " <<
toString(filterLanes) << std::endl;
995 std::cout <<
"Downstream distance: " << downstreamDist << std::endl;
996 std::cout <<
"Upstream distance: " << upstreamDist << std::endl;
997 std::cout <<
"Lateral distance: " << lateralDist << std::endl;
1004 for (
int offset : filterLanes) {
1006 if (lane !=
nullptr) {
1011 vehs.insert(vehs.end(), leader);
1012 vehs.insert(vehs.end(), follower);
1014#ifdef DEBUG_SURROUNDING
1015 std::cout <<
"Lane at index " << offset <<
": '" << lane->
getID() << std::endl;
1016 std::cout <<
"Leader: '" << (leader !=
nullptr ? leader->
getID() :
"NULL") <<
"'" << std::endl;
1017 std::cout <<
"Follower: '" << (follower !=
nullptr ? follower->
getID() :
"NULL") <<
"'" << std::endl;
1020 }
else if (!disregardOppositeDirection && offset > 0) {
1023 if (opposite ==
nullptr) {
1024#ifdef DEBUG_SURROUNDING
1025 std::cout <<
"No lane at index " << offset << std::endl;
1031 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
1032 if (ix_opposite < 0) {
1033#ifdef DEBUG_SURROUNDING
1034 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
1039 lane = opposite->
getLanes()[ix_opposite];
1046 vehs.insert(vehs.end(), lane->
getLeader(v, posOnOpposite - v->
getLength(), std::vector<MSLane*>()).first);
1060#ifdef DEBUG_SURROUNDING
1061 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
1062 for (
auto veh : vehs) {
1074 if (veh !=
nullptr) {
1075 objIDs.insert(objIDs.end(), veh->getID());
1082 auto i = objIDs.begin();
1083 while (i != objIDs.end()) {
1086 i = objIDs.erase(i);
1094 auto i = objIDs.begin();
1095 while (i != objIDs.end()) {
1098 i = objIDs.erase(i);
1112 double upstreamDist,
bool disregardOppositeDirection) {
1117 assert(filterLanes.size() > 0);
1122 auto checkedLanesInDrivingDir = std::make_shared<LaneCoverageInfo>();
1123 for (
int offset : filterLanes) {
1125 if (lane !=
nullptr) {
1126#ifdef DEBUG_SURROUNDING
1127 std::cout <<
"Checking for surrounding vehicles starting on lane '" << lane->
getID() <<
"' at index " << offset << std::endl;
1132 std::shared_ptr<LaneCoverageInfo> checkedLanes = std::make_shared<LaneCoverageInfo>();
1133 const std::set<MSVehicle*> new_vehs =
1135 vehs.insert(new_vehs.begin(), new_vehs.end());
1137 }
else if (!disregardOppositeDirection && offset > 0) {
1141 if (opposite ==
nullptr) {
1142#ifdef DEBUG_SURROUNDING
1143 std::cout <<
"No opposite edge, thus no lane at index " << offset << std::endl;
1149 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
1150 if (ix_opposite < 0) {
1151#ifdef DEBUG_SURROUNDING
1152 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
1157 lane = opposite->
getLanes()[ix_opposite];
1160 downstreamDist, std::make_shared<LaneCoverageInfo>());
1161 vehs.insert(new_vehs.begin(), new_vehs.end());
1163#ifdef DEBUG_SURROUNDING
1165 std::cout <<
"No lane at index " << offset << std::endl;
1169 if (!disregardOppositeDirection) {
1176 const int nOpp =
MAX2(0, (*std::max_element(filterLanes.begin(), filterLanes.end())) - ((
int)vehEdge->
getLanes().size() - 1 - vehLane->
getIndex()));
1179 for (
auto& laneCov : *checkedLanesInDrivingDir) {
1180 const MSLane*
const l = laneCov.first;
1185 const std::pair<double, double>& range = laneCov.second;
1186 auto leftMostOppositeLaneIt = opposite->
getLanes().rbegin();
1187 for (
auto oppositeLaneIt = leftMostOppositeLaneIt; oppositeLaneIt != opposite->
getLanes().rend(); ++oppositeLaneIt) {
1188 if ((
int)(oppositeLaneIt - leftMostOppositeLaneIt) == nOpp) {
1192 const MSLane* oppositeLane = *oppositeLaneIt;
1194 vehs.insert(new_vehs.begin(), new_vehs.end());
1199#ifdef DEBUG_SURROUNDING
1200 std::cout <<
SIMTIME <<
" applySubscriptionFilterLanes() for veh '" << v->
getID() <<
"', lane offset '" << offset <<
"'. Found the following vehicles so far:\n";
1201 for (
auto veh : vehs) {
1218#ifdef DEBUG_SURROUNDING
1219 std::cout <<
"Applying turn filter for vehicle '" << v->
getID() <<
"'\n Gathering foes ..." << std::endl;
1222 for (
auto& l : links) {
1223#ifdef DEBUG_SURROUNDING
1224 std::cout <<
" On junction '" << l->getJunction()->getID() <<
"' (no. foe links = " << l->getFoeLinks().size() <<
"):" << std::endl;
1226 for (
auto& foeLane : l->getFoeLanes()) {
1227 if (foeLane->isCrossing()) {
1228#ifdef DEBUG_SURROUNDING
1229 std::cout <<
" skipping crossing foeLane '" << foeLane->getID() <<
"'" << std::endl;
1233#ifdef DEBUG_SURROUNDING
1234 std::cout <<
" foeLane '" << foeLane->getID() <<
"'" << std::endl;
1237 const MSLink* foeLink = foeLane->getEntryLink();
1240#ifdef DEBUG_SURROUNDING
1241 std::cout <<
" Approaching foeLane entry link '" << vi.first->getID() <<
"'" << std::endl;
1243 vehs.insert(vehs.end(),
dynamic_cast<const MSVehicle*
>(vi.first));
1247 for (
const MSVehicle* foe : foeLane->getVehiclesSecure()) {
1248#ifdef DEBUG_SURROUNDING
1249 std::cout <<
" On foeLane '" << foe->getID() <<
"'" << std::endl;
1251 vehs.insert(vehs.end(), foe);
1253 foeLane->releaseVehicles();
1254 for (
auto& laneInfo : foeLane->getIncomingLanes()) {
1255 const MSLane* foeLanePred = laneInfo.lane;
1257#ifdef DEBUG_SURROUNDING
1258 std::cout <<
" foeLanePred '" << foeLanePred->
getID() <<
"'" << std::endl;
1261#ifdef DEBUG_SURROUNDING
1262 std::cout <<
" On foeLanePred '" << foe->getID() <<
"'" << std::endl;
1264 vehs.insert(vehs.end(), foe);
1284#ifdef DEBUG_SURROUNDING
1285 std::cout <<
"FOVFILTER: ego direction = " <<
toString(
RAD2DEG(egoVehicle->
getAngle())) <<
" (deg)" << std::endl;
1288 auto i = objIDs.begin();
1289 while (i != objIDs.end()) {
1290 if (s.
id.compare(*i) == 0) {
1298#ifdef DEBUG_SURROUNDING
1301 std::cout <<
"FOVFILTER: " << objType <<
" '" << *i <<
"' alpha = " <<
toString(
RAD2DEG(alpha)) <<
" (deg)" << std::endl;
1304 if (abs(alpha) > openingAngle * 0.5) {
1305 i = objIDs.erase(i);
1314 double lateralDist) {
1318 double range =
MAX3(downstreamDist, upstreamDist, lateralDist);
1319 std::set<std::string> objIDs;
1322#ifdef DEBUG_SURROUNDING
1323 std::cout <<
"FILTER_LATERAL_DIST: collected object IDs (range " << range <<
"):" << std::endl;
1324 for (std::string i : objIDs) {
1325 std::cout << i << std::endl;
1330#ifdef DEBUG_SURROUNDING
1348 std::set<const SUMOTrafficObject*>& vehs,
1349 const std::vector<const MSLane*>& lanes,
double posOnLane,
double posLat,
bool isDownstream) {
1351 double distRemaining = streamDist;
1352 bool isFirstLane =
true;
1354 for (
const MSLane* lane : lanes) {
1355#ifdef DEBUG_SURROUNDING
1356 std::cout <<
"FILTER_LATERAL_DIST: current lane " << (isDownstream ?
"down" :
"up") <<
" is '" << lane->getID() <<
"', length " << lane->getLength()
1357 <<
", pos " << posOnLane <<
", distRemaining " << distRemaining << std::endl;
1361 isFirstLane =
false;
1362 double geometryPos = lane->interpolateLanePosToGeometryPos(posOnLane);
1363 if (geometryPos <= POSITION_EPS) {
1364 if (!isDownstream) {
1368 if (geometryPos >= laneShape.
length() - POSITION_EPS) {
1371 auto pair = laneShape.
splitAt(geometryPos,
false);
1372 laneShape = isDownstream ? pair.second : pair.first;
1376 double laneLength = lane->interpolateGeometryPosToLanePos(laneShape.
length());
1377 if (distRemaining - laneLength < 0.) {
1378 double geometryPos = lane->interpolateLanePosToGeometryPos(isDownstream ? distRemaining : laneLength - distRemaining);
1379 if (geometryPos > POSITION_EPS && geometryPos < laneShape.
length() - POSITION_EPS) {
1380 auto pair = laneShape.
splitAt(geometryPos,
false);
1381 laneShape = isDownstream ? pair.first : pair.second;
1384 distRemaining -= laneLength;
1388 WRITE_WARNINGF(
TL(
"addSubscriptionFilterLateralDistance could not determine shape of lane '%' with a lateral shift of %."),
1391#ifdef DEBUG_SURROUNDING
1392 std::cout <<
" posLat=" << posLat <<
" laneShape=" << laneShape <<
"\n";
1395 combinedShape.
append(laneShape);
1397 combinedShape.
prepend(laneShape);
1399 if (distRemaining <= POSITION_EPS) {
1403#ifdef DEBUG_SURROUNDING
1404 std::cout <<
" combinedShape=" << combinedShape <<
"\n";
1407 auto i = objIDs.begin();
1408 while (i != objIDs.end()) {
1411#ifdef DEBUG_SURROUNDING
1412 std::cout << (isDownstream ?
"DOWN" :
"UP") <<
" obj " << obj->
getID() <<
" perpendicular dist=" << minPerpendicularDist <<
" filterLateralDist=" << s.
filterLateralDist <<
"\n";
1416 i = objIDs.erase(i);
1440 int numControlled = 0;
1443 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
1446 WRITE_WARNINGF(
TL(
"Vehicle '%' was removed though being controlled by TraCI"), controlled.first);
1452 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
1455 WRITE_WARNINGF(
TL(
"Person '%' was removed though being controlled by TraCI"), controlled.first);
1459 return numControlled;
1465 double speed,
const ConstMSEdgeVector& currentRoute,
const int routePosition,
const MSLane* currentLane,
double currentLanePos,
bool onRoad,
1470 std::cout <<
SIMTIME <<
" moveToXYMap pos=" << pos <<
" angle=" << angle <<
" vClass=" <<
toString(vClass) <<
"\n";
1472 const MSEdge*
const currentRouteEdge = currentRoute[routePosition];
1473 std::set<const Named*> into;
1475 shape.push_back(pos);
1478 std::map<MSLane*, LaneUtility, ComparatorNumericalIdLess> lane2utility;
1480 for (
const Named* namedEdge : into) {
1481 const MSEdge* e =
dynamic_cast<const MSEdge*
>(namedEdge);
1485 const MSEdge* prevEdge =
nullptr;
1486 const MSEdge* nextEdge =
nullptr;
1487 bool onRoute =
false;
1488 bool useCurrentAngle =
false;
1494 for (
int i = routePosition; i < (int)currentRoute.size(); i++) {
1495 const MSEdge* cand = currentRoute[i];
1498 if (i + 1 < (
int)currentRoute.size()) {
1500 nextEdge = currentRoute[i + 1];
1507 for (
int i = routePosition - 1; i >= 0; i--) {
1508 const MSEdge* cand = currentRoute[i];
1512 nextEdge = currentRoute[i + 1];
1517 if (prevEdge ==
nullptr) {
1523 if (e2 != nextEdge) {
1530 if (nextEdge ==
nullptr) {
1535 if (e2 != prevEdge) {
1542#ifdef DEBUG_MOVEXY_ANGLE
1552 ConstMSEdgeVector::const_iterator searchStart = currentRoute.begin() + routePosition;
1556 ConstMSEdgeVector::const_iterator edgePos = std::find(searchStart, currentRoute.end(), e);
1557 onRoute = edgePos != currentRoute.end();
1558 if (edgePos == currentRoute.end() - 1 && currentRouteEdge == e) {
1564 nextEdge = !onRoute || edgePos == currentRoute.end() - 1 ? nullptr : *(edgePos + 1);
1565#ifdef DEBUG_MOVEXY_ANGLE
1572 while (prevEdge !=
nullptr && prevEdge->
isInternal()) {
1575 prevEdge = l ==
nullptr ? nullptr : &l->
getEdge();
1578 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin() + routePosition, currentRoute.end(), prevEdge);
1580 while (nextEdge !=
nullptr && nextEdge->
isInternal()) {
1583 if (prevEdgePos != currentRoute.end() && (prevEdgePos + 1) != currentRoute.end()) {
1584 onRoute = *(prevEdgePos + 1) == nextEdge;
1590#ifdef DEBUG_MOVEXY_ANGLE
1597 const bool perpendicular =
false;
1599 if (!l->allowsVehicleClass(vClass)) {
1602 if (l->getShape().length() == 0) {
1606 double langle = 180.;
1608 double perpendicularDist =
FAR_AWAY;
1611 const double slack = POSITION_EPS *
TS;
1616 perpendicularDist = laneShape.
distance2D(pos,
true);
1619 off = l->getShape().nearest_offset_to_point2D(pos, perpendicular);
1621 dist = l->getShape().distance2D(pos, perpendicular);
1626 bool sameEdge = onRoad && e == ¤tLane->
getEdge() && currentRouteEdge->
getLength() > currentLanePos +
SPEED2DIST(speed) && !e->isWalkingArea();
1634 double dist2 = dist;
1635 if (mayLeaveNetwork && fabs(dist - perpendicularDist) > slack) {
1639 const double angle2 = useCurrentAngle ? currentAngle : angle;
1641#ifdef DEBUG_MOVEXY_ANGLE
1643 <<
" candLane=" << l->getID() <<
" lAngle=" << langle <<
" lLength=" << l->getLength()
1644 <<
" angleDiff=" << angleDiff
1646 <<
" pDist=" << perpendicularDist
1648 <<
" dist2=" << dist2
1650 std::cout << l->getID() <<
" param=" << l->getParameter(
SUMO_PARAM_ORIGID,
"") <<
" origID='" << origID <<
"\n";
1654 if (origIDMatch && setLateralPos
1655 && perpendicularDist > l->getWidth() / 2) {
1656 origIDMatch =
false;
1659 dist2, perpendicularDist, off, angleDiff,
1661 onRoute, sameEdge, prevEdge, nextEdge));
1669 double bestValue = 0;
1670 MSLane* bestLane =
nullptr;
1671 for (
const auto& it : lane2utility) {
1672 MSLane*
const l = it.first;
1674 double distN = u.
dist > 999 ? -10 : 1. - (u.
dist / maxDist);
1675 double angleDiffN = 1. - (u.
angleDiff / 180.);
1676 double idN = u.
ID ? 1 : 0;
1677 double onRouteN = u.
onRoute ? 1 : 0;
1681 double value = (distN * .5 /
TS
1687 std::cout <<
" x; l:" << l->
getID() <<
" d:" << u.
dist <<
" dN:" << distN <<
" aD:" << angleDiffN <<
1688 " ID:" << idN <<
" oRN:" << onRouteN <<
" sEN:" << sameEdgeN <<
" value:" << value << std::endl;
1690 if (value > bestValue || bestLane ==
nullptr) {
1700 if (bestLane ==
nullptr) {
1703 const LaneUtility& u = lane2utility.find(bestLane)->second;
1704 bestDistance = u.
dist;
1706 lanePos =
MAX2(0.,
MIN2(
double((*lane)->getLength() - NUMERICAL_EPS),
1711 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin(), currentRoute.end(), prevEdge);
1712 routeOffset = (int)std::distance(currentRoute.begin(), prevEdgePos);
1725#ifdef DEBUG_MOVEXY_ANGLE
1737 if (edge ==
nullptr) {
1740 bool newBest =
false;
1742 if (!candidateLane->allowsVehicleClass(vClass)) {
1745 if (candidateLane->getShape().length() == 0) {
1749 double dist = candidateLane->getShape().distance2D(pos);
1752 std::cout <<
" b at lane " << candidateLane->getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1754 if (dist < bestDistance || (dist == bestDistance && candidateLane->getNumericalID() < (*lane)->getNumericalID())) {
1756 bestDistance = dist;
1757 *lane = candidateLane;
1764 if (l->getIndex() == 0) {
1767 for (
const MSLink*
const link : l->getLinkCont()) {
1768 if (link->isInternalJunctionLink()) {
1769 if (
findCloserLane(&link->getViaLane()->getEdge(), pos, vClass, bestDistance, lane)) {
1784 double& bestDistance,
MSLane** lane,
double& lanePos,
int& routeOffset) {
1786 std::cout <<
SIMTIME <<
" moveToXYMap_matchingRoutePosition pos=" << pos <<
" vClass=" <<
toString(vClass) <<
"\n";
1794 const MSEdge* prev =
nullptr;
1795 for (
int i = routeIndex; i < (int)currentRoute.size(); ++i) {
1796 const MSEdge* cand = currentRoute[i];
1797 while (prev !=
nullptr) {
1803 if (
findCloserLane(internalCand, pos, vClass, bestDistance, lane)) {
1804 routeOffset = i - 1;
1806 prev = internalCand;
1814 const MSEdge* next = currentRoute[routeIndex];
1815 for (
int i = routeIndex; i >= 0; --i) {
1816 const MSEdge* cand = currentRoute[i];
1819 while (prev !=
nullptr) {
1822 if (
findCloserLane(internalCand, pos, vClass, bestDistance, lane)) {
1825 prev = internalCand;
1834 std::map<const MSJunction*, int> routeJunctions;
1835 for (
int i = 0; i < (int)currentRoute.size() - 1; ++i) {
1836 routeJunctions[currentRoute[i]->getToJunction()] = i;
1838 std::set<const Named*> into;
1840 shape.push_back(pos);
1842 for (
const Named* named : into) {
1843 const MSLane* cand =
dynamic_cast<const MSLane*
>(named);
1853 assert(lane !=
nullptr);
1855 if (*lane ==
nullptr) {
1857 std::cout <<
" b failed - no best route lane" << std::endl;
1865 if (!(*lane)->getEdge().isInternal()) {
1866 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1867 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1869 if (setLateralPos) {
1872 const double dist = (*i)->getShape().distance2D(pos);
1873 if (dist < (*i)->getWidth() / 2) {
1885 lanePos =
MAX2(0.,
MIN2(
double((*lane)->getLength() - NUMERICAL_EPS),
1886 (*lane)->interpolateGeometryPosToLanePos(
1887 (*lane)->getShape().nearest_offset_to_point25D(pos,
false))));
1890 std::cout <<
" b ok lane " << (*lane)->getID() <<
" lanePos:" << lanePos << std::endl;
1927 throw TraCIException(
"Unknown position format used for distance request.");
1938 :
VariableWrapper(handler), myResults(into), myContextResults(context), myActiveResults(&into) {
1945 myActiveResults = refID ==
nullptr ? &myResults : &myContextResults[*refID];
1951 myActiveResults = &myResults;
1953 myContextResults.clear();
1959 auto sl = std::make_shared<TraCIConnectionVectorWrapped>();
1961 (*myActiveResults)[objID][variable] = sl;
1968 (*myActiveResults)[objID][variable] = std::make_shared<TraCIDouble>(value);
1975 (*myActiveResults)[objID][variable] = std::make_shared<TraCIInt>(value);
1982 (*myActiveResults)[objID][variable] = std::make_shared<TraCIString>(value);
1989 auto sl = std::make_shared<TraCIStringList>();
1991 (*myActiveResults)[objID][variable] = sl;
1998 auto sl = std::make_shared<TraCIDoubleList>();
2000 (*myActiveResults)[objID][variable] = sl;
2007 (*myActiveResults)[objID][variable] = std::make_shared<TraCIPosition>(value);
2014 (*myActiveResults)[objID][variable] = std::make_shared<TraCIPositionVector>(value);
2021 (*myActiveResults)[objID][variable] = std::make_shared<TraCIColor>(value);
2028 (*myActiveResults)[objID][variable] = std::make_shared<TraCIRoadPosition>(value.first, value.second);
2035 auto sl = std::make_shared<TraCIStringDoublePairList>();
2037 (*myActiveResults)[objID][variable] = sl;
2044 auto sl = std::make_shared<TraCIStringList>();
2045 sl->value.push_back(value.first);
2046 sl->value.push_back(value.second);
2047 (*myActiveResults)[objID][variable] = sl;
2054 auto sl = std::make_shared<TraCIIntList>();
2055 sl->value.push_back(value.first);
2056 sl->value.push_back(value.second);
2057 (*myActiveResults)[objID][variable] = sl;
2064 (*myActiveResults)[objID][variable] = std::make_shared<TraCIStage>(value);
2071 auto sl = std::make_shared<TraCIReservationVectorWrapped>();
2073 (*myActiveResults)[objID][variable] = sl;
2080 auto sl = std::make_shared<TraCILogicVectorWrapped>();
2082 (*myActiveResults)[objID][variable] = sl;
2089 auto sl = std::make_shared<TraCILinkVectorVectorWrapped>();
2091 (*myActiveResults)[objID][variable] = sl;
2098 auto sl = std::make_shared<TraCISignalConstraintVectorWrapped>();
2100 (*myActiveResults)[objID][variable] = sl;
2107 auto sl = std::make_shared<TraCIJunctionFoeVectorWrapped>();
2109 (*myActiveResults)[objID][variable] = sl;
2116 auto sl = std::make_shared<TraCINextStopDataVectorWrapped>();
2118 (*myActiveResults)[objID][variable] = sl;
2125 auto sl = std::make_shared<TraCIVehicleDataVectorWrapped>();
2127 (*myActiveResults)[objID][variable] = sl;
2134 auto sl = std::make_shared<TraCIBestLanesDataVectorWrapped>();
2136 (*myActiveResults)[objID][variable] = sl;
2143 auto sl = std::make_shared<TraCINextTLSDataVectorWrapped>();
2145 (*myActiveResults)[objID][variable] = sl;
2152 (*myActiveResults)[objID];
2158 myVehicleStateChanges[to].push_back(vehicle->
getID());
2164 myTransportableStateChanges[to].push_back(transportable->
getID());
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
void checkTimeBounds(const double time)
check the valid SUMOTime range of double input and throw an error if out of bounds
constexpr SUMOTime TIME2STEPS(double x)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
const int STOP_DURATION_SET
const int STOP_PARKING_SET
std::vector< SUMOVehicleParameter::Stop > StopParVector
const int STOP_CONTAINER_TRIGGER_SET
const int STOP_TRIGGER_SET
const std::string SUMO_PARAM_ORIGID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
int gPrecision
the precision for floating point outputs
const double SUMO_const_laneWidth
std::string toHex(const T i, std::streamsize numDigits=0)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
double getHeight() const
Returns the height of the boundary (y-axis)
double getWidth() const
Returns the width of the boudary (x-axis)
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const Boundary & getConvBoundary() const
Returns the converted boundary.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
static double naviDegree(const double angle)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
The base class for microscopic and mesoscopic vehicles.
double getLength() const
Returns the vehicle's length.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Calibrates the flow on a segment to a specified one.
const MSLane * getLane() const
AspiredState getCurrentStateInterval() const
static const std::map< std::string, MSCalibrator * > & getInstances()
return all calibrator instances
A simple description of a position on a lane (crossing of a lane)
A detector of vehicles passing an area between entry/exit points.
const CrossSectionVector & getEntries() const
Returns the entry cross sections.
const CrossSectionVector & getExits() const
Returns the exit cross sections.
A road/street connecting two junctions.
bool isCrossing() const
return whether this edge is a pedestrian crossing
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
bool isWalkingArea() const
return whether this edge is walking area
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
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
bool isInternal() const
return whether this edge is an internal edge
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....
const MSEdgeVector & getPredecessors() const
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
The base class for an intersection.
Representation of a lane in the micro simulation.
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode, bool maxSearchDist=false) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
void visit(const MSLane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
bool isWalkingArea() const
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
double getLength() const
Returns the lane's length.
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the road network starting on the given position...
bool allowsVehicleClass(SUMOVehicleClass vclass) const
int getIndex() const
Returns the lane's index.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
double interpolateGeometryPosToLanePos(double geometryPos) const
std::pair< MSVehicle *const, double > getLeader(const MSVehicle *veh, const double vehPos, const std::vector< MSLane * > &bestLaneConts, double dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
virtual const PositionVector & getShape(bool) const
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
MSEdge & getEdge() const
Returns the lane's edge.
double getWidth() const
Returns the lane's width.
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
VehicleState
Definition of a vehicle state.
@ ARRIVED
The vehicle arrived at his destination (is deleted)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
MSVehicleRouter & getRouterTT(int rngIndex, const Prohibitions &prohibited={}) const
static bool hasInstance()
Returns whether the network was already constructed.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
void addTransportableStateListener(TransportableStateListener *listener)
Adds a transportable states listener.
TransportableState
Definition of a transportable state.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
double getDistanceBetween(double fromPos, double toPos, const MSLane *fromLane, const MSLane *toLane, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
Storage for all programs of a single tls.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Representation of a vehicle in the micro simulation.
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
MSAbstractLaneChangeModel & getLaneChangeModel()
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
const std::vector< const MSLane * > getPastLanesUntil(double distance) const
Returns the sequence of past lanes (right-most on edge) based on the route starting at the current la...
const MSLane * getLane() const
Returns the lane the vehicle is on.
Influencer & getInfluencer()
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getPositionOnLane() const
Get the vehicle's position along the lane.
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
const std::string & getID() const
Returns the name of the vehicle type.
double getLength() const
Get vehicle's length [m].
Allows to store the object; used as context while traveling the rtree in TraCI.
Base class for objects which have an id.
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.
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
void setz(double z)
set position z
double z() const
Returns the z-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...
void sety(double y)
set position y
double y() const
Returns the y-position.
void append(const PositionVector &v, double sameThreshold=2.0)
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position 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 prepend(const PositionVector &v, double sameThreshold=2.0)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::pair< PositionVector, PositionVector > splitAt(double where, bool use2D=false) const
Returns the two lists made when this list vector is splitted at the given point.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
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.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSEdge * getEdge() const =0
Returns the (normal) route edge the object is currently at.
Representation of a vehicle.
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
int getFlags() const
return flags as per Vehicle::getStops
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at.
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
int parametersSet
Information for the output which parameter were set.
int index
at which position in the stops list
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
bool wrapIntPair(const std::string &objID, const int variable, const std::pair< int, int > &value)
bool wrapJunctionFoeVector(const std::string &objID, const int variable, const std::vector< TraCIJunctionFoe > &value)
bool wrapDouble(const std::string &objID, const int variable, const double value)
void empty(const std::string &objID)
bool wrapConnectionVector(const std::string &objID, const int variable, const std::vector< TraCIConnection > &value)
bool wrapStringDoublePairList(const std::string &objID, const int variable, const std::vector< std::pair< std::string, double > > &value)
bool wrapPositionVector(const std::string &objID, const int variable, const TraCIPositionVector &value)
bool wrapLinkVectorVector(const std::string &objID, const int variable, const std::vector< std::vector< TraCILink > > &value)
bool wrapSignalConstraintVector(const std::string &objID, const int variable, const std::vector< TraCISignalConstraint > &value)
bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)
bool wrapInt(const std::string &objID, const int variable, const int value)
bool wrapReservationVector(const std::string &objID, const int variable, const std::vector< TraCIReservation > &value)
bool wrapNextTLSDataVector(const std::string &objID, const int variable, const std::vector< TraCINextTLSData > &value)
bool wrapBestLanesDataVector(const std::string &objID, const int variable, const std::vector< TraCIBestLanesData > &value)
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)
bool wrapString(const std::string &objID, const int variable, const std::string &value)
bool wrapLogicVector(const std::string &objID, const int variable, const std::vector< TraCILogic > &value)
bool wrapNextStopDataVector(const std::string &objID, const int variable, const std::vector< TraCINextStopData > &value)
bool wrapStage(const std::string &objID, const int variable, const TraCIStage &value)
bool wrapStringPair(const std::string &objID, const int variable, const std::pair< std::string, std::string > &value)
bool wrapStringDoublePair(const std::string &objID, const int variable, const std::pair< std::string, double > &value)
SubscriptionWrapper(VariableWrapper::SubscriptionHandler handler, SubscriptionResults &into, ContextSubscriptionResults &context)
bool wrapVehicleDataVector(const std::string &objID, const int variable, const std::vector< TraCIVehicleData > &value)
void setContext(const std::string *const refID)
bool wrapDoubleList(const std::string &objID, const int variable, const std::vector< double > &value)
void transportableStateChanged(const MSTransportable *const transportable, MSNet::TransportableState to, const std::string &info="")
Called if a transportable changes its state.
std::map< MSNet::TransportableState, std::vector< std::string > > myTransportableStateChanges
Changes in the states of simulated transportables.
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
static Position makePosition(const TraCIPosition &position)
static MSEdge * getEdge(const std::string &edgeID)
static double patchShapeDistance(const MSLane *lane, const Position &pos, double dist, bool wasPerpendicular)
return the distance of pos from the area covered by this lane
static double getDrivingDistance(std::pair< const MSLane *, double > &roadPos1, std::pair< const MSLane *, double > &roadPos2)
static void collectObjectsInRange(int domain, const PositionVector &shape, double range, std::set< const Named * > &into)
static MSCalibrator::AspiredState getCalibratorState(const MSCalibrator *c)
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
static LANE_RTREE_QUAL * myLaneTree
A lookup tree of lanes.
static void applySubscriptionFilterTurn(const Subscription &s, std::set< const SUMOTrafficObject * > &vehs)
Apply the subscription filter "turn": Gather upcoming junctions and vialanes within downstream distan...
static void findObjectShape(int domain, const std::string &id, PositionVector &shape)
static void clearStateChanges()
static PositionVector makePositionVector(const TraCIPositionVector &vector)
static void fuseLaneCoverage(std::shared_ptr< LaneCoverageInfo > aggregatedLaneCoverage, const std::shared_ptr< LaneCoverageInfo > newLaneCoverage)
Adds lane coverage information from newLaneCoverage into aggregatedLaneCoverage.
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 void debugPrint(const SUMOTrafficObject *veh)
static MSPerson * getPerson(const std::string &id)
static void subscribe(const int commandId, const std::string &id, const std::vector< int > &variables, const double beginTime, const double endTime, const libsumo::TraCIResults ¶ms, const int contextDomain=0, const double range=0.)
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
static int readDistanceRequest(tcpip::Storage &data, TraCIRoadPosition &roadPos, Position &pos)
static const std::vector< std::string > & getTransportableStateChanges(const MSNet::TransportableState state)
static std::map< int, std::shared_ptr< VariableWrapper > > myWrapper
Map of commandIds -> their executors; applicable if the executor applies to the method footprint.
static void clearSubscriptions()
static MSBaseVehicle * getVehicle(const std::string &id)
static void applySubscriptionFilterLateralDistanceSinglePass(const Subscription &s, std::set< std::string > &objIDs, std::set< const SUMOTrafficObject * > &vehs, const std::vector< const MSLane * > &lanes, double posOnLane, double posLat, bool isDownstream)
static MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag type)
static TraCIColor makeTraCIColor(const RGBColor &color)
static void applySubscriptionFilterFieldOfVision(const Subscription &s, std::set< std::string > &objIDs)
static Subscription * myLastContextSubscription
The last context subscription.
static TraCINextStopData buildStopData(const SUMOVehicleParameter::Stop &stopPar)
static void registerStateListener()
static TransportableStateListener myTransportableStateListener
Changes in the states of simulated transportables.
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
static int postProcessRemoteControl()
return number of remote-controlled entities
static void applySubscriptionFilters(const Subscription &s, std::set< std::string > &objIDs)
Filter the given ID-Set (which was obtained from an R-Tree search) according to the filters set by th...
static std::map< std::string, MSVehicle * > myRemoteControlledVehicles
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
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 MSTLLogicControl::TLSLogicVariants & getTLS(const std::string &id)
static SUMOTrafficObject * getTrafficObject(int domain, const std::string &id)
static VehicleStateListener myVehicleStateListener
Changes in the states of simulated vehicles.
static std::vector< Subscription > mySubscriptions
The list of known, still valid subscriptions.
static SUMOVehicleParameter::Stop buildStopParameters(const std::string &edgeOrStoppingPlaceID, double pos, int laneIndex, double startPos, int flags, double duration, double until)
static void handleSingleSubscription(const Subscription &s)
static void applySubscriptionFilterLateralDistance(const Subscription &s, std::set< const SUMOTrafficObject * > &vehs, double downstreamDist, double upstreamDist, double lateralDist)
Apply the subscription filter "lateral distance": Only return vehicles within the given lateral dista...
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
static void collectObjectIDsInRange(int domain, const PositionVector &shape, double range, std::set< std::string > &into)
static void handleSubscriptions(const SUMOTime t)
static Subscription * addSubscriptionFilter(SubscriptionFilterType filter)
static std::vector< Subscription >::iterator eraseSubscription(std::vector< Subscription > &subscriptions, std::vector< Subscription >::iterator position, Subscription *&lastContextSubscription)
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static RGBColor makeRGBColor(const TraCIColor &color)
static void applySubscriptionFilterLanes(const Subscription &s, std::set< const SUMOTrafficObject * > &vehs, std::vector< int > &filterLanes, double downstreamDist, double upstreamDist, bool disregardOppositeDirection)
Apply the subscription filter "lanes": Only return vehicles on list of lanes relative to ego vehicle....
static std::map< std::string, MSPerson * > myRemoteControlledPersons
static bool needNewSubscription(libsumo::Subscription &s, std::vector< Subscription > &subscriptions, libsumo::Subscription *&modifiedSubscription)
static bool findCloserLane(const MSEdge *edge, const Position &pos, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane)
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static std::shared_ptr< tcpip::Storage > toStorage(const TraCIResult &v)
Representation of a subscription.
double filterUpstreamDist
Upstream distance specified by the upstream distance filter.
int commandId
commandIdArg The command id of the subscription
std::set< std::string > filterVTypes
vTypes specified by the vTypes filter
double filterFieldOfVisionOpeningAngle
Opening angle (in deg) specified by the field of vision filter.
std::vector< int > filterLanes
lanes specified by the lanes filter
std::string id
The id of the object that is subscribed.
SUMOTime endTime
The end time of the subscription.
int contextDomain
The domain ID of the context.
double filterFoeDistToJunction
Foe distance to junction specified by the turn filter.
bool isVehicleToVehicleContextSubscription() const
SUMOTime beginTime
The begin time of the subscription.
std::vector< int > variables
The subscribed variables.
SVCPermissions filterVClasses
vClasses specified by the vClasses filter,
bool isVehicleToPersonContextSubscription() const
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
double filterLateralDist
Lateral distance specified by the lateral distance filter.
int activeFilters
Active filters for the subscription (bitset,.
double range
The range of the context.
std::vector< std::shared_ptr< tcpip::Storage > > parameters
The parameters for the subscribed variables.
An error which allows to continue.
virtual void empty(const std::string &)
bool(* SubscriptionHandler)(const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
Definition of a method to be called for serving an associated commandID.
virtual void setContext(const std::string *const)
virtual std::string readString()
virtual int readUnsignedByte()
virtual double readDouble()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int POSITION_3D
TRACI_CONST int CMD_GET_CHARGINGSTATION_VARIABLE
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int CMD_SUBSCRIBE_EDGE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_LANE_CONTEXT
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int CMD_GET_PARKINGAREA_VARIABLE
TRACI_CONST int CMD_GET_POI_VARIABLE
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_CONTEXT
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int CMD_GET_REROUTER_VARIABLE
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_EDGE_VARIABLE
TRACI_CONST int CMD_GET_CALIBRATOR_VARIABLE
TRACI_CONST int CMD_GET_PERSON_VARIABLE
TRACI_CONST int CMD_GET_ROUTEPROBE_VARIABLE
TRACI_CONST int CMD_GET_LANEAREA_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_BUSSTOP_CONTEXT
TRACI_CONST int POSITION_2D
TRACI_CONST int CMD_GET_BUSSTOP_VARIABLE
TRACI_CONST int CMD_GET_ROUTE_VARIABLE
TRACI_CONST int CMD_GET_MEANDATA_VARIABLE
TRACI_CONST int CMD_GET_JUNCTION_VARIABLE
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int CMD_GET_VARIABLESPEEDSIGN_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_CALIBRATOR_CONTEXT
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PERSON_CONTEXT
TRACI_CONST int CMD_GET_VEHICLETYPE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_CHARGINGSTATION_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_POLYGON_CONTEXT
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int CMD_GET_LANE_VARIABLE
TRACI_CONST int CMD_GET_GUI_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PARKINGAREA_CONTEXT
TRACI_CONST int CMD_GET_POLYGON_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
SubscriptionFilterType
Filter types for context subscriptions.
@ SUBS_FILTER_LEAD_FOLLOW
@ SUBS_FILTER_UPSTREAM_DIST
@ SUBS_FILTER_DOWNSTREAM_DIST
@ SUBS_FILTER_LATERAL_DIST
@ SUBS_FILTER_FIELD_OF_VISION
TRACI_CONST int CMD_SUBSCRIBE_LANEAREA_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_POI_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_SIM_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_LANE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PERSON_VARIABLE
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_GET_OVERHEADWIRE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_LANEAREA_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_JUNCTION_CONTEXT
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int CMD_SUBSCRIBE_EDGE_VARIABLE
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
std::vector< TraCIPosition > value
An edgeId, position and laneIndex.