 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
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());
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;
135 wrapper.second->clear();
138 if (s.beginTime > t) {
149 std::set<std::string> objIDs;
176 auto wrapper =
myWrapper.find(getCommandId);
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) {
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);
282 if (edge ==
nullptr) {
283 throw TraCIException(
"Referenced edge '" + edgeID +
"' is not known.");
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()) {
341 if (sumoVehicle ==
nullptr) {
344 MSVehicle* v = dynamic_cast<MSVehicle*>(sumoVehicle);
346 throw TraCIException(
"Vehicle '" +
id +
"' is not a micro-simulation vehicle.");
377 const std::vector<std::string>&
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);
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());
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()) {
804 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
806 WRITE_WARNING(
"Vehicle '" + controlled.first +
"' was removed though being controlled by TraCI");
812 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
814 WRITE_WARNING(
"Person '" + controlled.first +
"' was removed though being controlled by TraCI");
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;
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) {
1062 prev = internalCand;
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;
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) {
1130 myActiveResults = refID ==
"" ? &myResults : &myContextResults[refID];
1136 myActiveResults = &myResults;
1138 myContextResults.clear();
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());
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 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
const double SUMO_const_laneWidth
TRACI_CONST int CMD_SUBSCRIBE_PERSON_CONTEXT
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
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()
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
bool isInternal() const
return whether this edge is an internal edge
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
double xmin() const
Returns minimum x-coordinate.
Representation of a subscription.
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)
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.
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()
MSEdge & getEdge() const
Returns the lane's edge.
static LIBSUMO_SUBSCRIPTION_API NamedRTree * getTree()
Returns a tree filled with junction instances.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
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 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.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
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)
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)
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)
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)