55 #define FAR_AWAY 1000.0 67 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
69 myIDs.insert((*j)->getID());
78 for (
auto p : persons) {
80 myIDs.insert(p->getID());
108 std::vector<Subscription> Helper::mySubscriptions;
109 std::map<int, std::shared_ptr<VariableWrapper> > Helper::myWrapper;
110 Helper::VehicleStateListener Helper::myVehicleStateListener;
111 std::map<int, NamedRTree*> Helper::myObjects;
113 std::map<std::string, MSVehicle*> Helper::myRemoteControlledVehicles;
114 std::map<std::string, MSPerson*> Helper::myRemoteControlledPersons;
121 Helper::subscribe(
const int commandId,
const std::string&
id,
const std::vector<int>& variables,
122 const double beginTime,
const double endTime,
const int contextDomain,
const double range) {
123 std::vector<std::vector<unsigned char> > parameters;
127 mySubscriptions.push_back(s);
128 handleSingleSubscription(s);
134 for (
auto& wrapper : myWrapper) {
135 wrapper.second->clear();
138 if (s.beginTime > t) {
141 handleSingleSubscription(s);
149 std::set<std::string> objIDs;
156 applySubscriptionFilters(s, objIDs);
160 if (myWrapper.empty()) {
176 auto wrapper = myWrapper.find(getCommandId);
177 if (wrapper == myWrapper.end()) {
180 std::shared_ptr<VariableWrapper> handler = wrapper->second;
182 handler->setContext(s.
id);
184 handler->setContext(
"");
186 for (
const std::string& objID : objIDs) {
189 handler->handle(objID, variable, handler.get());
194 handler->handle(objID,
VAR_ROAD_ID, handler.get());
206 Helper::fuseLaneCoverage(std::shared_ptr<LaneCoverageInfo> aggregatedLaneCoverage,
const std::shared_ptr<LaneCoverageInfo> newLaneCoverage) {
207 for (
auto& p : *newLaneCoverage) {
208 const MSLane* lane = p.first;
209 if (aggregatedLaneCoverage->find(lane) == aggregatedLaneCoverage->end()) {
211 (*aggregatedLaneCoverage)[lane] = (*newLaneCoverage)[lane];
214 std::pair<double, double>& range1 = (*aggregatedLaneCoverage)[lane];
215 std::pair<double, double>& range2 = (*newLaneCoverage)[lane];
216 std::pair<double, double> hull = std::make_pair(
MIN2(range1.first, range2.first),
MAX2(range1.second, range2.second));
217 (*aggregatedLaneCoverage)[lane] = hull;
226 for (
int i = 0; i < (int)positionVector.size(); ++i) {
227 tp.push_back(makeTraCIPosition(positionVector[i]));
237 if (std::isnan(pos.x) || std::isnan(pos.y)) {
240 pv.push_back(
Position(pos.x, pos.y));
259 return RGBColor((
unsigned char)c.
r, (
unsigned char)c.
g, (
unsigned char)c.
b, (
unsigned char)c.
a);
264 Helper::makeTraCIPosition(
const Position& position,
const bool includeZ) {
280 Helper::getEdge(
const std::string& edgeID) {
282 if (edge ==
nullptr) {
283 throw TraCIException(
"Referenced edge '" + edgeID +
"' is not known.");
290 Helper::getLaneChecking(
const std::string& edgeID,
int laneIndex,
double pos) {
292 if (edge ==
nullptr) {
295 if (laneIndex < 0 || laneIndex >= (
int)edge->
getLanes().size()) {
299 if (pos < 0 || pos > lane->
getLength()) {
306 std::pair<MSLane*, double>
309 std::pair<MSLane*, double> result;
310 double range = 1000.;
313 while (range < maxRange) {
314 std::set<std::string> laneIds;
316 double minDistance = std::numeric_limits<double>::max();
317 for (
const std::string& laneID : laneIds) {
322 if (newDistance < minDistance) {
323 minDistance = newDistance;
328 if (minDistance < std::numeric_limits<double>::max()) {
339 Helper::getVehicle(
const std::string&
id) {
341 if (sumoVehicle ==
nullptr) {
346 throw TraCIException(
"Vehicle '" +
id +
"' is not a micro-simulation vehicle.");
353 Helper::getVehicleType(
const std::string& vehicleID) {
354 return getVehicle(vehicleID)->getVehicleType();
360 for (
const auto i : myObjects) {
365 myLaneTree =
nullptr;
370 Helper::registerVehicleStateListener() {
377 const std::vector<std::string>&
379 return myVehicleStateListener.myVehicleStateChanges[state];
384 Helper::clearVehicleStates() {
385 for (
auto& i : myVehicleStateListener.myVehicleStateChanges) {
392 Helper::findObjectShape(
int domain,
const std::string&
id,
PositionVector& shape) {
395 InductionLoop::storeShape(
id, shape);
398 Lane::storeShape(
id, shape);
401 Vehicle::storeShape(
id, shape);
404 Person::storeShape(
id, shape);
407 POI::storeShape(
id, shape);
410 Polygon::storeShape(
id, shape);
413 Junction::storeShape(
id, shape);
416 Edge::storeShape(
id, shape);
425 Helper::collectObjectsInRange(
int domain,
const PositionVector& shape,
double range, std::set<std::string>& into) {
427 if (myObjects.find(domain) == myObjects.end()) {
457 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
458 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
465 myObjects[domain]->Search(cmin, cmax, sv);
473 myLaneTree->Search(cmin, cmax, sv);
484 Helper::applySubscriptionFilters(
const Subscription& s, std::set<std::string>& objIDs) {
485 #ifdef DEBUG_SURROUNDING 486 MSVehicle* _veh = libsumo::Vehicle::getVehicle(s.
id);
487 std::cout <<
SIMTIME <<
" applySubscriptionFilters for vehicle '" << _veh->
getID() <<
"' on lane '" << _veh->
getLane()->
getID() <<
"'" 489 <<
"objIDs = " <<
toString(objIDs) << std::endl;
503 WRITE_WARNING(
"Ignoring no-opposite subscription filter for geographic range object collection. Consider using the 'lanes' filter.")
508 std::set<const MSVehicle*> vehs;
511 double downstreamDist = s.
range, upstreamDist = s.
range;
525 if (vehLane ==
nullptr) {
529 std::vector<int> filterLanes;
540 #ifdef DEBUG_SURROUNDING 541 std::cout <<
"Filter lanes: " <<
toString(filterLanes) << std::endl;
542 std::cout <<
"Downstream distance: " << downstreamDist << std::endl;
543 std::cout <<
"Upstream distance: " << upstreamDist << std::endl;
550 for (
int offset : filterLanes) {
552 if (lane !=
nullptr) {
556 vehs.insert(vehs.end(), leader);
557 vehs.insert(vehs.end(), follower);
559 #ifdef DEBUG_SURROUNDING 560 std::cout <<
"Lane at index " << offset <<
": '" << lane->
getID() << std::endl;
561 std::cout <<
"Leader: '" << (leader !=
nullptr ? leader->
getID() :
"NULL") <<
"'" << std::endl;
562 std::cout <<
"Follower: '" << (follower !=
nullptr ? follower->
getID() :
"NULL") <<
"'" << std::endl;
565 }
else if (!disregardOppositeDirection && offset > 0) {
568 if (opposite ==
nullptr) {
569 #ifdef DEBUG_SURROUNDING 570 std::cout <<
"No lane at index " << offset << std::endl;
576 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
577 if (ix_opposite < 0) {
578 #ifdef DEBUG_SURROUNDING 579 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
584 lane = opposite->
getLanes()[ix_opposite];
589 vehs.insert(vehs.end(), lane->
getFollower(v, posOnOpposite, downstreamDist,
true).first);
591 vehs.insert(vehs.end(), lane->
getLeader(v, posOnOpposite - v->
getLength(), std::vector<MSLane*>()).first);
600 #ifdef DEBUG_SURROUNDING 601 std::cout <<
"Applying turn filter for vehicle '" << v->
getID() <<
"'\n Gathering foes ..." << std::endl;
604 for (
auto& l : links) {
605 #ifdef DEBUG_SURROUNDING 606 std::cout <<
" On junction '" << l->getJunction()->getID() <<
"' (no. foe links = " << l->getFoeLinks().size() <<
"):" << std::endl;
608 for (
auto& foeLane : l->getFoeLanes()) {
610 const MSLink* foeLink = foeLane->getEntryLink();
612 if (vi.second.dist <= upstreamDist) {
613 #ifdef DEBUG_SURROUNDING 614 std::cout <<
" Approaching from foe-lane '" << vi.first->getID() <<
"'" << std::endl;
616 vehs.insert(vehs.end(),
dynamic_cast<const MSVehicle*
>(vi.first));
620 for (
const MSVehicle* foe : foeLane->getVehiclesSecure()) {
621 vehs.insert(vehs.end(), foe);
623 foeLane->releaseVehicles();
627 #ifdef DEBUG_SURROUNDING 628 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
629 for (
auto veh : vehs) {
630 if (veh !=
nullptr) {
631 std::cout <<
" '" << veh->getID() <<
"' on lane '" << veh->getLane()->getID() <<
"'\n";
637 assert(filterLanes.size() > 0);
639 auto checkedLanesInDrivingDir = std::make_shared<LaneCoverageInfo>();
640 for (
int offset : filterLanes) {
642 if (lane !=
nullptr) {
643 #ifdef DEBUG_SURROUNDING 644 std::cout <<
"Checking for surrounding vehicles starting on lane '" << lane->
getID() <<
"' at index " << offset << std::endl;
649 std::shared_ptr<LaneCoverageInfo> checkedLanes = std::make_shared<LaneCoverageInfo>();
651 vehs.insert(new_vehs.begin(), new_vehs.end());
652 fuseLaneCoverage(checkedLanesInDrivingDir, checkedLanes);
653 }
else if (!disregardOppositeDirection && offset > 0) {
655 assert(vehLane->
getIndex() + (
unsigned int) offset >= vehEdge->
getLanes().size());
657 if (opposite ==
nullptr) {
658 #ifdef DEBUG_SURROUNDING 659 std::cout <<
"No opposite edge, thus no lane at index " << offset << std::endl;
665 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
666 if (ix_opposite < 0) {
667 #ifdef DEBUG_SURROUNDING 668 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
673 lane = opposite->getLanes()[ix_opposite];
676 vehs.insert(new_vehs.begin(), new_vehs.end());
678 #ifdef DEBUG_SURROUNDING 680 std::cout <<
"No lane at index " << offset << std::endl;
684 if (!disregardOppositeDirection) {
691 const int nOpp =
MAX2(0, (*std::max_element(filterLanes.begin(), filterLanes.end())) - ((int)vehEdge->
getLanes().size() - 1 - vehLane->
getIndex()));
694 for (
auto& laneCov : *checkedLanesInDrivingDir) {
695 const MSLane* lane = laneCov.first;
701 const std::pair<double, double>& range = laneCov.second;
702 auto leftMostOppositeLaneIt = opposite->
getLanes().rbegin();
703 for (
auto oppositeLaneIt = leftMostOppositeLaneIt;
704 oppositeLaneIt != opposite->
getLanes().rend(); ++oppositeLaneIt) {
705 if ((
int)(oppositeLaneIt - leftMostOppositeLaneIt) == nOpp) {
709 const MSLane* oppositeLane = *oppositeLaneIt;
711 vehs.insert(new_vehs.begin(), new_vehs.end());
716 #ifdef DEBUG_SURROUNDING 717 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
718 for (
auto veh : vehs) {
719 if (veh !=
nullptr) {
720 std::cout <<
" '" << veh->getID() <<
"' on lane '" << veh->getLane()->getID() <<
"'\n";
729 auto i = vehs.begin();
730 while (i != vehs.end()) {
731 if (((*i)->getVehicleType().getVehicleClass() & s.
filterVClasses) == 0) {
740 auto i = vehs.begin();
741 while (i != vehs.end()) {
752 if (veh !=
nullptr) {
753 objIDs.insert(objIDs.end(), veh->getID());
760 auto i = objIDs.begin();
761 while (i != objIDs.end()) {
772 auto i = objIDs.begin();
773 while (i != objIDs.end()) {
788 myRemoteControlledVehicles[v->
getID()] = v;
795 myRemoteControlledPersons[p->
getID()] = p;
801 Helper::postProcessRemoteControl() {
802 for (
auto& controlled : myRemoteControlledVehicles) {
803 if (
MSNet::getInstance()->getVehicleControl().getVehicle(controlled.first) !=
nullptr) {
804 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
806 WRITE_WARNING(
"Vehicle '" + controlled.first +
"' was removed though being controlled by TraCI");
809 myRemoteControlledVehicles.clear();
810 for (
auto& controlled : myRemoteControlledPersons) {
812 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
814 WRITE_WARNING(
"Person '" + controlled.first +
"' was removed though being controlled by TraCI");
817 myRemoteControlledPersons.clear();
822 Helper::moveToXYMap(
const Position& pos,
double maxRouteDistance,
bool mayLeaveNetwork,
const std::string& origID,
const double angle,
823 double speed,
const ConstMSEdgeVector& currentRoute,
const int routePosition,
MSLane* currentLane,
double currentLanePos,
bool onRoad,
827 const MSEdge*
const currentRouteEdge = currentRoute[routePosition];
828 std::set<std::string> into;
830 shape.push_back(pos);
833 std::map<MSLane*, LaneUtility> lane2utility;
835 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
837 const MSEdge* prevEdge =
nullptr;
838 const MSEdge* nextEdge =
nullptr;
839 bool onRoute =
false;
843 #ifdef DEBUG_MOVEXY_ANGLE 844 std::cout <<
"Ego on normal" << std::endl;
850 ConstMSEdgeVector::const_iterator searchStart = currentRoute.begin() + routePosition;
854 ConstMSEdgeVector::const_iterator edgePos = std::find(searchStart, currentRoute.end(), e);
855 onRoute = edgePos != currentRoute.end();
856 if (edgePos == currentRoute.end() - 1 && currentRouteEdge == e) {
862 nextEdge = !onRoute || edgePos == currentRoute.end() - 1 ? nullptr : *(edgePos + 1);
863 #ifdef DEBUG_MOVEXY_ANGLE 864 std::cout <<
"normal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:";
866 std::cout << nextEdge->
getID();
868 std::cout << std::endl;
871 #ifdef DEBUG_MOVEXY_ANGLE 872 std::cout <<
"Ego on internal" << std::endl;
877 while (prevEdge !=
nullptr && prevEdge->
isInternal()) {
880 prevEdge = l ==
nullptr ? nullptr : &l->
getEdge();
883 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin() + routePosition, currentRoute.end(), prevEdge);
885 while (nextEdge !=
nullptr && nextEdge->isInternal()) {
888 if (prevEdgePos != currentRoute.end() && (prevEdgePos + 1) != currentRoute.end()) {
889 onRoute = *(prevEdgePos + 1) == nextEdge;
891 #ifdef DEBUG_MOVEXY_ANGLE 892 std::cout <<
"internal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:" << nextEdge->getID() << std::endl;
898 const std::vector<MSLane*>& lanes = e->
getLanes();
899 const bool perpendicular =
false;
900 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
905 double langle = 180.;
907 double perpendicularDist =
FAR_AWAY;
914 perpendicularDist = shape.
distance2D(pos,
true);
930 if (mayLeaveNetwork && fabs(dist - perpendicularDist) > slack) {
935 #ifdef DEBUG_MOVEXY_ANGLE 937 <<
" candLane=" << lane->
getID() <<
" lAngle=" << langle <<
" lLength=" << lane->
getLength()
938 <<
" angleDiff=" << angleDiff
940 <<
" pDist=" << perpendicularDist
942 <<
" dist2=" << dist2
947 dist2, perpendicularDist, off, angleDiff,
949 onRoute, sameEdge, prevEdge, nextEdge);
957 double bestValue = 0;
958 MSLane* bestLane =
nullptr;
959 for (std::map<MSLane*, LaneUtility>::iterator i = lane2utility.begin(); i != lane2utility.end(); ++i) {
962 double distN = u.
dist > 999 ? -10 : 1. - (u.
dist / maxDist);
963 double angleDiffN = 1. - (u.
angleDiff / 180.);
964 double idN = u.
ID ? 1 : 0;
965 double onRouteN = u.
onRoute ? 1 : 0;
967 double value = (distN * .5
973 std::cout <<
" x; l:" << l->
getID() <<
" d:" << u.
dist <<
" dN:" << distN <<
" aD:" << angleDiffN <<
974 " ID:" << idN <<
" oRN:" << onRouteN <<
" sEN:" << sameEdgeN <<
" value:" << value << std::endl;
976 if (value > bestValue || bestLane ==
nullptr) {
986 if (bestLane ==
nullptr) {
989 const LaneUtility& u = lane2utility.find(bestLane)->second;
990 bestDistance = u.
dist;
995 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin(), currentRoute.end(), prevEdge);
996 routeOffset = (int)std::distance(currentRoute.begin(), prevEdgePos);
1009 #ifdef DEBUG_MOVEXY_ANGLE 1019 if (edge ==
nullptr) {
1022 const std::vector<MSLane*>& lanes = edge->
getLanes();
1023 bool newBest =
false;
1024 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
1025 MSLane* candidateLane = *k;
1031 std::cout <<
" b at lane " << candidateLane->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1033 if (dist < bestDistance) {
1035 bestDistance = dist;
1036 *lane = candidateLane;
1045 Helper::moveToXYMap_matchingRoutePosition(
const Position& pos,
const std::string& origID,
1048 double& bestDistance,
MSLane** lane,
double& lanePos,
int& routeOffset) {
1055 const MSEdge* prev =
nullptr;
1056 for (
int i = routeIndex; i < (int)currentRoute.size(); ++i) {
1057 const MSEdge* cand = currentRoute[i];
1058 while (prev !=
nullptr) {
1061 findCloserLane(internalCand, pos, vClass, bestDistance, lane);
1062 prev = internalCand;
1064 if (findCloserLane(cand, pos, vClass, bestDistance, lane)) {
1070 const MSEdge* next = currentRoute[routeIndex];
1071 for (
int i = routeIndex; i >= 0; --i) {
1072 const MSEdge* cand = currentRoute[i];
1075 while (prev !=
nullptr) {
1078 if (findCloserLane(internalCand, pos, vClass, bestDistance, lane)) {
1081 prev = internalCand;
1083 if (findCloserLane(cand, pos, vClass, bestDistance, lane)) {
1091 if (lane ==
nullptr) {
1093 std::cout <<
" b failed - no best route lane" << std::endl;
1101 if (!(*lane)->getEdge().isInternal()) {
1102 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1103 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1112 (*lane)->interpolateGeometryPosToLanePos(
1113 (*lane)->getShape().nearest_offset_to_point25D(pos,
false))));
1116 std::cout <<
" b ok lane " << (*lane)->getID() <<
" lanePos:" << lanePos << std::endl;
1123 :
VariableWrapper(handler), myResults(into), myContextResults(context), myActiveResults(&into) {
1144 (*myActiveResults)[objID][variable] = std::make_shared<TraCIDouble>(value);
1151 (*myActiveResults)[objID][variable] = std::make_shared<TraCIInt>(value);
1158 (*myActiveResults)[objID][variable] = std::make_shared<TraCIString>(value);
1165 auto sl = std::make_shared<TraCIStringList>();
1167 (*myActiveResults)[objID][variable] = sl;
1174 (*myActiveResults)[objID][variable] = std::make_shared<TraCIPosition>(value);
1181 (*myActiveResults)[objID][variable] = std::make_shared<TraCIColor>(value);
1188 (*myActiveResults)[objID][variable] = std::make_shared<TraCIRoadPosition>(value);
1195 myVehicleStateChanges[to].push_back(vehicle->
getID());
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
double ymin() const
Returns minimum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
double getLength() const
Returns the vehicle's length.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
Representation of a subscription.
double range
The range of the context.
TRACI_CONST int CMD_GET_TL_VARIABLE
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the along the road network starting on the give...
An edgeId, position and laneIndex.
double z() const
Returns the z-position.
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) ...
TRACI_CONST int CMD_GET_LANE_VARIABLE
const Boundary & getConvBoundary() const
Returns the converted boundary.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
virtual const std::string & getID() const =0
Get the vehicle's ID.
MSLane * getLane() const
Returns the lane the vehicle is on.
TRACI_CONST int CMD_GET_LANEAREA_VARIABLE
bool wrapDouble(const std::string &objID, const int variable, const double value)
bool wrapString(const std::string &objID, const int variable, const std::string &value)
static void fill(RTREE &into)
Fills the given RTree with lane instances.
int gPrecision
the precision for floating point outputs
TRACI_CONST int VAR_ROAD_ID
unsigned char alpha() const
Returns the alpha-amount of the color.
TRACI_CONST int CMD_GET_ROUTE_VARIABLE
TRACI_CONST int CMD_GET_VEHICLETYPE_VARIABLE
ContextSubscriptionResults & myContextResults
const double SUMO_const_laneWidth
double y() const
Returns the y-position.
double getPositionOnLane() const
Get the vehicle's position along the lane.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
TRACI_CONST int CMD_GET_PERSON_VARIABLE
double x() const
Returns the x-position.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getWidth() const
Returns the width of the boudary (x-axis)
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
double getLength() const
Returns the lane's length.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
const PositionVector & getShape() const
Returns this lane's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
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...
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
unsigned char blue() const
Returns the blue-amount of the color.
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
std::vector< const MSEdge * > ConstMSEdgeVector
const std::string & getID() const
Returns the id.
bool wrapRoadPosition(const std::string &objID, const int variable, const TraCIRoadPosition &value)
bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)
double getLength() const
return the length of the edge
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
TRACI_CONST int CMD_SUBSCRIBE_PERSON_CONTEXT
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.
SubscriptionResults & myResults
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
The car-following model and parameter.
std::string id
The id of the object that is subscribed.
bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)
TRACI_CONST int CMD_GET_POI_VARIABLE
SubscriptionResults * myActiveResults
TRACI_CONST int TRACI_ID_LIST
int commandId
commandIdArg The command id of the subscription
TRACI_CONST int CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_POLYGON_CONTEXT
A road/street connecting two junctions.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
int activeFilters
Active filters for the subscription (bitset,.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
static double naviDegree(const double angle)
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_CONTEXT
int getIndex() const
Returns the lane's index.
TRACI_CONST int CMD_SUBSCRIBE_POI_CONTEXT
Influencer & getInfluencer()
Returns the velocity/lane influencer.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
static bool hasInstance()
Returns whether the network was already constructed.
Representation of a vehicle.
int contextDomain
The domain ID of the context.
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
double interpolateGeometryPosToLanePos(double geometryPos) const
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
A point in 2D or 3D with translation and scaling methods.
int filterVClasses
vClasses specified by the vClasses filter,
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
TRACI_CONST int CMD_SUBSCRIBE_JUNCTION_CONTEXT
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
TRACI_CONST int CMD_GET_MULTIENTRYEXIT_VARIABLE
void add(const MSLane *const l) const
Adds the given object to the container.
double xmin() const
Returns minimum x-coordinate.
const std::string & getID() const
returns the id of the transportable
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.
Boundary & grow(double by)
extends the boundary by the given amount
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
bool isInternal() const
return whether this edge is an internal edge
std::set< std::string > filterVTypes
vTypes specified by the vTypes filter
std::vector< MSVehicle * > VehCont
Container for vehicles.
double filterUpstreamDist
Upstream distance specified by the upstream distance filter.
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
VehicleState
Definition of a vehicle state.
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Allows to store the object; used as context while traveling the rtree in TraCI.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
std::set< std::string > & myIDs
The container.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
const PositionVector & myShape
TRACI_CONST int CMD_SUBSCRIBE_LANE_CONTEXT
TRACI_CONST int VAR_LANEPOSITION
double getHeight() const
Returns the height of the boundary (y-axis)
unsigned char green() const
Returns the green-amount of the color.
std::vector< int > variables
The subscribed variables.
bool wrapInt(const std::string &objID, const int variable, const int value)
const std::string & getID() const
Returns the name of the vehicle type.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
const std::string SUMO_PARAM_ORIGID
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool allowsVehicleClass(SUMOVehicleClass vclass) const
unsigned char red() const
Returns the red-amount of the color.
TRACI_CONST int CMD_GET_JUNCTION_VARIABLE
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_GET_EDGE_VARIABLE
double ymax() const
Returns maximum y-coordinate.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
TRACI_CONST double INVALID_DOUBLE_VALUE
const std::string & getID() const
Returns the name of the vehicle.
Representation of a lane in the micro simulation.
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane *> &contLanes) const
Returns all upcoming junctions within given range along the given (non-internal) continuation lanes m...
TRACI_CONST int CMD_SUBSCRIBE_EDGE_CONTEXT
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
TRACI_CONST int CMD_GET_POLYGON_VARIABLE
std::vector< int > filterLanes
lanes specified by the lanes filter
void setContext(const std::string &refID)