54 #define FAR_AWAY 1000.0 65 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
67 myIDs.insert((*j)->getID());
76 for (
auto p : persons) {
78 myIDs.insert(p->getID());
106 std::vector<Subscription> Helper::mySubscriptions;
107 std::map<int, std::shared_ptr<VariableWrapper> > Helper::myWrapper;
108 Helper::VehicleStateListener Helper::myVehicleStateListener;
109 std::map<int, NamedRTree*> Helper::myObjects;
111 std::map<std::string, MSVehicle*> Helper::myRemoteControlledVehicles;
112 std::map<std::string, MSPerson*> Helper::myRemoteControlledPersons;
119 Helper::subscribe(
const int commandId,
const std::string&
id,
const std::vector<int>& variables,
120 const double beginTime,
const double endTime,
const int contextDomain,
const double range) {
121 std::vector<std::vector<unsigned char> > parameters;
125 mySubscriptions.push_back(s);
126 handleSingleSubscription(s);
133 if (s.beginTime > t) {
136 handleSingleSubscription(s);
144 std::set<std::string> objIDs;
151 applySubscriptionFilters(s, objIDs);
156 if (myWrapper.empty()) {
172 auto wrapper = myWrapper.find(getCommandId);
173 if (wrapper == myWrapper.end()) {
176 std::shared_ptr<VariableWrapper> handler = wrapper->second;
177 for (
const std::string& objID : objIDs) {
180 handler->handle(objID, variable, handler.get());
192 Helper::fuseLaneCoverage(std::shared_ptr<LaneCoverageInfo> aggregatedLaneCoverage,
const std::shared_ptr<LaneCoverageInfo> newLaneCoverage) {
193 for (
auto& p : *newLaneCoverage) {
194 const MSLane* lane = p.first;
195 if (aggregatedLaneCoverage->find(lane) == aggregatedLaneCoverage->end()) {
197 (*aggregatedLaneCoverage)[lane] = (*newLaneCoverage)[lane];
200 std::pair<double, double>& range1 = (*aggregatedLaneCoverage)[lane];
201 std::pair<double, double>& range2 = (*newLaneCoverage)[lane];
202 std::pair<double, double> hull = std::make_pair(
MIN2(range1.first, range2.first),
MAX2(range1.second, range2.second));
203 (*aggregatedLaneCoverage)[lane] = hull;
212 for (
int i = 0; i < (int)positionVector.size(); ++i) {
213 tp.push_back(makeTraCIPosition(positionVector[i]));
222 for (
int i = 0; i < (int)vector.size(); i++) {
223 pv.push_back(
Position(vector[i].x, vector[i].y));
242 return RGBColor((
unsigned char)c.
r, (
unsigned char)c.
g, (
unsigned char)c.
b, (
unsigned char)c.
a);
247 Helper::makeTraCIPosition(
const Position& position,
const bool includeZ) {
263 Helper::getEdge(
const std::string& edgeID) {
265 if (edge ==
nullptr) {
266 throw TraCIException(
"Referenced edge '" + edgeID +
"' is not known.");
273 Helper::getLaneChecking(
const std::string& edgeID,
int laneIndex,
double pos) {
275 if (edge ==
nullptr) {
278 if (laneIndex < 0 || laneIndex >= (
int)edge->
getLanes().size()) {
282 if (pos < 0 || pos > lane->
getLength()) {
289 std::pair<MSLane*, double>
292 std::pair<MSLane*, double> result;
293 std::vector<std::string> allEdgeIds;
294 double minDistance = std::numeric_limits<double>::max();
297 for (std::vector<std::string>::iterator itId = allEdgeIds.begin(); itId != allEdgeIds.end(); itId++) {
299 for (std::vector<MSLane*>::const_iterator itLane = allLanes.begin(); itLane != allLanes.end(); itLane++) {
300 const double newDistance = (*itLane)->getShape().distance2D(pos);
301 if (newDistance < minDistance) {
302 minDistance = newDistance;
303 result.first = (*itLane);
308 result.second = result.first->getShape().nearest_offset_to_point2D(pos,
false);
315 for (
const auto i : myObjects) {
320 myLaneTree =
nullptr;
325 Helper::registerVehicleStateListener() {
330 const std::vector<std::string>&
332 return myVehicleStateListener.myVehicleStateChanges[state];
337 Helper::clearVehicleStates() {
338 for (
auto& i : myVehicleStateListener.myVehicleStateChanges) {
345 Helper::findObjectShape(
int domain,
const std::string&
id,
PositionVector& shape) {
348 InductionLoop::storeShape(
id, shape);
351 Lane::storeShape(
id, shape);
354 Vehicle::storeShape(
id, shape);
357 Person::storeShape(
id, shape);
360 POI::storeShape(
id, shape);
363 Polygon::storeShape(
id, shape);
366 Junction::storeShape(
id, shape);
369 Edge::storeShape(
id, shape);
378 Helper::collectObjectsInRange(
int domain,
const PositionVector& shape,
double range, std::set<std::string>& into) {
380 if (myObjects.find(domain) == myObjects.end()) {
410 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
411 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
418 myObjects[domain]->Search(cmin, cmax, sv);
426 myLaneTree->Search(cmin, cmax, sv);
437 Helper::applySubscriptionFilters(
const Subscription& s, std::set<std::string>& objIDs) {
438 #ifdef DEBUG_SURROUNDING 440 std::cout <<
SIMTIME <<
" applySubscriptionFilters for vehicle '" << _veh->
getID() <<
"' on lane '" << _veh->
getLane()->
getID() <<
"'" 442 <<
"objIDs = " <<
toString(objIDs) << std::endl;
456 WRITE_WARNING(
"Ignoring no-opposite subscription filter for geographic range object collection. Consider using the 'lanes' filter.")
461 std::set<const MSVehicle*> vehs;
464 double downstreamDist = s.
range, upstreamDist = s.
range;
478 if (vehLane ==
nullptr) {
482 std::vector<int> filterLanes;
493 #ifdef DEBUG_SURROUNDING 494 std::cout <<
"Filter lanes: " <<
toString(filterLanes) << std::endl;
495 std::cout <<
"Downstream distance: " << downstreamDist << std::endl;
496 std::cout <<
"Upstream distance: " << upstreamDist << std::endl;
503 for (
int offset : filterLanes) {
505 if (lane !=
nullptr) {
509 vehs.insert(vehs.end(), leader);
510 vehs.insert(vehs.end(), follower);
512 #ifdef DEBUG_SURROUNDING 513 std::cout <<
"Lane at index " << offset <<
": '" << lane->
getID() << std::endl;
514 std::cout <<
"Leader: '" << (leader !=
nullptr ? leader->
getID() :
"NULL") <<
"'" << std::endl;
515 std::cout <<
"Follower: '" << (follower !=
nullptr ? follower->
getID() :
"NULL") <<
"'" << std::endl;
518 }
else if (!disregardOppositeDirection && offset > 0) {
521 if (opposite ==
nullptr) {
522 #ifdef DEBUG_SURROUNDING 523 std::cout <<
"No lane at index " << offset << std::endl;
529 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
530 if (ix_opposite < 0) {
531 #ifdef DEBUG_SURROUNDING 532 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
537 lane = opposite->
getLanes()[ix_opposite];
542 vehs.insert(vehs.end(), lane->
getFollower(v, posOnOpposite, downstreamDist,
true).first);
544 vehs.insert(vehs.end(), lane->
getLeader(v, posOnOpposite-v->
getLength(), std::vector<MSLane*>()).first);
553 #ifdef DEBUG_SURROUNDING 554 std::cout <<
"Applying turn filter for vehicle '" << v->
getID() <<
"'\n Gathering foes ..." << std::endl;
557 for (
auto& l : links) {
558 #ifdef DEBUG_SURROUNDING 559 std::cout <<
" On junction '" << l->getJunction()->getID() <<
"' (no. foe links = " << l->getFoeLinks().size() <<
"):" << std::endl;
561 for(
auto& foeLane : l->getFoeLanes()) {
563 const MSLink* foeLink = foeLane->getEntryLink();
565 if (vi.second.dist <= upstreamDist) {
566 #ifdef DEBUG_SURROUNDING 567 std::cout <<
" Approaching from foe-lane '" << vi.first->getID() <<
"'" << std::endl;
569 vehs.insert(vehs.end(),
dynamic_cast<const MSVehicle*
>(vi.first));
573 for (
const MSVehicle* foe : foeLane->getVehiclesSecure()) {
574 vehs.insert(vehs.end(), foe);
576 foeLane->releaseVehicles();
580 #ifdef DEBUG_SURROUNDING 581 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
582 for (
auto veh : vehs) {
583 if (veh !=
nullptr) {
584 std::cout <<
" '" << veh->getID() <<
"' on lane '" << veh->getLane()->getID() <<
"'\n";
590 assert(filterLanes.size() > 0);
592 auto checkedLanesInDrivingDir = std::make_shared<LaneCoverageInfo>();
593 for (
int offset : filterLanes){
595 if (lane !=
nullptr) {
596 #ifdef DEBUG_SURROUNDING 597 std::cout <<
"Checking for surrounding vehicles starting on lane '" << lane->
getID() <<
"' at index " << offset << std::endl;
602 std::shared_ptr<LaneCoverageInfo> checkedLanes = std::make_shared<LaneCoverageInfo>();
604 vehs.insert(new_vehs.begin(), new_vehs.end());
605 fuseLaneCoverage(checkedLanesInDrivingDir, checkedLanes);
606 }
else if (!disregardOppositeDirection && offset > 0) {
608 assert(vehLane->
getIndex() + (
unsigned int) offset >= vehEdge->
getLanes().size());
610 if (opposite ==
nullptr) {
611 #ifdef DEBUG_SURROUNDING 612 std::cout <<
"No opposite edge, thus no lane at index " << offset << std::endl;
618 const int ix_opposite = (int)opposite->
getLanes().size() - 1 - (vehLane->
getIndex() + offset - (int)vehEdge->
getLanes().size());
619 if (ix_opposite < 0) {
620 #ifdef DEBUG_SURROUNDING 621 std::cout <<
"No lane on opposite at index " << ix_opposite << std::endl;
626 lane = opposite->getLanes()[ix_opposite];
629 vehs.insert(new_vehs.begin(), new_vehs.end());
631 #ifdef DEBUG_SURROUNDING 633 std::cout <<
"No lane at index " << offset << std::endl;
637 if (!disregardOppositeDirection) {
644 const int nOpp =
MAX2(0, (*std::max_element(filterLanes.begin(), filterLanes.end())) - ((int)vehEdge->
getLanes().size() - 1 - vehLane->
getIndex()));
647 for (
auto& laneCov : *checkedLanesInDrivingDir) {
648 const MSLane* lane = laneCov.first;
654 const std::pair<double, double>& range = laneCov.second;
655 auto leftMostOppositeLaneIt = opposite->
getLanes().rbegin();
656 for (
auto oppositeLaneIt = leftMostOppositeLaneIt;
657 oppositeLaneIt != opposite->
getLanes().rend(); ++oppositeLaneIt) {
658 if ((
int)(oppositeLaneIt - leftMostOppositeLaneIt) == nOpp) {
662 const MSLane* oppositeLane = *oppositeLaneIt;
664 vehs.insert(new_vehs.begin(), new_vehs.end());
669 #ifdef DEBUG_SURROUNDING 670 std::cout <<
SIMTIME <<
" applySubscriptionFilters() for veh '" << v->
getID() <<
"'. Found the following vehicles:\n";
671 for (
auto veh : vehs) {
672 if (veh !=
nullptr) {
673 std::cout <<
" '" << veh->getID() <<
"' on lane '" << veh->getLane()->getID() <<
"'\n";
682 auto i = vehs.begin();
683 while (i != vehs.end()) {
684 if (((*i)->getVehicleType().getVehicleClass() & s.
filterVClasses) == 0) {
693 auto i = vehs.begin();
694 while (i != vehs.end()) {
705 if (veh !=
nullptr) {
706 objIDs.insert(objIDs.end(), veh->getID());
713 auto i = objIDs.begin();
714 while (i != objIDs.end()) {
725 auto i = objIDs.begin();
726 while (i != objIDs.end()) {
741 myRemoteControlledVehicles[v->
getID()] = v;
748 myRemoteControlledPersons[p->
getID()] = p;
754 Helper::postProcessRemoteControl() {
755 for (
auto& controlled : myRemoteControlledVehicles) {
756 if (
MSNet::getInstance()->getVehicleControl().getVehicle(controlled.first) !=
nullptr) {
757 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
759 WRITE_WARNING(
"Vehicle '" + controlled.first +
"' was removed though being controlled by TraCI");
762 myRemoteControlledVehicles.clear();
763 for (
auto& controlled : myRemoteControlledPersons) {
765 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
767 WRITE_WARNING(
"Person '" + controlled.first +
"' was removed though being controlled by TraCI");
770 myRemoteControlledPersons.clear();
775 Helper::moveToXYMap(
const Position& pos,
double maxRouteDistance,
bool mayLeaveNetwork,
const std::string& origID,
const double angle,
776 double speed,
const ConstMSEdgeVector& currentRoute,
const int routePosition,
MSLane* currentLane,
double currentLanePos,
bool onRoad,
779 const MSEdge*
const currentRouteEdge = currentRoute[routePosition];
780 std::set<std::string> into;
782 shape.push_back(pos);
785 std::map<MSLane*, LaneUtility> lane2utility;
787 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
789 const MSEdge* prevEdge =
nullptr;
790 const MSEdge* nextEdge =
nullptr;
791 bool onRoute =
false;
795 #ifdef DEBUG_MOVEXY_ANGLE 796 std::cout <<
"Ego on normal" << std::endl;
802 ConstMSEdgeVector::const_iterator searchStart = currentRoute.begin() + routePosition;
806 ConstMSEdgeVector::const_iterator edgePos = std::find(searchStart, currentRoute.end(), e);
807 onRoute = edgePos != currentRoute.end();
808 if (edgePos == currentRoute.end() - 1 && currentRouteEdge == e) {
814 nextEdge = !onRoute || edgePos == currentRoute.end() - 1 ? nullptr : *(edgePos + 1);
815 #ifdef DEBUG_MOVEXY_ANGLE 816 std::cout <<
"normal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:";
818 std::cout << nextEdge->
getID();
820 std::cout << std::endl;
823 #ifdef DEBUG_MOVEXY_ANGLE 824 std::cout <<
"Ego on internal" << std::endl;
829 while (prevEdge !=
nullptr && prevEdge->
isInternal()) {
832 prevEdge = l ==
nullptr ? nullptr : &l->
getEdge();
835 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin() + routePosition, currentRoute.end(), prevEdge);
837 while (nextEdge !=
nullptr && nextEdge->isInternal()) {
840 if (prevEdgePos != currentRoute.end() && (prevEdgePos + 1) != currentRoute.end()) {
841 onRoute = *(prevEdgePos + 1) == nextEdge;
843 #ifdef DEBUG_MOVEXY_ANGLE 844 std::cout <<
"internal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:" << nextEdge->getID() << std::endl;
850 const std::vector<MSLane*>& lanes = e->
getLanes();
851 const bool perpendicular =
false;
852 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
854 double langle = 180.;
856 double perpendicularDist =
FAR_AWAY;
875 if (mayLeaveNetwork && dist != perpendicularDist) {
880 #ifdef DEBUG_MOVEXY_ANGLE 881 std::cout << lane->
getID() <<
" lAngle:" << langle <<
" lLength=" << lane->
getLength()
882 <<
" angleDiff:" << angleDiff
884 <<
" pDist=" << perpendicularDist
886 <<
" dist2=" << dist2
891 dist2, perpendicularDist, off, angleDiff,
893 onRoute, sameEdge, prevEdge, nextEdge);
901 double bestValue = 0;
902 MSLane* bestLane =
nullptr;
903 for (std::map<MSLane*, LaneUtility>::iterator i = lane2utility.begin(); i != lane2utility.end(); ++i) {
906 double distN = u.
dist > 999 ? -10 : 1. - (u.
dist / maxDist);
907 double angleDiffN = 1. - (u.
angleDiff / 180.);
908 double idN = u.
ID ? 1 : 0;
909 double onRouteN = u.
onRoute ? 1 : 0;
911 double value = (distN * .5
917 std::cout <<
" x; l:" << l->
getID() <<
" d:" << u.
dist <<
" dN:" << distN <<
" aD:" << angleDiffN <<
918 " ID:" << idN <<
" oRN:" << onRouteN <<
" sEN:" << sameEdgeN <<
" value:" << value << std::endl;
920 if (value > bestValue || bestLane ==
nullptr) {
930 if (bestLane ==
nullptr) {
933 const LaneUtility& u = lane2utility.find(bestLane)->second;
934 bestDistance = u.
dist;
939 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin(), currentRoute.end(), prevEdge);
940 routeOffset = (int)std::distance(currentRoute.begin(), prevEdgePos);
953 #ifdef DEBUG_MOVEXY_ANGLE 963 if (edge ==
nullptr) {
966 const std::vector<MSLane*>& lanes = edge->
getLanes();
967 bool newBest =
false;
968 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
969 MSLane* candidateLane = *k;
972 std::cout <<
" b at lane " << candidateLane->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
974 if (dist < bestDistance) {
977 *lane = candidateLane;
986 Helper::moveToXYMap_matchingRoutePosition(
const Position& pos,
const std::string& origID,
988 double& bestDistance,
MSLane** lane,
double& lanePos,
int& routeOffset) {
995 const MSEdge* prev =
nullptr;
996 for (
int i = routeIndex; i < (int)currentRoute.size(); ++i) {
997 const MSEdge* cand = currentRoute[i];
998 while (prev !=
nullptr) {
1001 findCloserLane(internalCand, pos, bestDistance, lane);
1002 prev = internalCand;
1004 if (findCloserLane(cand, pos, bestDistance, lane)) {
1010 const MSEdge* next = currentRoute[routeIndex];
1011 for (
int i = routeIndex; i >= 0; --i) {
1012 const MSEdge* cand = currentRoute[i];
1015 while (prev !=
nullptr) {
1018 if (findCloserLane(internalCand, pos, bestDistance, lane)) {
1021 prev = internalCand;
1023 if (findCloserLane(cand, pos, bestDistance, lane)) {
1031 if (lane ==
nullptr) {
1033 std::cout <<
" b failed - no best route lane" << std::endl;
1041 if (!(*lane)->getEdge().isInternal()) {
1042 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1043 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1052 (*lane)->interpolateGeometryPosToLanePos(
1053 (*lane)->getShape().nearest_offset_to_point2D(pos,
false))));
1056 std::cout <<
" b ok lane " << (*lane)->getID() <<
" lanePos:" << lanePos << std::endl;
1063 :
VariableWrapper(handler), myResults(into), myContextResults(context), myActiveResults(into) {
1076 myActiveResults[objID][variable] = std::make_shared<TraCIDouble>(value);
1090 myActiveResults[objID][variable] = std::make_shared<TraCIString>(value);
1097 auto sl = std::make_shared<TraCIStringList>();
1106 myActiveResults[objID][variable] = std::make_shared<TraCIPosition>(value);
1113 myActiveResults[objID][variable] = std::make_shared<TraCIColor>(value);
1120 myVehicleStateChanges[to].push_back(vehicle->
getID());
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.
#define CMD_SUBSCRIBE_VEHICLE_CONTEXT
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.
#define CMD_GET_TL_VARIABLE
#define CMD_SUBSCRIBE_JUNCTION_CONTEXT
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...
double z() const
Returns the z-position.
#define CMD_GET_VEHICLE_VARIABLE
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) ...
MSLane * getLane() const
Returns the lane the vehicle is on.
#define CMD_GET_INDUCTIONLOOP_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.
unsigned char alpha() const
Returns the alpha-amount of the color.
const double SUMO_const_laneWidth
double y() const
Returns the y-position.
double getPositionOnLane() const
Get the vehicle's position along the lane.
#define CMD_GET_LANEAREA_VARIABLE
#define 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).
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
std::set< MSVehicle * > getVehiclesInRange(double a, double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
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
#define CMD_SUBSCRIBE_POLYGON_CONTEXT
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
#define CMD_GET_POLYGON_VARIABLE
ContextSubscriptionResults myContextResults
std::vector< const MSEdge * > ConstMSEdgeVector
SubscriptionResults & myActiveResults
const std::string & getID() const
Returns the id.
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.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
#define CMD_GET_ROUTE_VARIABLE
A class that stores a 2D geometrical boundary.
#define CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
#define WRITE_WARNING(msg)
std::vector< std::string > getEdgeNames() const
Returns the list of names of all known edges.
std::string id
The id of the object that is subscribed.
bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)
int commandId
commandIdArg The command id of the subscription
#define CMD_SUBSCRIBE_LANE_CONTEXT
#define CMD_GET_VEHICLETYPE_VARIABLE
A road/street connecting two junctions.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
#define INVALID_DOUBLE_VALUE
int activeFilters
Active filters for the subscription (bitset,.
static double naviDegree(const double angle)
int getIndex() const
Returns the lane's index.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Representation of a vehicle.
int contextDomain
The domain ID of the context.
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
A point in 2D or 3D with translation and scaling methods.
#define CMD_GET_POI_VARIABLE
int filterVClasses
vClasses specified by the vClasses filter,
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
#define CMD_GET_LANE_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
#define CMD_GET_SIM_VARIABLE
#define CMD_GET_EDGE_VARIABLE
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.
SubscriptionResults myResults
Boundary & grow(double by)
extends the boundary by the given amount
#define CMD_SUBSCRIBE_EDGE_CONTEXT
#define CMD_GET_JUNCTION_VARIABLE
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
VehicleState
Definition of a vehicle state.
#define LAST_STEP_VEHICLE_NUMBER
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.
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
#define CMD_SUBSCRIBE_PERSON_CONTEXT
unsigned char green() const
Returns the green-amount of the color.
std::vector< int > variables
The subscribed variables.
#define CMD_GET_MULTIENTRYEXIT_VARIABLE
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.
const std::string SUMO_PARAM_ORIGID
unsigned char red() const
Returns the red-amount of the color.
MSEdgeControl & getEdgeControl()
Returns the edge control.
static MSVehicle * getVehicle(const std::string &id)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
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
const std::string & getID() const
Returns the name of the vehicle.
#define CMD_SUBSCRIBE_POI_CONTEXT
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...
virtual const std::string & getID() const =0
Get the vehicle's ID.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
static const Position INVALID
used to indicate that a position is valid
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
std::vector< int > filterLanes
lanes specified by the lanes filter
void setContext(const std::string &refID)