 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
54 #define FAR_AWAY 1000.0
66 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
68 myIDs.insert((*j)->getID());
77 for (
auto p : persons) {
79 myIDs.insert(p->getID());
120 Helper::subscribe(
const int commandId,
const std::string&
id,
const std::vector<int>& variables,
121 const double beginTime,
const double endTime,
const int contextDomain,
const double range) {
122 if (variables.empty()) {
124 if (j->id ==
id && j->commandId == commandId && (contextDomain < 0 || j->contextDomain == contextDomain)) {
131 std::vector<std::vector<unsigned char> > parameters;
146 wrapper.second->clear();
149 if (s.beginTime <= t) {
162 std::vector<std::vector<unsigned char> >::const_iterator k = s.
parameters.begin();
164 const int offset = (int)(std::find(o.variables.begin(), o.variables.end(), v) - o.variables.begin());
165 if (offset == (
int)o.variables.size() || o.parameters[offset] != *k) {
166 o.variables.push_back(v);
167 o.parameters.push_back(*k);
171 modifiedSubscription = &o;
188 std::set<std::string> objIDs;
215 auto wrapper =
myWrapper.find(getCommandId);
219 std::shared_ptr<VariableWrapper> handler = wrapper->second;
224 if (containerWrapper ==
myWrapper.end()) {
227 container = containerWrapper->second.get();
231 for (
const std::string& objID : objIDs) {
234 handler->handle(objID, variable, container);
251 Helper::fuseLaneCoverage(std::shared_ptr<LaneCoverageInfo> aggregatedLaneCoverage,
const std::shared_ptr<LaneCoverageInfo> newLaneCoverage) {
252 for (
auto& p : *newLaneCoverage) {
253 const MSLane* lane = p.first;
254 if (aggregatedLaneCoverage->find(lane) == aggregatedLaneCoverage->end()) {
256 (*aggregatedLaneCoverage)[lane] = (*newLaneCoverage)[lane];
259 std::pair<double, double>& range1 = (*aggregatedLaneCoverage)[lane];
260 std::pair<double, double>& range2 = (*newLaneCoverage)[lane];
261 std::pair<double, double> hull = std::make_pair(
MIN2(range1.first, range2.first),
MAX2(range1.second, range2.second));
262 (*aggregatedLaneCoverage)[lane] = hull;
271 for (
int i = 0; i < (int)positionVector.size(); ++i) {
282 if (std::isnan(pos.x) || std::isnan(pos.y)) {
285 pv.push_back(
Position(pos.x, pos.y));
304 return RGBColor((
unsigned char)c.
r, (
unsigned char)c.
g, (
unsigned char)c.
b, (
unsigned char)c.
a);
327 if (edge ==
nullptr) {
328 throw TraCIException(
"Referenced edge '" + edgeID +
"' is not known.");
337 if (edge ==
nullptr) {
340 if (laneIndex < 0 || laneIndex >= (
int)edge->
getLanes().size()) {
344 if (pos < 0 || pos > lane->
getLength()) {
351 std::pair<MSLane*, double>
354 std::pair<MSLane*, double> result;
355 double range = 1000.;
358 while (range < maxRange) {
359 std::set<std::string> laneIds;
361 double minDistance = std::numeric_limits<double>::max();
362 for (
const std::string& laneID : laneIds) {
367 if (newDistance < minDistance) {
368 minDistance = newDistance;
373 if (minDistance < std::numeric_limits<double>::max()) {
386 if (sumoVehicle ==
nullptr) {
391 throw TraCIException(
"Vehicle '" +
id +
"' is not a micro-simulation vehicle.");
422 const std::vector<std::string>&
502 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
503 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
510 myObjects[domain]->Search(cmin, cmax, sv);
530 #ifdef DEBUG_SURROUNDING
532 std::cout <<
SIMTIME <<
" applySubscriptionFilters for vehicle '" << _veh->
getID() <<
"' on lane '" << _veh->
getLane()->
getID() <<
"'"
534 <<
"objIDs = " <<
toString(objIDs) << std::endl;
548 WRITE_WARNING(
"Ignoring no-opposite subscription filter for geographic range object collection. Consider using the 'lanes' filter.")
551 WRITE_WARNING(
"Ignoring field of vision subscription filter due to incompatibility with other filter(s).")
556 std::set<const MSVehicle*> vehs;
559 double downstreamDist = s.
range, upstreamDist = s.
range;
573 if (vehLane ==
nullptr) {
577 std::vector<int> filterLanes;
588 #ifdef DEBUG_SURROUNDING
589 std::cout <<
"Filter lanes: " <<
toString(filterLanes) << std::endl;
590 std::cout <<
"Downstream distance: " << downstreamDist << std::endl;
591 std::cout <<
"Upstream distance: " << upstreamDist << std::endl;
598 for (
int offset : filterLanes) {
600 if (lane !=
nullptr) {
604 vehs.insert(vehs.end(), leader);
605 vehs.insert(vehs.end(), follower);
607 #ifdef DEBUG_SURROUNDING
608 std::cout <<
"Lane at index " << offset <<
": '" << lane->
getID() << std::endl;
609 std::cout <<
"Leader: '" << (leader !=
nullptr ? leader->
getID() :
"NULL") <<
"'" << std::endl;
610 std::cout <<
"Follower: '" << (follower !=
nullptr ? follower->
getID() :
"NULL") <<
"'" << std::endl;
613 }
else if (!disregardOppositeDirection && offset > 0) {
616 if (opposite ==
nullptr) {
617 #ifdef DEBUG_SURROUNDING
618 std::cout <<
"No lane at index " << offset << std::endl;
624 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
625 if (ix_opposite < 0) {
626 #ifdef DEBUG_SURROUNDING
627 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
632 lane = opposite->
getLanes()[ix_opposite];
637 vehs.insert(vehs.end(), lane->
getFollower(v, posOnOpposite, downstreamDist,
true).first);
639 vehs.insert(vehs.end(), lane->
getLeader(v, posOnOpposite - v->
getLength(), std::vector<MSLane*>()).first);
648 #ifdef DEBUG_SURROUNDING
649 std::cout <<
"Applying turn filter for vehicle '" << v->
getID() <<
"'\n Gathering foes ..." << std::endl;
652 for (
auto& l : links) {
653 #ifdef DEBUG_SURROUNDING
654 std::cout <<
" On junction '" << l->getJunction()->getID() <<
"' (no. foe links = " << l->getFoeLinks().size() <<
"):" << std::endl;
656 for (
auto& foeLane : l->getFoeLanes()) {
658 const MSLink* foeLink = foeLane->getEntryLink();
660 if (vi.second.dist <= upstreamDist) {
661 #ifdef DEBUG_SURROUNDING
662 std::cout <<
" Approaching from foe-lane '" << vi.first->getID() <<
"'" << std::endl;
664 vehs.insert(vehs.end(),
dynamic_cast<const MSVehicle*
>(vi.first));
668 for (
const MSVehicle* foe : foeLane->getVehiclesSecure()) {
669 vehs.insert(vehs.end(), foe);
671 foeLane->releaseVehicles();
675 #ifdef DEBUG_SURROUNDING
676 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
677 for (
auto veh : vehs) {
678 if (veh !=
nullptr) {
679 std::cout <<
" '" << veh->getID() <<
"' on lane '" << veh->getLane()->getID() <<
"'\n";
685 assert(filterLanes.size() > 0);
687 auto checkedLanesInDrivingDir = std::make_shared<LaneCoverageInfo>();
688 for (
int offset : filterLanes) {
690 if (lane !=
nullptr) {
691 #ifdef DEBUG_SURROUNDING
692 std::cout <<
"Checking for surrounding vehicles starting on lane '" << lane->
getID() <<
"' at index " << offset << std::endl;
697 std::shared_ptr<LaneCoverageInfo> checkedLanes = std::make_shared<LaneCoverageInfo>();
699 vehs.insert(new_vehs.begin(), new_vehs.end());
701 }
else if (!disregardOppositeDirection && offset > 0) {
705 if (opposite ==
nullptr) {
706 #ifdef DEBUG_SURROUNDING
707 std::cout <<
"No opposite edge, thus no lane at index " << offset << std::endl;
713 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
714 if (ix_opposite < 0) {
715 #ifdef DEBUG_SURROUNDING
716 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
721 lane = opposite->
getLanes()[ix_opposite];
724 vehs.insert(new_vehs.begin(), new_vehs.end());
726 #ifdef DEBUG_SURROUNDING
728 std::cout <<
"No lane at index " << offset << std::endl;
732 if (!disregardOppositeDirection) {
739 const int nOpp =
MAX2(0, (*std::max_element(filterLanes.begin(), filterLanes.end())) - ((
int)vehEdge->
getLanes().size() - 1 - vehLane->
getIndex()));
742 for (
auto& laneCov : *checkedLanesInDrivingDir) {
743 const MSLane*
const l = laneCov.first;
748 const std::pair<double, double>& range = laneCov.second;
749 auto leftMostOppositeLaneIt = opposite->
getLanes().rbegin();
750 for (
auto oppositeLaneIt = leftMostOppositeLaneIt;
751 oppositeLaneIt != opposite->
getLanes().rend(); ++oppositeLaneIt) {
752 if ((
int)(oppositeLaneIt - leftMostOppositeLaneIt) == nOpp) {
756 const MSLane* oppositeLane = *oppositeLaneIt;
758 vehs.insert(new_vehs.begin(), new_vehs.end());
763 #ifdef DEBUG_SURROUNDING
764 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
765 for (
auto veh : vehs) {
766 if (veh !=
nullptr) {
767 std::cout <<
" '" << veh->getID() <<
"' on lane '" << veh->getLane()->getID() <<
"'\n";
776 auto i = vehs.begin();
777 while (i != vehs.end()) {
778 if (((*i)->getVehicleType().getVehicleClass() & s.
filterVClasses) == 0) {
787 auto i = vehs.begin();
788 while (i != vehs.end()) {
799 if (veh !=
nullptr) {
800 objIDs.insert(objIDs.end(), veh->getID());
806 auto i = objIDs.begin();
807 while (i != objIDs.end()) {
818 auto i = objIDs.begin();
819 while (i != objIDs.end()) {
846 #ifdef DEBUG_SURROUNDING
847 std::cout <<
"FOVFILTER: ego direction = " <<
toString(
RAD2DEG(egoVehicle->
getAngle())) <<
" (deg)" << std::endl;
850 auto i = objIDs.begin();
851 while (i != objIDs.end()) {
852 if (s.
id.compare(*i) == 0) {
860 #ifdef DEBUG_SURROUNDING
862 std::cout <<
"FOVFILTER: veh '" << *i <<
"' alpha = " <<
toString(
RAD2DEG(alpha)) <<
" (deg)" << std::endl;
865 if (abs(alpha) > openingAngle * 0.5) {
892 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
894 WRITE_WARNING(
"Vehicle '" + controlled.first +
"' was removed though being controlled by TraCI");
900 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
902 WRITE_WARNING(
"Person '" + controlled.first +
"' was removed though being controlled by TraCI");
911 double speed,
const ConstMSEdgeVector& currentRoute,
const int routePosition,
MSLane* currentLane,
double currentLanePos,
bool onRoad,
915 const MSEdge*
const currentRouteEdge = currentRoute[routePosition];
916 std::set<std::string> into;
918 shape.push_back(pos);
921 std::map<MSLane*, LaneUtility> lane2utility;
923 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
925 const MSEdge* prevEdge =
nullptr;
926 const MSEdge* nextEdge =
nullptr;
927 bool onRoute =
false;
931 #ifdef DEBUG_MOVEXY_ANGLE
932 std::cout <<
"Ego on normal" << std::endl;
938 ConstMSEdgeVector::const_iterator searchStart = currentRoute.begin() + routePosition;
942 ConstMSEdgeVector::const_iterator edgePos = std::find(searchStart, currentRoute.end(), e);
943 onRoute = edgePos != currentRoute.end();
944 if (edgePos == currentRoute.end() - 1 && currentRouteEdge == e) {
950 nextEdge = !onRoute || edgePos == currentRoute.end() - 1 ? nullptr : *(edgePos + 1);
951 #ifdef DEBUG_MOVEXY_ANGLE
952 std::cout <<
"normal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:";
954 std::cout << nextEdge->
getID();
956 std::cout << std::endl;
959 #ifdef DEBUG_MOVEXY_ANGLE
960 std::cout <<
"Ego on internal" << std::endl;
965 while (prevEdge !=
nullptr && prevEdge->
isInternal()) {
968 prevEdge = l ==
nullptr ? nullptr : &l->
getEdge();
971 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin() + routePosition, currentRoute.end(), prevEdge);
973 while (nextEdge !=
nullptr && nextEdge->
isInternal()) {
976 if (prevEdgePos != currentRoute.end() && (prevEdgePos + 1) != currentRoute.end()) {
977 onRoute = *(prevEdgePos + 1) == nextEdge;
979 #ifdef DEBUG_MOVEXY_ANGLE
980 std::cout <<
"internal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:" << nextEdge->
getID() << std::endl;
986 const bool perpendicular =
false;
988 if (!l->allowsVehicleClass(vClass)) {
991 double langle = 180.;
993 double perpendicularDist =
FAR_AWAY;
1000 perpendicularDist = laneShape.
distance2D(pos,
true);
1002 off = l->getShape().nearest_offset_to_point2D(pos, perpendicular);
1004 dist = l->getShape().distance2D(pos, perpendicular);
1007 bool sameEdge = onRoad && e == ¤tLane->
getEdge() && currentRouteEdge->
getLength() > currentLanePos +
SPEED2DIST(speed);
1015 double dist2 = dist;
1016 if (mayLeaveNetwork && fabs(dist - perpendicularDist) > slack) {
1021 #ifdef DEBUG_MOVEXY_ANGLE
1023 <<
" candLane=" << l->getID() <<
" lAngle=" << langle <<
" lLength=" << l->getLength()
1024 <<
" angleDiff=" << angleDiff
1026 <<
" pDist=" << perpendicularDist
1028 <<
" dist2=" << dist2
1030 std::cout << l->getID() <<
" param=" << l->getParameter(
SUMO_PARAM_ORIGID, lane->
getID()) <<
" origID='" << origID <<
"\n";
1033 dist2, perpendicularDist, off, angleDiff,
1035 onRoute, sameEdge, prevEdge, nextEdge));
1043 double bestValue = 0;
1044 MSLane* bestLane =
nullptr;
1045 for (
const auto& it : lane2utility) {
1046 MSLane*
const l = it.first;
1048 double distN = u.
dist > 999 ? -10 : 1. - (u.
dist / maxDist);
1049 double angleDiffN = 1. - (u.
angleDiff / 180.);
1050 double idN = u.
ID ? 1 : 0;
1051 double onRouteN = u.
onRoute ? 1 : 0;
1053 double value = (distN * .5
1059 std::cout <<
" x; l:" << l->
getID() <<
" d:" << u.
dist <<
" dN:" << distN <<
" aD:" << angleDiffN <<
1060 " ID:" << idN <<
" oRN:" << onRouteN <<
" sEN:" << sameEdgeN <<
" value:" << value << std::endl;
1062 if (value > bestValue || bestLane ==
nullptr) {
1072 if (bestLane ==
nullptr) {
1075 const LaneUtility& u = lane2utility.find(bestLane)->second;
1076 bestDistance = u.
dist;
1081 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin(), currentRoute.end(), prevEdge);
1082 routeOffset = (int)std::distance(currentRoute.begin(), prevEdgePos);
1095 #ifdef DEBUG_MOVEXY_ANGLE
1105 if (edge ==
nullptr) {
1108 const std::vector<MSLane*>& lanes = edge->
getLanes();
1109 bool newBest =
false;
1110 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
1111 MSLane* candidateLane = *k;
1117 std::cout <<
" b at lane " << candidateLane->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1119 if (dist < bestDistance) {
1121 bestDistance = dist;
1122 *lane = candidateLane;
1134 double& bestDistance,
MSLane** lane,
double& lanePos,
int& routeOffset) {
1141 const MSEdge* prev =
nullptr;
1142 for (
int i = routeIndex; i < (int)currentRoute.size(); ++i) {
1143 const MSEdge* cand = currentRoute[i];
1144 while (prev !=
nullptr) {
1148 prev = internalCand;
1156 const MSEdge* next = currentRoute[routeIndex];
1157 for (
int i = routeIndex; i >= 0; --i) {
1158 const MSEdge* cand = currentRoute[i];
1161 while (prev !=
nullptr) {
1164 if (
findCloserLane(internalCand, pos, vClass, bestDistance, lane)) {
1167 prev = internalCand;
1177 if (lane ==
nullptr) {
1179 std::cout <<
" b failed - no best route lane" << std::endl;
1187 if (!(*lane)->getEdge().isInternal()) {
1188 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1189 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1198 (*lane)->interpolateGeometryPosToLanePos(
1199 (*lane)->getShape().nearest_offset_to_point25D(pos,
false))));
1202 std::cout <<
" b ok lane " << (*lane)->getID() <<
" lanePos:" << lanePos << std::endl;
1209 :
VariableWrapper(handler), myResults(into), myContextResults(context), myActiveResults(&into) {
1216 myActiveResults = refID ==
"" ? &myResults : &myContextResults[refID];
1222 myActiveResults = &myResults;
1224 myContextResults.clear();
1230 (*myActiveResults)[objID][variable] = std::make_shared<TraCIDouble>(value);
1237 (*myActiveResults)[objID][variable] = std::make_shared<TraCIInt>(value);
1244 (*myActiveResults)[objID][variable] = std::make_shared<TraCIString>(value);
1251 auto sl = std::make_shared<TraCIStringList>();
1253 (*myActiveResults)[objID][variable] = sl;
1260 (*myActiveResults)[objID][variable] = std::make_shared<TraCIPosition>(value);
1267 (*myActiveResults)[objID][variable] = std::make_shared<TraCIColor>(value);
1274 (*myActiveResults)[objID][variable] = std::make_shared<TraCIRoadPosition>(value);
1281 myVehicleStateChanges[to].push_back(vehicle->
getID());
unsigned char alpha() const
Returns the alpha-amount of the color.
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
static MSEdge * getEdge(const std::string &edgeID)
The car-following model and parameter.
TRACI_CONST int CMD_GET_TL_VARIABLE
static void handleSubscriptions(const SUMOTime t)
static Position makePosition(const TraCIPosition &position)
static std::map< int, NamedRTree * > myObjects
A storage of objects.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int activeFilters
Active filters for the subscription (bitset,.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
TRACI_CONST int CMD_GET_POLYGON_VARIABLE
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
const std::string & getID() const
Returns the name of the vehicle type.
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
double filterUpstreamDist
Upstream distance specified by the upstream distance filter.
#define WRITE_WARNING(msg)
const Boundary & getConvBoundary() const
Returns the converted boundary.
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
static LANE_RTREE_QUAL * myLaneTree
A storage of lanes.
Representation of a lane in the micro simulation.
static MSVehicle * getVehicle(const std::string &id)
TRACI_CONST double INVALID_DOUBLE_VALUE
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static TraCIColor makeTraCIColor(const RGBColor &color)
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
double ymin() const
Returns minimum y-coordinate.
TRACI_CONST int VAR_ROAD_ID
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
SubscriptionWrapper(VariableWrapper::SubscriptionHandler handler, SubscriptionResults &into, ContextSubscriptionResults &context)
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
void setContext(const std::string &refID)
double z() const
Returns the z-position.
Allows to store the object; used as context while traveling the rtree in TraCI.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
virtual const std::string & getID() const =0
Get the vehicle's ID.
const PositionVector & myShape
static PositionVector makePositionVector(const TraCIPositionVector &vector)
TRACI_CONST int CMD_GET_PERSON_VARIABLE
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
static RGBColor makeRGBColor(const TraCIColor &color)
double getLength() const
Returns the vehicle's length.
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
static std::map< std::string, MSVehicle * > myRemoteControlledVehicles
static std::shared_ptr< VariableWrapper > makeWrapper()
std::vector< int > filterLanes
lanes specified by the lanes filter
TRACI_CONST int CMD_GET_LANEAREA_VARIABLE
bool wrapRoadPosition(const std::string &objID, const int variable, const TraCIRoadPosition &value)
static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Representation of a vehicle.
std::vector< MSVehicle * > VehCont
Container for vehicles.
std::string id
The id of the object that is subscribed.
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, MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
static double naviDegree(const double angle)
std::vector< const MSEdge * > ConstMSEdgeVector
double xmax() const
Returns maximum x-coordinate.
static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
double getHeight() const
Returns the height of the boundary (y-axis)
static void subscribe(const int commandId, const std::string &id, const std::vector< int > &variables, const double beginTime, const double endTime, const int contextDomain=0, const double range=0.)
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
static bool needNewSubscription(libsumo::Subscription &s, std::vector< Subscription > &subscriptions, libsumo::Subscription *&modifiedSubscription)
const double SUMO_const_laneWidth
TRACI_CONST int CMD_SUBSCRIBE_PERSON_CONTEXT
SUMOTime endTime
The end time of the subscription.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
#define WRITE_WARNINGF(...)
unsigned char red() const
Returns the red-amount of the color.
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 TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
TRACI_CONST int CMD_SUBSCRIBE_POI_CONTEXT
TRACI_CONST int CMD_GET_LANE_VARIABLE
bool wrapString(const std::string &objID, const int variable, const std::string &value)
std::set< std::string > & myIDs
The container.
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_CONTEXT
double getLength() const
return the length of the edge
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...
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_VEHICLETYPE_VARIABLE
static LIBSUMO_SUBSCRIPTION_API NamedRTree * getTree()
Returns a tree filled with PoI instances.
std::vector< int > variables
The subscribed variables.
static std::shared_ptr< VariableWrapper > makeWrapper()
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
std::vector< std::vector< unsigned char > > parameters
The parameters for the subscribed variables.
bool isInternal() const
return whether this edge is an internal edge
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
TRACI_CONST int CMD_SUBSCRIBE_POLYGON_CONTEXT
int commandId
commandIdArg The command id of the subscription
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
double interpolateGeometryPosToLanePos(double geometryPos) const
double getPositionOnLane() const
Get the vehicle's position along the lane.
TRACI_CONST int CMD_GET_POI_VARIABLE
@ SUBS_FILTER_UPSTREAM_DIST
double xmin() const
Returns minimum x-coordinate.
Representation of a subscription.
double filterFieldOfVisionOpeningAngle
Opening angle (in deg) specified by the field of vision filter.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool wrapInt(const std::string &objID, const int variable, const int value)
static void fuseLaneCoverage(std::shared_ptr< LaneCoverageInfo > aggregatedLaneCoverage, const std::shared_ptr< LaneCoverageInfo > newLaneCoverage)
Adds lane coverage information from newLaneCoverage into aggregatedLaneCoverage.
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
VehicleState
Definition of a vehicle state.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
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.
int filterVClasses
vClasses specified by the vClasses filter,
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 std::string SUMO_PARAM_ORIGID
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
static std::shared_ptr< VariableWrapper > makeWrapper()
A class that stores a 2D geometrical boundary.
double getLength() const
Returns the lane's length.
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static std::shared_ptr< VariableWrapper > makeWrapper()
double getWidth() const
Returns the width of the boudary (x-axis)
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
double getAngle() const
Returns the vehicle's direction in radians.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
TRACI_CONST int CMD_GET_SIM_VARIABLE
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
TRACI_CONST int TRACI_ID_LIST
bool(* SubscriptionHandler)(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition of a method to be called for serving an associated commandID.
A road/street connecting two junctions.
SUMOTime beginTime
The begin time of the subscription.
static std::shared_ptr< VariableWrapper > makeWrapper()
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...
TRACI_CONST int CMD_SUBSCRIBE_JUNCTION_CONTEXT
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
unsigned char green() const
Returns the green-amount of the color.
bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
static LIBSUMO_SUBSCRIPTION_API NamedRTree * getTree()
Returns a tree filled with inductive loop instances.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
static void postProcessRemoteControl()
MSLane * getLane() const
Returns the lane the vehicle is on.
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)
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
static std::shared_ptr< VariableWrapper > makeWrapper()
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
MSEdge & getEdge() const
Returns the lane's edge.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
static LIBSUMO_SUBSCRIPTION_API NamedRTree * getTree()
Returns a tree filled with junction instances.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
static void applySubscriptionFilterFieldOfVision(const Subscription &s, std::set< std::string > &objIDs)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void collectObjectsInRange(int domain, const PositionVector &shape, double range, std::set< std::string > &into)
const PositionVector & getShape() const
Returns this lane's shape.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
static void clearSubscriptions()
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double y() const
Returns the y-position.
static std::shared_ptr< VariableWrapper > makeWrapper()
TRACI_CONST int CMD_GET_MULTIENTRYEXIT_VARIABLE
unsigned char blue() const
Returns the blue-amount of the color.
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
static VehicleStateListener myVehicleStateListener
Changes in the states of simulated vehicles.
double range
The range of the context.
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
static std::map< std::string, MSPerson * > myRemoteControlledPersons
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static void handleSingleSubscription(const Subscription &s)
TRACI_CONST int CMD_SUBSCRIBE_LANE_CONTEXT
TRACI_CONST int VAR_LANEPOSITION
bool wrapDouble(const std::string &objID, const int variable, const double value)
@ SUBS_FILTER_DOWNSTREAM_DIST
static void findObjectShape(int domain, const std::string &id, PositionVector &shape)
const std::string & getID() const
returns the id of the transportable
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
const std::string & getID() const
Returns the name of the vehicle.
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.
TRACI_CONST int CMD_SUBSCRIBE_EDGE_CONTEXT
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)
@ SUBS_FILTER_FIELD_OF_VISION
virtual void setContext(const std::string &)
static bool hasInstance()
Returns whether the network was already constructed.
An edgeId, position and laneIndex.
int contextDomain
The domain ID of the context.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
int gPrecision
the precision for floating point outputs
Boundary & grow(double by)
extends the boundary by the given amount
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
static std::shared_ptr< VariableWrapper > makeWrapper()
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
@ SUBS_FILTER_LEAD_FOLLOW
static bool findCloserLane(const MSEdge *edge, const Position &pos, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane)
static std::vector< Subscription > mySubscriptions
The list of known, still valid subscriptions.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
static std::shared_ptr< VariableWrapper > makeWrapper()
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
const std::string & getID() const
Returns the id.
TRACI_CONST int CMD_GET_EDGE_VARIABLE
static std::map< int, std::shared_ptr< VariableWrapper > > myWrapper
Map of commandIds -> their executors; applicable if the executor applies to the method footprint.
int getIndex() const
Returns the lane's index.
static void registerVehicleStateListener()
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
void add(const MSLane *const l) const
Adds the given object to the container.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
static void clearVehicleStates()
double ymax() const
Returns maximum y-coordinate.
std::set< std::string > filterVTypes
vTypes specified by the vTypes filter
TRACI_CONST int CMD_GET_JUNCTION_VARIABLE
TRACI_CONST int CMD_GET_ROUTE_VARIABLE
Representation of a vehicle in the micro simulation.
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)