SUMO - Simulation of Urban MObility
Helper.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Helper of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2017-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // C++ TraCI client API implementation
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <utils/geom/GeomHelper.h>
31 #include <microsim/MSNet.h>
34 #include <microsim/MSEdgeControl.h>
36 #include <microsim/MSEdge.h>
37 #include <microsim/MSLane.h>
38 #include <microsim/MSVehicle.h>
41 #include <libsumo/TraCIDefs.h>
42 #include <libsumo/InductionLoop.h>
43 #include <libsumo/Junction.h>
44 #include <libsumo/POI.h>
45 #include <libsumo/Polygon.h>
47 #include "Helper.h"
48 
49 #define FAR_AWAY 1000.0
50 
51 //#define DEBUG_MOVEXY
52 //#define DEBUG_MOVEXY_ANGLE
53 
54 
55 void
56 LaneStoringVisitor::add(const MSLane* const l) const {
57  switch (myDomain) {
59  const MSLane::VehCont& vehs = l->getVehiclesSecure();
60  for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
61  if (myShape.distance2D((*j)->getPosition()) <= myRange) {
62  myIDs.insert((*j)->getID());
63  }
64  }
65  l->releaseVehicles();
66  }
67  break;
69  l->getVehiclesSecure();
70  std::vector<MSTransportable*> persons = l->getEdge().getSortedPersons(MSNet::getInstance()->getCurrentTimeStep(), true);
71  for (auto p : persons) {
72  if (myShape.distance2D(p->getPosition()) <= myRange) {
73  myIDs.insert(p->getID());
74  }
75  }
76  l->releaseVehicles();
77  }
78  break;
79  case CMD_GET_EDGE_VARIABLE: {
80  if (myShape.size() != 1 || l->getShape().distance2D(myShape[0]) <= myRange) {
81  myIDs.insert(l->getEdge().getID());
82  }
83  }
84  break;
85  case CMD_GET_LANE_VARIABLE: {
86  if (myShape.size() != 1 || l->getShape().distance2D(myShape[0]) <= myRange) {
87  myIDs.insert(l->getID());
88  }
89  }
90  break;
91  default:
92  break;
93 
94  }
95 }
96 
97 namespace libsumo {
98 // ===========================================================================
99 // static member definitions
100 // ===========================================================================
101 std::map<int, NamedRTree*> Helper::myObjects;
102 LANE_RTREE_QUAL* Helper::myLaneTree;
103 std::map<std::string, MSVehicle*> Helper::myRemoteControlledVehicles;
104 std::map<std::string, MSPerson*> Helper::myRemoteControlledPersons;
105 
106 // ===========================================================================
107 // member definitions
108 // ===========================================================================
110 Helper::makeTraCIPositionVector(const PositionVector& positionVector) {
112  for (int i = 0; i < (int)positionVector.size(); ++i) {
113  tp.push_back(makeTraCIPosition(positionVector[i]));
114  }
115  return tp;
116 }
117 
118 
120 Helper::makePositionVector(const TraCIPositionVector& vector) {
121  PositionVector pv;
122  for (int i = 0; i < (int)vector.size(); i++) {
123  pv.push_back(Position(vector[i].x, vector[i].y));
124  }
125  return pv;
126 }
127 
128 
130 Helper::makeTraCIColor(const RGBColor& color) {
131  TraCIColor tc;
132  tc.a = color.alpha();
133  tc.b = color.blue();
134  tc.g = color.green();
135  tc.r = color.red();
136  return tc;
137 }
138 
139 
140 RGBColor
141 Helper::makeRGBColor(const TraCIColor& c) {
142  return RGBColor((unsigned char)c.r, (unsigned char)c.g, (unsigned char)c.b, (unsigned char)c.a);
143 }
144 
145 
147 Helper::makeTraCIPosition(const Position& position) {
148  TraCIPosition p;
149  p.x = position.x();
150  p.y = position.y();
151  p.z = position.z();
152  return p;
153 }
154 
155 
156 Position
157 Helper::makePosition(const TraCIPosition& tpos) {
158  Position p;
159  p.set(tpos.x, tpos.y, tpos.z);
160  return p;
161 }
162 
163 
164 MSEdge*
165 Helper::getEdge(const std::string& edgeID) {
166  MSEdge* edge = MSEdge::dictionary(edgeID);
167  if (edge == 0) {
168  throw TraCIException("Referenced edge '" + edgeID + "' is not known.");
169  }
170  return edge;
171 }
172 
173 
174 const MSLane*
175 Helper::getLaneChecking(const std::string& edgeID, int laneIndex, double pos) {
176  const MSEdge* edge = MSEdge::dictionary(edgeID);
177  if (edge == 0) {
178  throw TraCIException("Unknown edge " + edgeID);
179  }
180  if (laneIndex < 0 || laneIndex >= (int)edge->getLanes().size()) {
181  throw TraCIException("Invalid lane index for " + edgeID);
182  }
183  const MSLane* lane = edge->getLanes()[laneIndex];
184  if (pos < 0 || pos > lane->getLength()) {
185  throw TraCIException("Position on lane invalid");
186  }
187  return lane;
188 }
189 
190 
191 std::pair<MSLane*, double>
192 Helper::convertCartesianToRoadMap(Position pos) {
194  std::pair<MSLane*, double> result;
195  std::vector<std::string> allEdgeIds;
196  double minDistance = std::numeric_limits<double>::max();
197 
198  allEdgeIds = MSNet::getInstance()->getEdgeControl().getEdgeNames();
199  for (std::vector<std::string>::iterator itId = allEdgeIds.begin(); itId != allEdgeIds.end(); itId++) {
200  const std::vector<MSLane*>& allLanes = MSEdge::dictionary((*itId))->getLanes();
201  for (std::vector<MSLane*>::const_iterator itLane = allLanes.begin(); itLane != allLanes.end(); itLane++) {
202  const double newDistance = (*itLane)->getShape().distance2D(pos);
203  if (newDistance < minDistance) {
204  minDistance = newDistance;
205  result.first = (*itLane);
206  }
207  }
208  }
209  // @todo this may be a place where 3D is required but 2D is delivered
210  result.second = result.first->getShape().nearest_offset_to_point2D(pos, false);
211  return result;
212 }
213 
214 void
215 Helper::cleanup() {
216  for (std::map<int, NamedRTree*>::const_iterator i = myObjects.begin(); i != myObjects.end(); ++i) {
217  delete(*i).second;
218  }
219  myObjects.clear();
220  delete myLaneTree;
221  myLaneTree = 0;
222 }
223 
224 
225 void
226 Helper::collectObjectsInRange(int domain, const PositionVector& shape, double range, std::set<std::string>& into) {
227  // build the look-up tree if not yet existing
228  if (myObjects.find(domain) == myObjects.end()) {
229  switch (domain) {
231  myObjects[CMD_GET_INDUCTIONLOOP_VARIABLE] = InductionLoop::getTree();
232  break;
237  myObjects[CMD_GET_EDGE_VARIABLE] = 0;
238  myObjects[CMD_GET_LANE_VARIABLE] = 0;
239  myObjects[CMD_GET_PERSON_VARIABLE] = 0;
240  myObjects[CMD_GET_VEHICLE_VARIABLE] = 0;
241  myLaneTree = new LANE_RTREE_QUAL(&MSLane::visit);
242  MSLane::fill(*myLaneTree);
243  break;
245  myObjects[CMD_GET_POI_VARIABLE] = POI::getTree();
246  break;
248  myObjects[CMD_GET_POLYGON_VARIABLE] = Polygon::getTree();
249  break;
251  myObjects[CMD_GET_JUNCTION_VARIABLE] = Junction::getTree();
252  break;
253  default:
254  break;
255  }
256  }
257  const Boundary b = shape.getBoxBoundary().grow(range);
258  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
259  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
260  switch (domain) {
265  Named::StoringVisitor sv(into);
266  myObjects[domain]->Search(cmin, cmax, sv);
267  }
268  break;
273  LaneStoringVisitor sv(into, shape, range, domain);
274  myLaneTree->Search(cmin, cmax, sv);
275  }
276  break;
277  default:
278  break;
279  }
280 }
281 
282 void
283 Helper::setRemoteControlled(MSVehicle* v, Position xyPos, MSLane* l, double pos, double posLat, double angle,
284  int edgeOffset, ConstMSEdgeVector route, SUMOTime t) {
285  myRemoteControlledVehicles[v->getID()] = v;
286  v->getInfluencer().setRemoteControlled(xyPos, l, pos, posLat, angle, edgeOffset, route, t);
287 }
288 
289 void
290 Helper::setRemoteControlled(MSPerson* p, Position xyPos, MSLane* l, double pos, double posLat, double angle,
291  int edgeOffset, ConstMSEdgeVector route, SUMOTime t) {
292  myRemoteControlledPersons[p->getID()] = p;
293  p->getInfluencer().setRemoteControlled(xyPos, l, pos, posLat, angle, edgeOffset, route, t);
294 }
295 
296 
297 void
298 Helper::postProcessRemoteControl() {
299  for (auto& controlled : myRemoteControlledVehicles) {
300  if (MSNet::getInstance()->getVehicleControl().getVehicle(controlled.first) != 0) {
301  controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
302  } else {
303  WRITE_WARNING("Vehicle '" + controlled.first + "' was removed though being controlled by TraCI");
304  }
305  }
306  myRemoteControlledVehicles.clear();
307  for (auto& controlled : myRemoteControlledPersons) {
308  if (MSNet::getInstance()->getPersonControl().get(controlled.first) != 0) {
309  controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
310  } else {
311  WRITE_WARNING("Person '" + controlled.first + "' was removed though being controlled by TraCI");
312  }
313  }
314  myRemoteControlledPersons.clear();
315 }
316 
317 
318 bool
319 Helper::moveToXYMap(const Position& pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string& origID, const double angle,
320  double speed, const ConstMSEdgeVector& currentRoute, const int routePosition, MSLane* currentLane, double currentLanePos, bool onRoad,
321  double& bestDistance, MSLane** lane, double& lanePos, int& routeOffset, ConstMSEdgeVector& edges) {
322  // collect edges around the vehicle/person
323  const MSEdge* const currentRouteEdge = currentRoute[routePosition];
324  std::set<std::string> into;
325  PositionVector shape;
326  shape.push_back(pos);
327  collectObjectsInRange(CMD_GET_EDGE_VARIABLE, shape, maxRouteDistance, into);
328  double maxDist = 0;
329  std::map<MSLane*, LaneUtility> lane2utility;
330  // compute utility for all candidate edges
331  for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
332  const MSEdge* const e = MSEdge::dictionary(*j);
333  const MSEdge* prevEdge = 0;
334  const MSEdge* nextEdge = 0;
335  bool onRoute = false;
336  // the next if/the clause sets "onRoute", "prevEdge", and "nextEdge", depending on
337  // whether the currently seen edge is an internal one or a normal one
338  if (!e->isInternal()) {
339 #ifdef DEBUG_MOVEXY_ANGLE
340  std::cout << "Ego on normal" << std::endl;
341 #endif
342  // a normal edge
343  //
344  // check whether the currently seen edge is in the vehicle's route
345  // - either the one it's on or one of the next edges
346  ConstMSEdgeVector::const_iterator searchStart = currentRoute.begin() + routePosition;
347  if (onRoad && currentLane->getEdge().isInternal()) {
348  ++searchStart;
349  }
350  ConstMSEdgeVector::const_iterator edgePos = std::find(searchStart, currentRoute.end(), e);
351  onRoute = edgePos != currentRoute.end(); // no? -> onRoute is false
352  if (edgePos == currentRoute.end() - 1 && currentRouteEdge == e) {
353  // onRoute is false as well if the vehicle is beyond the edge
354  onRoute &= currentRouteEdge->getLength() > currentLanePos + SPEED2DIST(speed);
355  }
356  // save prior and next edges
357  prevEdge = e;
358  nextEdge = !onRoute || edgePos == currentRoute.end() - 1 ? 0 : *(edgePos + 1);
359 #ifdef DEBUG_MOVEXY_ANGLE
360  std::cout << "normal:" << e->getID() << " prev:" << prevEdge->getID() << " next:";
361  if (nextEdge != 0) {
362  std::cout << nextEdge->getID();
363  }
364  std::cout << std::endl;
365 #endif
366  } else {
367 #ifdef DEBUG_MOVEXY_ANGLE
368  std::cout << "Ego on internal" << std::endl;
369 #endif
370  // an internal edge
371  // get the previous edge
372  prevEdge = e;
373  while (prevEdge != 0 && prevEdge->isInternal()) {
374  MSLane* l = prevEdge->getLanes()[0];
375  l = l->getLogicalPredecessorLane();
376  prevEdge = l == 0 ? 0 : &l->getEdge();
377  }
378  // check whether the previous edge is on the route (was on the route)
379  ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin() + routePosition, currentRoute.end(), prevEdge);
380  nextEdge = e;
381  while (nextEdge != 0 && nextEdge->isInternal()) {
382  nextEdge = nextEdge->getSuccessors()[0]; // should be only one for an internal edge
383  }
384  if (prevEdgePos != currentRoute.end() && (prevEdgePos + 1) != currentRoute.end()) {
385  onRoute = *(prevEdgePos + 1) == nextEdge;
386  }
387 #ifdef DEBUG_MOVEXY_ANGLE
388  std::cout << "internal:" << e->getID() << " prev:" << prevEdge->getID() << " next:" << nextEdge->getID() << std::endl;
389 #endif
390  }
391 
392 
393  // weight the lanes...
394  const std::vector<MSLane*>& lanes = e->getLanes();
395  const bool perpendicular = false;
396  for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
397  MSLane* lane = *k;
398  double langle = 180.;
399  double dist = FAR_AWAY;
400  double perpendicularDist = FAR_AWAY;
401  double off = lane->getShape().nearest_offset_to_point2D(pos, true);
402  if (off != GeomHelper::INVALID_OFFSET) {
403  perpendicularDist = lane->getShape().distance2D(pos, true);
404  }
405  off = lane->getShape().nearest_offset_to_point2D(pos, perpendicular);
406  if (off != GeomHelper::INVALID_OFFSET) {
407  dist = lane->getShape().distance2D(pos, perpendicular);
408  langle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(off));
409  }
410  bool sameEdge = onRoad && &lane->getEdge() == &currentLane->getEdge() && currentRouteEdge->getLength() > currentLanePos + SPEED2DIST(speed);
411  /*
412  const MSEdge* rNextEdge = nextEdge;
413  while(rNextEdge==0&&lane->getEdge().getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL) {
414  MSLane* next = lane->getLinkCont()[0]->getLane();
415  rNextEdge = next == 0 ? 0 : &next->getEdge();
416  }
417  */
418  double dist2 = dist;
419  if (mayLeaveNetwork && dist != perpendicularDist) {
420  // ambiguous mapping. Don't trust this
421  dist2 = FAR_AWAY;
422  }
423  const double angleDiff = (angle == INVALID_DOUBLE_VALUE ? 0 : GeomHelper::getMinAngleDiff(angle, langle));
424 #ifdef DEBUG_MOVEXY_ANGLE
425  std::cout << lane->getID() << " lAngle:" << langle << " lLength=" << lane->getLength()
426  << " angleDiff:" << angleDiff
427  << " off:" << off
428  << " pDist=" << perpendicularDist
429  << " dist=" << dist
430  << " dist2=" << dist2
431  << "\n";
432  std::cout << lane->getID() << " param=" << lane->getParameter(SUMO_PARAM_ORIGID, lane->getID()) << " origID='" << origID << "\n";
433 #endif
434  lane2utility[lane] = LaneUtility(
435  dist2, perpendicularDist, off, angleDiff,
436  lane->getParameter(SUMO_PARAM_ORIGID, lane->getID()) == origID,
437  onRoute, sameEdge, prevEdge, nextEdge);
438  // update scaling value
439  maxDist = MAX2(maxDist, MIN2(dist, SUMO_const_laneWidth));
440 
441  }
442  }
443 
444  // get the best lane given the previously computed values
445  double bestValue = 0;
446  MSLane* bestLane = 0;
447  for (std::map<MSLane*, LaneUtility>::iterator i = lane2utility.begin(); i != lane2utility.end(); ++i) {
448  MSLane* l = (*i).first;
449  const LaneUtility& u = (*i).second;
450  double distN = u.dist > 999 ? -10 : 1. - (u.dist / maxDist);
451  double angleDiffN = 1. - (u.angleDiff / 180.);
452  double idN = u.ID ? 1 : 0;
453  double onRouteN = u.onRoute ? 1 : 0;
454  double sameEdgeN = u.sameEdge ? MIN2(currentRouteEdge->getLength() / speed, (double)1.) : 0;
455  double value = (distN * .5 // distance is more important than angle because the vehicle might be driving in the opposite direction
456  + angleDiffN * 0.35 /*.5 */
457  + idN * 1
458  + onRouteN * 0.1
459  + sameEdgeN * 0.1);
460 #ifdef DEBUG_MOVEXY
461  std::cout << " x; l:" << l->getID() << " d:" << u.dist << " dN:" << distN << " aD:" << angleDiffN <<
462  " ID:" << idN << " oRN:" << onRouteN << " sEN:" << sameEdgeN << " value:" << value << std::endl;
463 #endif
464  if (value > bestValue || bestLane == 0) {
465  bestValue = value;
466  if (u.dist == FAR_AWAY) {
467  bestLane = 0;
468  } else {
469  bestLane = l;
470  }
471  }
472  }
473  // no best lane found, return
474  if (bestLane == 0) {
475  return false;
476  }
477  const LaneUtility& u = lane2utility.find(bestLane)->second;
478  bestDistance = u.dist;
479  *lane = bestLane;
480  lanePos = bestLane->getShape().nearest_offset_to_point2D(pos, false);
481  const MSEdge* prevEdge = u.prevEdge;
482  if (u.onRoute) {
483  ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin(), currentRoute.end(), prevEdge);
484  routeOffset = (int)std::distance(currentRoute.begin(), prevEdgePos);
485  //std::cout << SIMTIME << "moveToXYMap vehicle=" << veh.getID() << " currLane=" << veh.getLane()->getID() << " routeOffset=" << routeOffset << " edges=" << toString(ev) << " bestLane=" << bestLane->getID() << " prevEdge=" << prevEdge->getID() << "\n";
486  } else {
487  edges.push_back(u.prevEdge);
488  /*
489  if(bestLane->getEdge().getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) {
490  edges.push_back(&bestLane->getEdge());
491  }
492  */
493  if (u.nextEdge != 0) {
494  edges.push_back(u.nextEdge);
495  }
496  routeOffset = 0;
497 #ifdef DEBUG_MOVEXY_ANGLE
498  std::cout << "internal2: lane=" << bestLane->getID() << " prev=" << Named::getIDSecure(u.prevEdge) << " next=" << Named::getIDSecure(u.nextEdge) << "\n";;
499 #endif
500  }
501  return true;
502 }
503 
504 
505 bool
506 Helper::findCloserLane(const MSEdge* edge, const Position& pos, double& bestDistance, MSLane** lane) {
507  if (edge == 0) {
508  return false;
509  }
510  const std::vector<MSLane*>& lanes = edge->getLanes();
511  bool newBest = false;
512  for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance > POSITION_EPS; ++k) {
513  MSLane* candidateLane = *k;
514  const double dist = candidateLane->getShape().distance2D(pos); // get distance
515 #ifdef DEBUG_MOVEXY
516  std::cout << " b at lane " << candidateLane->getID() << " dist:" << dist << " best:" << bestDistance << std::endl;
517 #endif
518  if (dist < bestDistance) {
519  // is the new distance the best one? keep then...
520  bestDistance = dist;
521  *lane = candidateLane;
522  newBest = true;
523  }
524  }
525  return newBest;
526 }
527 
528 bool
529 Helper::moveToXYMap_matchingRoutePosition(const Position& pos, const std::string& origID,
530  const ConstMSEdgeVector& currentRoute, int routeIndex,
531  double& bestDistance, MSLane** lane, double& lanePos, int& routeOffset) {
532  routeOffset = 0;
533  // routes may be looped which makes routeOffset ambiguous. We first try to
534  // find the closest upcoming edge on the route and then look for closer passed edges
535 
536  // look forward along the route
537  const MSEdge* prev = 0;
538  for (int i = routeIndex; i < (int)currentRoute.size(); ++i) {
539  const MSEdge* cand = currentRoute[i];
540  while (prev != 0) {
541  // check internal edge(s)
542  const MSEdge* internalCand = prev->getInternalFollowingEdge(cand);
543  findCloserLane(internalCand, pos, bestDistance, lane);
544  prev = internalCand;
545  }
546  if (findCloserLane(cand, pos, bestDistance, lane)) {
547  routeOffset = i;
548  }
549  prev = cand;
550  }
551  // look backward along the route
552  const MSEdge* next = currentRoute[routeIndex];
553  for (int i = routeIndex; i > 0; --i) {
554  const MSEdge* cand = currentRoute[i];
555  prev = cand;
556  while (prev != 0) {
557  // check internal edge(s)
558  const MSEdge* internalCand = prev->getInternalFollowingEdge(next);
559  findCloserLane(internalCand, pos, bestDistance, lane);
560  prev = internalCand;
561  }
562  if (findCloserLane(cand, pos, bestDistance, lane)) {
563  routeOffset = i;
564  }
565  next = cand;
566  }
567 
568  assert(lane != 0);
569  // quit if no solution was found, reporting a failure
570  if (lane == 0) {
571 #ifdef DEBUG_MOVEXY
572  std::cout << " b failed - no best route lane" << std::endl;
573 #endif
574  return false;
575  }
576 
577 
578  // position may be inaccurate; let's checkt the given index, too
579  // @note: this is enabled for non-internal lanes only, as otherwise the position information may ambiguous
580  if (!(*lane)->getEdge().isInternal()) {
581  const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
582  for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
583  if ((*i)->getParameter(SUMO_PARAM_ORIGID, (*i)->getID()) == origID) {
584  *lane = *i;
585  break;
586  }
587  }
588  }
589  // check position, stuff, we should have the best lane along the route
590  lanePos = MAX2(0., MIN2(double((*lane)->getLength() - POSITION_EPS),
591  (*lane)->interpolateGeometryPosToLanePos(
592  (*lane)->getShape().nearest_offset_to_point2D(pos, false))));
593  //std::cout << SIMTIME << " moveToXYMap_matchingRoutePosition vehicle=" << veh.getID() << " currLane=" << veh.getLane()->getID() << " routeOffset=" << routeOffset << " edges=" << toString(edges) << " lane=" << (*lane)->getID() << "\n";
594 #ifdef DEBUG_MOVEXY
595  std::cout << " b ok lane " << (*lane)->getID() << " lanePos:" << lanePos << std::endl;
596 #endif
597  return true;
598 }
599 
600 }
601 
602 
603 /****************************************************************************/
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
Definition: GeomHelper.cpp:167
unsigned char g
Definition: TraCIDefs.h:79
const MSEdge * prevEdge
Definition: Helper.h:212
#define FAR_AWAY
Definition: Helper.cpp:49
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2256
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:137
const MSEdge * nextEdge
Definition: Helper.h:213
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:131
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:607
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
#define SPEED2DIST(x)
Definition: SUMOTime.h:54
const int myDomain
Definition: Helper.h:68
double z() const
Returns the z-position.
Definition: Position.h:72
#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) ...
#define LANE_RTREE_QUAL
Definition: Helper.h:78
#define CMD_GET_INDUCTIONLOOP_VARIABLE
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1679
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:89
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
double y() const
Returns the y-position.
Definition: Position.h:67
#define CMD_GET_PERSON_VARIABLE
double x() const
Returns the x-position.
Definition: Position.h:62
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:539
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:167
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
T MAX2(T a, T b)
Definition: StdDefs.h:73
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1059
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:497
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:392
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:439
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:67
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:744
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:82
#define CMD_GET_POLYGON_VARIABLE
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
const std::string & getID() const
Returns the id.
Definition: Named.h:74
void set(double x, double y)
set positions x and y
Definition: Position.h:92
double getLength() const
return the length of the edge
Definition: MSEdge.h:569
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge&#39;s persons sorted by pos.
Definition: MSEdge.cpp:876
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
std::vector< std::string > getEdgeNames() const
Returns the list of names of all known edges.
unsigned char b
Definition: TraCIDefs.h:79
A road/street connecting two junctions.
Definition: MSEdge.h:80
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:186
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:513
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
#define CMD_GET_POI_VARIABLE
A list of positions.
unsigned char a
Definition: TraCIDefs.h:79
const double myRange
Definition: Helper.h:67
#define CMD_GET_LANE_VARIABLE
void add(const MSLane *const l) const
Adds the given object to the container.
Definition: Helper.cpp:56
T MIN2(T a, T b)
Definition: StdDefs.h:67
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:125
#define POSITION_EPS
Definition: config.h:175
const std::string & getID() const
returns the id of the transportable
#define CMD_GET_EDGE_VARIABLE
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
unsigned char r
Definition: TraCIDefs.h:79
#define CMD_GET_JUNCTION_VARIABLE
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:58
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSVehicle.cpp:459
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:229
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:89
Definition: Edge.cpp:31
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
Definition: MSEdge.cpp:656
#define INVALID_DOUBLE_VALUE
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:90
std::set< std::string > & myIDs
The container.
Definition: Helper.h:65
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:4812
const PositionVector & myShape
Definition: Helper.h:66
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:75
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
const MSEdgeVector & getSuccessors() const
Returns the following edges.
Definition: MSEdge.h:319
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:68
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition: MSNet.h:349
long long int SUMOTime
Definition: TraCIDefs.h:51
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:143
A 3D-position.
Definition: TraCIDefs.h:71
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:419
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.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
A list of positions.