Eclipse SUMO - Simulation of Urban MObility
MSLane.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
22 // Representation of a lane in the micro simulation
23 /****************************************************************************/
24 #ifndef MSLane_h
25 #define MSLane_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #include <config.h>
32 
33 #include <memory>
34 #include <vector>
35 #include <map>
36 #include <deque>
37 #include <cassert>
38 #include <utils/common/Named.h>
44 #include "MSLinkCont.h"
45 #include "MSLeaderInfo.h"
46 #include "MSMoveReminder.h"
47 #include <libsumo/Helper.h>
48 
50 #ifdef HAVE_FOX
52 #endif
53 
54 
55 // ===========================================================================
56 // class declarations
57 // ===========================================================================
58 class MSEdge;
59 class MSVehicle;
60 class MSLaneChanger;
61 class MSLink;
62 class MSVehicleTransfer;
63 class MSVehicleControl;
64 class OutputDevice;
66 
67 // ===========================================================================
68 // type definitions
69 // ===========================================================================
71 typedef std::map<const MSLane*, std::pair<double, double> > LaneCoverageInfo; // also declared in libsumo/Helper.h!
72 
73 // ===========================================================================
74 // class definitions
75 // ===========================================================================
83 class MSLane : public Named, public Parameterised {
84 public:
86  friend class MSLaneChanger;
87  friend class MSLaneChangerSublane;
88 
89  friend class MSQueueExport;
90  friend class AnyVehicleIterator;
91 
93  typedef std::vector<MSVehicle*> VehCont;
94 
97  struct VehPosition : public std::binary_function < const MSVehicle*, double, bool > {
99  bool operator()(const MSVehicle* cmp, double pos) const;
100  };
101 
102  // TODO: Better documentation
111  public:
113  const MSLane* lane,
114  int i1,
115  int i2,
116  int i3,
117  const int i1End,
118  const int i2End,
119  const int i3End,
120  bool downstream = true) :
121  myLane(lane),
122  myI1(i1),
123  myI2(i2),
124  myI3(i3),
125  myI1End(i1End),
126  myI2End(i2End),
127  myI3End(i3End),
128  myDownstream(downstream),
129  myDirection(downstream ? 1 : -1) {
130  }
131 
132  bool operator== (AnyVehicleIterator const& other) const {
133  return (myI1 == other.myI1
134  && myI2 == other.myI2
135  && myI3 == other.myI3
136  && myI1End == other.myI1End
137  && myI2End == other.myI2End
138  && myI3End == other.myI3End);
139  }
140 
141  bool operator!= (AnyVehicleIterator const& other) const {
142  return !(*this == other);
143  }
144 
146  return **this;
147  }
148 
149  const MSVehicle* operator*();
150 
151  AnyVehicleIterator& operator++();
152 
153  private:
154  bool nextIsMyVehicles() const;
155 
157  const MSLane* myLane;
159  int myI1;
161  int myI2;
163  int myI3;
165  int myI1End;
167  int myI2End;
169  int myI3End;
174 
175  };
176 
177 
178 public:
187  };
188 
203  MSLane(const std::string& id, double maxSpeed, double length, MSEdge* const edge,
204  int numericalID, const PositionVector& shape, double width,
205  SVCPermissions permissions, int index, bool isRampAccel,
206  const std::string& type);
207 
208 
210  virtual ~MSLane();
211 
213  void setRNGIndex(const int rngIndex) {
214  myRNGIndex = rngIndex;
215  }
216 
218  int getRNGIndex() const {
219  return myRNGIndex;
220  }
221 
223  std::mt19937* getRNG() const {
224  return &myRNGs[myRNGIndex];
225  }
226 
228  static int getNumRNGs() {
229  return (int)myRNGs.size();
230  }
231 
234 
242  void addLink(MSLink* link);
243 
248  void addNeigh(const std::string& id);
250 
251 
252 
255 
262  virtual void addMoveReminder(MSMoveReminder* rem);
263 
264 
268  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
269  return myMoveReminders;
270  }
272 
273 
274 
277 
293  bool insertVehicle(MSVehicle& v);
294 
295 
314  bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
315  bool recheckNextLanes,
316  MSMoveReminder::Notification notification);
317 
318  // XXX: Documentation?
319  bool checkFailure(const MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const;
320 
324  bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
325 
333  bool freeInsertion(MSVehicle& veh, double speed, double posLat,
335 
336 
346  void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
348 
349 
350 
354 
361  virtual double setPartialOccupation(MSVehicle* v);
362 
366  virtual void resetPartialOccupation(MSVehicle* v);
367 
370  virtual void setManeuverReservation(MSVehicle* v);
371 
375  virtual void resetManeuverReservation(MSVehicle* v);
376 
387  const MSLeaderInfo getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
388 
390  const MSLeaderInfo getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
391 
393 
396 
401  int getVehicleNumber() const {
402  return (int)myVehicles.size();
403  }
404 
410  return (int)myVehicles.size() + (int)myPartialVehicles.size();
411  }
412 
418  return (int)myPartialVehicles.size();
419  }
420 
421 
428  virtual const VehCont& getVehiclesSecure() const {
429  return myVehicles;
430  }
431 
432 
435  return AnyVehicleIterator(this, 0, 0, 0,
436  (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
437  }
438 
441  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(),
442  (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
443  }
444 
447  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, (int)myTmpVehicles.size() - 1,
448  -1, -1, -1, false);
449  }
450 
453  return AnyVehicleIterator(this, -1, -1, -1, -1, -1, -1, false);
454  }
455 
458  virtual void releaseVehicles() const { }
460 
461 
462 
465 
466 
470  inline int getNumericalID() const {
471  return myNumericalID;
472  }
473 
474 
478  inline const PositionVector& getShape() const {
479  return myShape;
480  }
481 
483  inline double getLengthGeometryFactor() const {
484  return myLengthGeometryFactor;
485  }
486 
488  inline bool isAccelLane() const {
489  return myIsRampAccel;
490  }
491 
493  const std::string& getLaneType() const {
494  return myLaneType;
495  }
496 
497  /* @brief fit the given lane position to a visibly suitable geometry position
498  * (lane length might differ from geometry length) */
499  inline double interpolateLanePosToGeometryPos(double lanePos) const {
500  return lanePos * myLengthGeometryFactor;
501  }
502 
503  /* @brief fit the given lane position to a visibly suitable geometry position
504  * and return the coordinates */
505  inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
506  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
507  }
508 
509  /* @brief fit the given geometry position to a valid lane position
510  * (lane length might differ from geometry length) */
511  inline double interpolateGeometryPosToLanePos(double geometryPos) const {
512  return geometryPos / myLengthGeometryFactor;
513  }
514 
519  inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh) const {
520  if (myRestrictions != 0) {
521  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
522  if (r != myRestrictions->end()) {
523  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
524  }
525  }
526  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
527  }
528 
529 
533  inline double getSpeedLimit() const {
534  return myMaxSpeed;
535  }
536 
537 
541  inline double getLength() const {
542  return myLength;
543  }
544 
545 
550  return myPermissions;
551  }
552 
553 
557  double getWidth() const {
558  return myWidth;
559  }
560 
564  int getIndex() const {
565  return myIndex;
566  }
568 
570  int getCrossingIndex() const;
571 
572 
575 
583  virtual void planMovements(const SUMOTime t);
584 
590  virtual void setJunctionApproaches(const SUMOTime t) const;
591 
600  void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
601 
612  virtual void executeMovements(const SUMOTime t);
613 
615  virtual void integrateNewVehicles();
616 
618  void updateLengthSum();
620 
621 
623  inline bool needsCollisionCheck() const {
624  return myNeedsCollisionCheck;
625  }
626 
628  inline void requireCollisionCheck() {
629  myNeedsCollisionCheck = true;
630  }
631 
633  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
634 
635 
638  virtual bool appropriate(const MSVehicle* veh);
639 
640 
642  const MSLinkCont& getLinkCont() const;
643 
645  MSLink* getLinkTo(const MSLane*) const;
646 
648  MSLink* getEntryLink() const;
649 
650 
652  bool empty() const {
653  assert(myVehBuffer.size() == 0);
654  return myVehicles.empty();
655  }
656 
660  void setMaxSpeed(double val);
661 
665  void setLength(double val);
666 
670  MSEdge& getEdge() const {
671  return *myEdge;
672  }
673 
674 
678  const MSEdge* getNextNormal() const;
679 
680 
686  const MSLane* getFirstInternalInConnection(double& offset) const;
687 
688 
691 
702  static bool dictionary(const std::string& id, MSLane* lane);
703 
704 
711  static MSLane* dictionary(const std::string& id);
712 
713 
715  static void clear();
716 
717 
721  static int dictSize() {
722  return (int)myDict.size();
723  }
724 
725 
729  static void insertIDs(std::vector<std::string>& into);
730 
731 
736  template<class RTREE>
737  static void fill(RTREE& into);
738 
739 
741  static void initRNGs(const OptionsCont& oc);
743 
744 
745 
746  // XXX: succLink does not exist... Documentation?
751  static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
752  int nRouteSuccs,
753  const MSLane& succLinkSource,
754  const std::vector<MSLane*>& conts);
755 
756 
759  bool isLinkEnd(MSLinkCont::const_iterator& i) const;
760 
763  bool isLinkEnd(MSLinkCont::iterator& i);
764 
767  bool isEmpty() const;
768 
770  bool isInternal() const;
771 
773  MSVehicle* getLastFullVehicle() const;
774 
777 
779  MSVehicle* getLastAnyVehicle() const;
780 
782  MSVehicle* getFirstAnyVehicle() const;
783 
784  /* @brief remove the vehicle from this lane
785  * @param[notify] whether moveReminders of the vehicle shall be triggered
786  */
787  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
788 
789  void leftByLaneChange(MSVehicle* v);
791 
795  MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
796 
797 
802  void setPermissions(SVCPermissions permissions, long long transientID);
803  void resetPermissions(long long transientID);
804 
805 
806  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
807  return (myPermissions & vclass) == vclass;
808  }
809 
810  void addIncomingLane(MSLane* lane, MSLink* viaLink);
811 
812 
815  double length;
817  };
818 
819  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
820  return myIncomingLanes;
821  }
822 
823 
824  void addApproachingLane(MSLane* lane, bool warnMultiCon);
825  bool isApproachedFrom(MSEdge* const edge);
826  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
827 
829  double getStopOffset(const MSVehicle* veh) const;
830 
832  const std::map<SVCPermissions, double>& getStopOffsets() const {
833  return myStopOffsets;
834  };
835 
837  void setStopOffsets(std::map<SVCPermissions, double> stopOffsets) {
838  myStopOffsets = stopOffsets;
839  };
840 
842  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
843  bool allSublanes, double searchDist = -1, bool ignoreMinorLinks = false) const;
844 
846  double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
847 
860  std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
861 
884  std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
885  double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
886 
888  void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
889  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
890 
908  std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
909 
910  /* @brief return the partial vehicle closest behind ego or 0
911  * if no such vehicle exists */
912  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
913 
916 
928  std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
929 
932  std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
933 
934 
936  std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
938  std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
939 
944 
948  const MSLane* getNormalPredecessorLane() const;
949 
952  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
953 
954 
961 
962 
969 
972 
974  const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
975 
977 
978 
982  double getMeanSpeed() const;
983 
987  double getWaitingSeconds() const;
988 
989 
993  double getBruttoOccupancy() const;
994 
995 
999  double getNettoOccupancy() const;
1000 
1001 
1005  inline double getBruttoVehLenSum() const {
1006  return myBruttoVehicleLengthSum;
1007  }
1008 
1009 
1013  double getCO2Emissions() const;
1014 
1015 
1019  double getCOEmissions() const;
1020 
1021 
1025  double getPMxEmissions() const;
1026 
1027 
1031  double getNOxEmissions() const;
1032 
1033 
1037  double getHCEmissions() const;
1038 
1039 
1043  double getFuelConsumption() const;
1044 
1045 
1049  double getElectricityConsumption() const;
1050 
1051 
1055  double getHarmonoise_NoiseEmissions() const;
1057 
1058  void setRightSideOnEdge(double value, int rightmostSublane) {
1059  myRightSideOnEdge = value;
1060  myRightmostSublane = rightmostSublane;
1061  }
1062 
1064  void initRestrictions();
1065 
1066  void checkBufferType();
1067 
1068  double getRightSideOnEdge() const {
1069  return myRightSideOnEdge;
1070  }
1071 
1072  int getRightmostSublane() const {
1073  return myRightmostSublane;
1074  }
1075 
1076  double getCenterOnEdge() const {
1077  return myRightSideOnEdge + 0.5 * myWidth;
1078  }
1079 
1081  void sortPartialVehicles();
1082 
1084  void sortManeuverReservations();
1085 
1087  MSLane* getOpposite() const;
1088 
1090  double getOppositePos(double pos) const;
1091 
1092  /* @brief find leader for a vehicle depending on the relative driving direction
1093  * @param[in] ego The ego vehicle
1094  * @param[in] dist The look-ahead distance when looking at consecutive lanes
1095  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1096  * @return the leader vehicle and it's gap to ego
1097  */
1098  std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir) const;
1099 
1100  /* @brief find follower for a vehicle that is located on the opposite of this lane
1101  * @param[in] ego The ego vehicle
1102  * @return the follower vehicle and it's gap to ego
1103  */
1104  std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1105 
1106 
1114  std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, bool ignoreMinorLinks) const;
1115 
1116 
1118  void addParking(MSVehicle* veh);
1119 
1121  virtual void removeParking(MSVehicle* veh);
1122 
1124  const std::set<const MSVehicle*>& getParkingVehicles() const {
1125  return myParkingVehicles;
1126  }
1127 
1129  virtual bool isSelected() const {
1130  return false;
1131  }
1132 
1134  MSLane* getBidiLane() const;
1135 
1137  bool mustCheckJunctionCollisions() const;
1138 
1139 #ifdef HAVE_FOX
1140  FXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1141  mySimulationTask.init(&MSLane::planMovements, time);
1142  return &mySimulationTask;
1143  }
1144 
1145  FXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1146  mySimulationTask.init(&MSLane::executeMovements, time);
1147  return &mySimulationTask;
1148  }
1149 
1150  FXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1151  mySimulationTask.init(&MSLane::changeLanes, time);
1152  return &mySimulationTask;
1153  }
1154 #endif
1155 
1156  void changeLanes(const SUMOTime time);
1157 
1160 
1168  void saveState(OutputDevice& out);
1169 
1181  void loadState(const std::vector<std::string>& vehIDs, MSVehicleControl& vc);
1183 
1184 
1192  void visit(const LaneStoringVisitor& cont) const {
1193  cont.add(this);
1194  }
1195 
1196  static void initCollisionOptions(const OptionsCont& oc);
1197 
1198  static bool teleportOnCollision() {
1200  }
1201 
1203  return myCollisionAction;
1204  }
1205 
1206  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1207  static const long CHANGE_PERMISSIONS_GUI = 1;
1208 
1209 protected:
1211  virtual void swapAfterLaneChange(SUMOTime t);
1212 
1224  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1225  const MSLane::VehCont::iterator& at,
1227 
1229  void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1230  SUMOTime timestep, const std::string& stage);
1231 
1233  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1234  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1235  std::set<const MSVehicle*>& toTeleport) const;
1236 
1238  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1239  double gap, double latGap,
1240  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1241  std::set<const MSVehicle*>& toTeleport) const;
1242 
1244  double getMaximumBrakeDist() const;
1245 
1246  /* @brief determine depart speed and whether it may be patched
1247  * @param[in] veh The departing vehicle
1248  * @param[out] whether the speed may be patched to account for safety
1249  * @return the depart speed
1250  */
1251  double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1252 
1253  /* @brief determine the lateral depart position
1254  * @param[in] veh The departing vehicle
1255  * @return the lateral depart position
1256  */
1257  double getDepartPosLat(const MSVehicle& veh);
1258 
1261  double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1262 
1264  bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1265 
1268 
1271 
1273  int myIndex;
1274 
1286  VehCont myVehicles;
1287 
1299 
1302  VehCont myTmpVehicles;
1303 
1307 
1315 
1316  /* @brief list of vehicles that are parking near this lane
1317  * (not necessarily on the road but having reached their stop on this lane)
1318  * */
1319  std::set<const MSVehicle*> myParkingVehicles;
1320 
1322  double myLength;
1323 
1325  const double myWidth;
1326 
1330  std::map<SVCPermissions, double> myStopOffsets;
1331 
1333  MSEdge* const myEdge;
1334 
1336  double myMaxSpeed;
1337 
1340 
1343 
1345  const std::map<SUMOVehicleClass, double>* myRestrictions;
1346 
1348  std::vector<IncomingLaneInfo> myIncomingLanes;
1349 
1352 
1355 
1358 
1361 
1364 
1367 
1370 
1374 
1376  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1377 
1382 
1387 
1390 
1392  const bool myIsRampAccel;
1393 
1395  const std::string myLaneType;
1396 
1401 
1404 
1405  // @brief the ids of neighboring lanes
1406  std::vector<std::string> myNeighs;
1407 
1408  // @brief transient changes in permissions
1409  std::map<long long, SVCPermissions> myPermissionChanges;
1410 
1411  // @brief index of the associated thread-rng
1413 
1415  typedef std::map< std::string, MSLane* > DictType;
1416 
1418  static DictType myDict;
1419 
1420  static std::vector<std::mt19937> myRNGs;
1421 
1422 private:
1424  std::vector< MSMoveReminder* > myMoveReminders;
1425 
1431 
1437  public:
1439  explicit vehicle_position_sorter(const MSLane* lane) :
1440  myLane(lane) {
1441  }
1442 
1443 
1449  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1450 
1451  const MSLane* myLane;
1452 
1453  };
1454 
1460  public:
1462  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1463  myLane(lane) {
1464  }
1465 
1466 
1472  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1473 
1474  const MSLane* myLane;
1475 
1476  };
1477 
1483  public:
1485  explicit by_connections_to_sorter(const MSEdge* const e);
1486 
1488  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1489 
1490  private:
1491  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1492  private:
1493  const MSEdge* const myEdge;
1494  double myLaneDir;
1495  };
1496 
1497 
1498 
1504  public:
1506  explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1507 
1509  int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1510 
1511  private:
1512  incoming_lane_priority_sorter& operator=(const incoming_lane_priority_sorter&); // just to avoid a compiler warning
1513  private:
1514  const MSLane* const myLane;
1515  double myLaneDir;
1516  };
1517 
1518 
1524  public:
1526  explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1527 
1529  int operator()(const MSLink* link1, const MSLink* link2) const;
1530 
1531  private:
1532  outgoing_lane_priority_sorter& operator=(const outgoing_lane_priority_sorter&); // just to avoid a compiler warning
1533  private:
1534  const MSLane* const myLane;
1535  double myLaneDir;
1536  };
1537 
1541  class edge_finder {
1542  public:
1543  edge_finder(MSEdge* e) : myEdge(e) {}
1544  bool operator()(const IncomingLaneInfo& ili) const {
1545  return &(ili.lane->getEdge()) == myEdge;
1546  }
1547  private:
1548  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1549  private:
1550  const MSEdge* const myEdge;
1551  };
1552 
1553 #ifdef HAVE_FOX
1554  typedef void(MSLane::*Operation)(const SUMOTime);
1556 
1561  class SimulationTask : public FXWorkerThread::Task {
1562  public:
1563  SimulationTask(MSLane& l, const SUMOTime time)
1564  : myLane(l), myTime(time) {}
1565  void init(Operation operation, const SUMOTime time) {
1566  myOperation = operation;
1567  myTime = time;
1568  }
1569  void run(FXWorkerThread* /*context*/) {
1570  try {
1571  (myLane.*(myOperation))(myTime);
1572  } catch (ProcessError& e) {
1573  WRITE_ERROR(e.what());
1574  }
1575  }
1576  private:
1577  Operation myOperation;
1578  MSLane& myLane;
1579  SUMOTime myTime;
1580  private:
1582  SimulationTask& operator=(const SimulationTask&) = delete;
1583  };
1584 
1585  SimulationTask mySimulationTask;
1587  mutable FXMutex myLeaderInfoMutex;
1589  mutable FXMutex myFollowerInfoMutex;
1590 #endif
1591 private:
1593  MSLane(const MSLane&);
1594 
1596  MSLane& operator=(const MSLane&);
1597 
1598 
1599 };
1600 
1601 
1602 #endif
1603 
1604 /****************************************************************************/
1605 
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage)
detect whether a vehicle collids with pedestrians on the junction
Definition: MSLane.cpp:1473
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:819
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) ...
Definition: MSLane.cpp:3520
void changeLanes(const SUMOTime time)
Definition: MSLane.cpp:1821
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2666
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1339
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2532
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1286
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
Definition: MSLane.cpp:1051
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:133
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2761
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:670
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long long int SUMOTime
Definition: SUMOTime.h:35
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2013
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
detect whether there is a collision between the two vehicles
Definition: MSLane.cpp:1507
static int getNumRNGs()
return the number of RNGs
Definition: MSLane.h:228
int getRNGIndex() const
returns the associated RNG index
Definition: MSLane.h:218
void sortManeuverReservations()
sorts myManeuverReservations
Definition: MSLane.cpp:1964
const MSEdge * getNextNormal() const
Returns the lane&#39;s follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1827
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1887
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1395
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...
Definition: MSLane.cpp:3368
void updateLeaderInfo(const MSVehicle *veh, VehCont::reverse_iterator &vehPart, VehCont::reverse_iterator &vehRes, MSLeaderInfo &ahead) const
This updates the MSLeaderInfo argument with respect to the given MSVehicle. All leader-vehicles on th...
Definition: MSLane.cpp:1210
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn&#39;t apply, wrt. the angle differenc...
Definition: MSLane.h:1503
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3012
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
Definition: MSLane.cpp:3539
std::map< const MSLane *, std::pair< double, double > > LaneCoverageInfo
Coverage info.
Definition: MSLane.h:65
static bool teleportOnCollision()
Definition: MSLane.h:1198
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1207
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:609
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition: MSLane.cpp:3672
int myI2
index for myPartialVehicles
Definition: MSLane.h:161
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2785
bool isInsertionSuccess(MSVehicle *vehicle, double speed, double pos, double posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
Definition: MSLane.cpp:638
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1895
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:2257
const std::string & getLaneType() const
return the type of this lane
Definition: MSLane.h:493
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:2144
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1703
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1348
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:167
std::vector< const MSJunction * > getUpcomingJunctions(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...
Definition: MSLane.cpp:3440
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:240
static std::vector< std::mt19937 > myRNGs
Definition: MSLane.h:1420
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1354
int myIndex
The lane index.
Definition: MSLane.h:1273
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane, excluding their minGaps)
Definition: MSLane.h:1369
static double myCollisionMinGapFactor
Definition: MSLane.h:1430
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1384
bool needsCollisionCheck() const
short-circut collision check if nothing changed since the last check
Definition: MSLane.h:623
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
Definition: MSLane.cpp:2826
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane...
Definition: MSLane.h:110
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1429
Notification
Definition of a vehicle state.
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition: MSLane.cpp:312
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2169
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1360
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2036
const MSEdge *const myEdge
Definition: MSLane.h:1493
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1409
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2193
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2749
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1192
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:541
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:428
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:478
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1983
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:3591
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:258
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
Definition: MSLane.cpp:2106
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2641
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:2578
FXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1306
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:246
const std::vector< MSMoveReminder *> & getMoveReminders() const
Return the list of this lane&#39;s move reminders.
Definition: MSLane.h:268
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition: MSLane.cpp:3696
virtual double getChosenSpeedFactor() const =0
const MSLeaderInfo getFirstVehicleInformation(const MSVehicle *ego, double latOffset, bool onlyFrontOnLane, double maxPos=std::numeric_limits< double >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
Definition: MSLane.cpp:1107
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:268
VehCont myPartialVehicles
The lane&#39;s partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1298
static bool myCheckJunctionCollisions
Definition: MSLane.h:1428
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.
Definition: MSLane.cpp:2187
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition: MSLane.cpp:301
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:557
int myI1End
end index for myVehicles
Definition: MSLane.h:165
int myDirection
index delta
Definition: MSLane.h:173
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1270
int myI3
index for myTmpVehicles
Definition: MSLane.h:163
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:2598
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1319
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane *> &bestLaneConts, MSLeaderDistanceInfo &result) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
Definition: MSLane.cpp:3240
bool myDownstream
iteration direction
Definition: MSLane.h:171
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:409
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition: MSLane.h:628
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
Definition: MSLane.h:1406
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1427
int getNumericalID() const
Returns this lane&#39;s numerical id.
Definition: MSLane.h:470
std::map< std::string, MSLane *> DictType
definition of the static dictionary type
Definition: MSLane.h:1415
static CollisionAction getCollisionAction()
Definition: MSLane.h:1202
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
Definition: MSLane.h:417
MSLinkCont myLinks
Definition: MSLane.h:1373
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1260
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1418
Sorts lanes (their origin link) by the priority of their noninternal target edges or...
Definition: MSLane.h:1523
std::mt19937 * getRNG() const
return the associated RNG
Definition: MSLane.h:223
bool isInternal() const
Definition: MSLane.cpp:1999
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:2203
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:48
A road/street connecting two junctions.
Definition: MSEdge.h:76
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:533
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:1005
double myLength
Lane length [m].
Definition: MSLane.h:1322
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:564
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3623
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned ...
Definition: MSLane.cpp:2557
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1302
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:3611
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
Definition: MSLane.cpp:2127
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:721
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
Definition: MSLane.cpp:2655
Export the queueing length in front of a junction (very experimental!)
Definition: MSQueueExport.h:50
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:282
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2725
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1392
const MSEdge *const myEdge
Definition: MSLane.h:1550
Representation of a vehicle.
Definition: SUMOVehicle.h:61
friend class AnyVehicleIterator
Definition: MSLane.h:90
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:2151
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:511
Sorts vehicles by their position (descending)
Definition: MSLane.h:1436
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1398
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
double getCenterOnEdge() const
Definition: MSLane.h:1076
bool lastInsertion(MSVehicle &veh, double mspeed, double posLat, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
Definition: MSLane.cpp:351
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1342
A list of positions.
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2648
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:401
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1345
bool isEmpty() const
Definition: MSLane.cpp:1994
bool checkForPedestrians(const MSVehicle *aVehicle, double &speed, double &dist, double pos, bool patchSpeed) const
check whether pedestrians on this lane interfere with vehicle insertion
Definition: MSLane.cpp:3638
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:3562
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:549
double safeInsertionSpeed(const MSVehicle *veh, double seen, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition: MSLane.cpp:1022
double getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:533
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Sorts edges by their angle relative to the given edge (straight comes first)
Definition: MSLane.h:1482
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1013
void setStopOffsets(std::map< SVCPermissions, double > stopOffsets)
Set vehicle class specific stopOffsets.
Definition: MSLane.h:837
void add(const MSLane *const l) const
Adds the given object to the container.
Definition: Helper.cpp:63
T MIN2(T a, T b)
Definition: StdDefs.h:74
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:3330
int myRNGIndex
Definition: MSLane.h:1412
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition: MSLane.h:1129
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:440
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:434
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:2619
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.
Definition: MSLane.cpp:2268
CollisionAction
Definition: MSLane.h:182
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1400
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1351
Something on a lane to be noticed about vehicle movement.
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2630
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:3499
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:446
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2158
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2773
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1376
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:93
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
Definition: MSLane.cpp:2050
const std::map< SVCPermissions, double > & getStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition: MSLane.h:832
Base class for objects which have an id.
Definition: Named.h:57
std::map< SVCPermissions, double > myStopOffsets
Definition: MSLane.h:1330
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1267
std::vector< MSMoveReminder *> myMoveReminders
This lane&#39;s move reminder.
Definition: MSLane.h:1424
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step...
Definition: MSLane.h:1314
double getRightSideOnEdge() const
Definition: MSLane.h:1068
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition: MSLane.cpp:3353
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:224
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:483
AnyVehicleIterator(const MSLane *lane, int i1, int i2, int i3, const int i1End, const int i2End, const int i3End, bool downstream=true)
Definition: MSLane.h:112
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
int getRightmostSublane() const
Definition: MSLane.h:1072
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2004
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:1956
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned. ...
Definition: MSLane.cpp:1202
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Definition: MSLane.cpp:386
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1929
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2797
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1855
The vehicle has departed (was inserted into the network)
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2737
Representation of a vehicle or person.
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane *> &bestLaneConts) const
Returns the immediate leader and the distance to him.
Definition: MSLane.cpp:2333
int myI1
index for myVehicles
Definition: MSLane.h:159
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:3508
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1544
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1878
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
Definition: MSLane.cpp:1837
void checkBufferType()
Definition: MSLane.cpp:232
int myI3End
end index for myTmpVehicles
Definition: MSLane.h:169
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1333
const MSVehicle * operator->()
Definition: MSLane.h:145
void setRNGIndex(const int rngIndex)
sets the associated RNG index
Definition: MSLane.h:213
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:157
A storage for options typed value containers)
Definition: OptionsCont.h:90
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:499
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1578
MSLane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: MSLane.cpp:179
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2022
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.cpp:2217
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2809
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition: MSLane.cpp:3045
std::pair< MSVehicle *const, double > getCriticalLeader(double dist, double seen, double speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
Definition: MSLane.cpp:2459
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:3684
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:452
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:806
MSLane & operator=(const MSLane &)
invalidated assignment operator
const std::set< const MSVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition: MSLane.h:1124
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:3017
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1379
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:3030
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1357
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
Abstract superclass of a task to be run with an index to keep track of pending tasks.
size_t size() const
Definition: FXSynchQue.h:134
A thread repeatingly calculating incoming tasks.
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1363
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2709
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1381
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:216
virtual double getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
Definition: MSLane.cpp:3006
The class responsible for building and deletion of vehicles.
double getMissingRearGap(const MSVehicle *leader, double backOffset, double leaderSpeed) const
return by how much further the leader must be inserted to avoid rear end collisions ...
Definition: MSLane.cpp:2241
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1389
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:2099
double getDepartPosLat(const MSVehicle &veh)
Definition: MSLane.cpp:509
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1206
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane, including their minGaps)
Definition: MSLane.h:1366
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, bool ignoreMinorLinks=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition: MSLane.cpp:3059
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:652
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1386
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition: MSLane.cpp:1807
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:458
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1336
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2681
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
Definition: MSLane.cpp:3420
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
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...
Definition: MSLane.cpp:3451
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:519
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2696
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition: MSLane.h:1403
const double myWidth
Lane width [m].
Definition: MSLane.h:1325
edge_finder(MSEdge *e)
Definition: MSLane.h:1543
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:1058
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:488
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: MSLane.cpp:330
virtual bool appropriate(const MSVehicle *veh)
Definition: MSLane.cpp:1911
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
Definition: MSLane.cpp:1162
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1439
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1462
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:474