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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
25 // Representation of a lane in the micro simulation
26 /****************************************************************************/
27 #pragma once
28 #include <config.h>
29 
30 #include <memory>
31 #include <vector>
32 #include <map>
33 #include <deque>
34 #include <cassert>
35 #include <utils/common/Named.h>
41 #include "MSGlobals.h"
42 #include "MSLeaderInfo.h"
43 #include "MSMoveReminder.h"
44 #include <libsumo/Helper.h>
45 
47 #ifdef HAVE_FOX
49 #endif
50 #include <utils/common/StopWatch.h>
51 
52 
53 // ===========================================================================
54 // class declarations
55 // ===========================================================================
56 class MSEdge;
57 class MSVehicle;
58 class MSLaneChanger;
59 class MSLink;
60 class MSVehicleTransfer;
61 class MSVehicleControl;
62 class OutputDevice;
63 class MSLeaderInfo;
64 
65 
66 // ===========================================================================
67 // type definitions
68 // ===========================================================================
70 typedef std::map<const MSLane*, std::pair<double, double> > LaneCoverageInfo; // also declared in libsumo/Helper.h!
71 
72 // ===========================================================================
73 // class definitions
74 // ===========================================================================
82 class MSLane : public Named, public Parameterised {
83 public:
85  friend class MSLaneChanger;
86  friend class MSLaneChangerSublane;
87 
88  friend class MSQueueExport;
89  friend class AnyVehicleIterator;
90 
92  typedef std::vector<MSVehicle*> VehCont;
93 
94  // TODO: Better documentation
103  public:
105  const MSLane* lane,
106  int i1,
107  int i2,
108  int i3,
109  const int i1End,
110  const int i2End,
111  const int i3End,
112  bool downstream = true) :
113  myLane(lane),
114  myI1(i1),
115  myI2(i2),
116  myI3(i3),
117  myI1End(i1End),
118  myI2End(i2End),
119  myI3End(i3End),
120  myDownstream(downstream),
121  myDirection(downstream ? 1 : -1) {
122  }
123 
124  bool operator== (AnyVehicleIterator const& other) const {
125  return (myI1 == other.myI1
126  && myI2 == other.myI2
127  && myI3 == other.myI3
128  && myI1End == other.myI1End
129  && myI2End == other.myI2End
130  && myI3End == other.myI3End);
131  }
132 
133  bool operator!= (AnyVehicleIterator const& other) const {
134  return !(*this == other);
135  }
136 
138  return **this;
139  }
140 
141  const MSVehicle* operator*();
142 
144 
145  private:
146  bool nextIsMyVehicles() const;
147 
149  const MSLane* myLane;
151  int myI1;
153  int myI2;
155  int myI3;
157  int myI1End;
159  int myI2End;
161  int myI3End;
166 
167  };
168 
169 
170 public:
179  };
180 
195  MSLane(const std::string& id, double maxSpeed, double length, MSEdge* const edge,
196  int numericalID, const PositionVector& shape, double width,
197  SVCPermissions permissions,
198  SVCPermissions changeLeft, SVCPermissions changeRight,
199  int index, bool isRampAccel,
200  const std::string& type);
201 
202 
204  virtual ~MSLane();
205 
207  inline int getThreadIndex() const {
209  }
210 
212  inline int getRNGIndex() const {
213  return myRNGIndex;
214  }
215 
217  SumoRNG* getRNG() const {
218  return &myRNGs[myRNGIndex];
219  }
220 
222  static int getNumRNGs() {
223  return (int)myRNGs.size();
224  }
225 
227  static void saveRNGStates(OutputDevice& out);
228 
230  static void loadRNGState(int index, const std::string& state);
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 != nullptr) {
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 
556  double getWidth() const {
557  return myWidth;
558  }
559 
563  int getIndex() const {
564  return myIndex;
565  }
567 
569  int getCrossingIndex() const;
570 
571 
574 
582  virtual void planMovements(const SUMOTime t);
583 
589  virtual void setJunctionApproaches(const SUMOTime t) const;
590 
599  void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
600 
611  virtual void executeMovements(const SUMOTime t);
612 
614  virtual void integrateNewVehicles();
615 
617  void updateLengthSum();
619 
620 
622  inline bool needsCollisionCheck() const {
623  return myNeedsCollisionCheck;
624  }
625 
627  inline void requireCollisionCheck() {
628  myNeedsCollisionCheck = true;
629  }
630 
632  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
633 
634 
637  virtual bool appropriate(const MSVehicle* veh) const;
638 
639 
641  const std::vector<MSLink*>& getLinkCont() const {
642  return myLinks;
643  }
644 
646  const MSLink* getLinkTo(const MSLane* const) const;
647 
649  const MSLane* getInternalFollowingLane(const MSLane* const) const;
650 
652  const MSLink* getEntryLink() const;
653 
654 
656  bool empty() const {
657  assert(myVehBuffer.size() == 0);
658  return myVehicles.empty();
659  }
660 
664  void setMaxSpeed(double val);
665 
669  void setLength(double val);
670 
674  MSEdge& getEdge() const {
675  return *myEdge;
676  }
677 
678 
682  const MSEdge* getNextNormal() const;
683 
684 
690  const MSLane* getFirstInternalInConnection(double& offset) const;
691 
692 
695 
706  static bool dictionary(const std::string& id, MSLane* lane);
707 
708 
715  static MSLane* dictionary(const std::string& id);
716 
717 
719  static void clear();
720 
721 
725  static int dictSize() {
726  return (int)myDict.size();
727  }
728 
729 
733  static void insertIDs(std::vector<std::string>& into);
734 
735 
740  template<class RTREE>
741  static void fill(RTREE& into);
742 
743 
745  static void initRNGs(const OptionsCont& oc);
747 
748 
749 
750  // XXX: succLink does not exist... Documentation?
755  static std::vector<MSLink*>::const_iterator succLinkSec(const SUMOVehicle& veh,
756  int nRouteSuccs,
757  const MSLane& succLinkSource,
758  const std::vector<MSLane*>& conts);
759 
760 
763  inline bool isLinkEnd(std::vector<MSLink*>::const_iterator& i) const {
764  return i == myLinks.end();
765  }
766 
769  inline bool isLinkEnd(std::vector<MSLink*>::iterator& i) {
770  return i == myLinks.end();
771  }
772 
775  inline bool isEmpty() const {
776  return myVehicles.empty() && myPartialVehicles.empty();
777  }
778 
780  bool isInternal() const;
781 
783  MSVehicle* getLastFullVehicle() const;
784 
786  MSVehicle* getLastAnyVehicle() const;
787 
789  MSVehicle* getFirstAnyVehicle() const;
790 
791  /* @brief remove the vehicle from this lane
792  * @param[notify] whether moveReminders of the vehicle shall be triggered
793  */
794  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
795 
796  void leftByLaneChange(MSVehicle* v);
798 
802  MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
803 
804 
809  void setPermissions(SVCPermissions permissions, long long transientID);
810  void resetPermissions(long long transientID);
811  bool hadPermissionChanges() const;
812 
813 
814  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
815  return (myPermissions & vclass) == vclass;
816  }
817 
819  inline bool allowsChangingLeft(SUMOVehicleClass vclass) const {
820  return (myChangeLeft & vclass) == vclass;
821  }
822 
824  inline bool allowsChangingRight(SUMOVehicleClass vclass) const {
825  return (myChangeRight & vclass) == vclass;
826  }
827 
828  void addIncomingLane(MSLane* lane, MSLink* viaLink);
829 
830 
833  double length;
835  };
836 
837  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
838  return myIncomingLanes;
839  }
840 
841 
842  void addApproachingLane(MSLane* lane, bool warnMultiCon);
843  inline bool isApproachedFrom(MSEdge* const edge) {
844  return myApproachingLanes.find(edge) != myApproachingLanes.end();
845  }
846  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
847 
849  double getVehicleStopOffset(const MSVehicle* veh) const;
850 
852  const StopOffset& getLaneStopOffsets() const;
853 
855  void setLaneStopOffset(const StopOffset& stopOffset);
856 
858  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
859  bool allSublanes, double searchDist = -1, bool ignoreMinorLinks = false) const;
860 
862  double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
863 
876  std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
877 
900  std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
901  double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
902 
904  void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
905  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result, bool oppositeDirection = false) const;
906 
907 
909  void addLeaders(const MSVehicle* vehicle, double vehPos, MSLeaderDistanceInfo& result, bool oppositeDirection = false);
910 
911 
929  std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
930 
931  /* @brief return the partial vehicle closest behind ego or 0
932  * if no such vehicle exists */
933  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
934 
937 
948  std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
949 
952  std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
953 
954 
956  std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
958  std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
959 
964 
968  const MSLane* getNormalPredecessorLane() const;
969 
972  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
973 
974 
981 
982 
989 
992 
994  const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
995 
997  std::vector<const MSLane*> getNormalIncomingLanes() const;
998 
1000 
1001 
1005  double getMeanSpeed() const;
1006 
1008  double getMeanSpeedBike() const;
1009 
1013  double getWaitingSeconds() const;
1014 
1015 
1019  double getBruttoOccupancy() const;
1020 
1021 
1025  double getNettoOccupancy() const;
1026 
1027 
1031  inline double getBruttoVehLenSum() const {
1032  return myBruttoVehicleLengthSum;
1033  }
1034 
1035 
1039  double getCO2Emissions() const;
1040 
1041 
1045  double getCOEmissions() const;
1046 
1047 
1051  double getPMxEmissions() const;
1052 
1053 
1057  double getNOxEmissions() const;
1058 
1059 
1063  double getHCEmissions() const;
1064 
1065 
1069  double getFuelConsumption() const;
1070 
1071 
1075  double getElectricityConsumption() const;
1076 
1077 
1081  double getHarmonoise_NoiseEmissions() const;
1083 
1084  void setRightSideOnEdge(double value, int rightmostSublane) {
1085  myRightSideOnEdge = value;
1086  myRightmostSublane = rightmostSublane;
1087  }
1088 
1090  void initRestrictions();
1091 
1092  void checkBufferType();
1093 
1094  double getRightSideOnEdge() const {
1095  return myRightSideOnEdge;
1096  }
1097 
1098  int getRightmostSublane() const {
1099  return myRightmostSublane;
1100  }
1101 
1102  double getCenterOnEdge() const {
1103  return myRightSideOnEdge + 0.5 * myWidth;
1104  }
1105 
1107  void sortPartialVehicles();
1108 
1110  void sortManeuverReservations();
1111 
1113  MSLane* getOpposite() const;
1114 
1116  MSLane* getParallelOpposite() const;
1117 
1119  double getOppositePos(double pos) const;
1120 
1121  /* @brief find leader for a vehicle depending on the relative driving direction
1122  * @param[in] ego The ego vehicle
1123  * @param[in] dist The look-ahead distance when looking at consecutive lanes
1124  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1125  * @return the leader vehicle and it's gap to ego
1126  */
1127  std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir) const;
1128 
1129  /* @brief find follower for a vehicle that is located on the opposite of this lane
1130  * @param[in] ego The ego vehicle
1131  * @return the follower vehicle and it's gap to ego
1132  */
1133  std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1134 
1135 
1143  std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, bool ignoreMinorLinks) const;
1144 
1145 
1147  void addParking(MSBaseVehicle* veh);
1148 
1150  virtual void removeParking(MSBaseVehicle* veh);
1151 
1153  const std::set<const MSBaseVehicle*>& getParkingVehicles() const {
1154  return myParkingVehicles;
1155  }
1156 
1158  virtual bool isSelected() const {
1159  return false;
1160  }
1161 
1163  MSLane* getBidiLane() const;
1164 
1166  bool mustCheckJunctionCollisions() const;
1167 
1168 #ifdef HAVE_FOX
1169  FXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1170  mySimulationTask.init(&MSLane::planMovements, time);
1171  return &mySimulationTask;
1172  }
1173 
1174  FXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1175  mySimulationTask.init(&MSLane::executeMovements, time);
1176  return &mySimulationTask;
1177  }
1178 
1179  FXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1180  mySimulationTask.init(&MSLane::changeLanes, time);
1181  return &mySimulationTask;
1182  }
1183 #endif
1184 
1185  std::vector<StopWatch<std::chrono::nanoseconds> >& getStopWatch() {
1186  return myStopWatch;
1187  }
1188 
1189  void changeLanes(const SUMOTime time);
1190 
1193 
1201  void saveState(OutputDevice& out);
1202 
1204  void clearState();
1205 
1217  void loadState(const std::vector<std::string>& vehIDs, MSVehicleControl& vc);
1218 
1219 
1220  /* @brief helper function for state saving: checks whether any outgoing
1221  * links are being approached */
1222  bool hasApproaching() const;
1223 
1225 
1226 
1234  void visit(const LaneStoringVisitor& cont) const {
1235  cont.add(this);
1236  }
1237 
1239  bool hasPedestrians() const;
1240 
1242  std::pair<const MSPerson*, double> nextBlocking(double minPos, double minRight, double maxLeft, double stopTime = 0) const;
1243 
1245  double getSpaceTillLastStanding(const MSVehicle* ego, bool& foundStopped) const;
1246 
1248  double getMaximumBrakeDist() const;
1249 
1250  static void initCollisionOptions(const OptionsCont& oc);
1251 
1253  return myCollisionAction;
1254  }
1255 
1256  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1257  static const long CHANGE_PERMISSIONS_GUI = 1;
1258 
1259 protected:
1261  virtual void swapAfterLaneChange(SUMOTime t);
1262 
1274  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1275  const MSLane::VehCont::iterator& at,
1277 
1279  void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1280  SUMOTime timestep, const std::string& stage);
1281 
1283  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1284  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1285  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1286 
1288  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1289  double gap, double latGap,
1290  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1291  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1292 
1293  /* @brief determine depart speed and whether it may be patched
1294  * @param[in] veh The departing vehicle
1295  * @param[out] whether the speed may be patched to account for safety
1296  * @return the depart speed
1297  */
1298  double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1299 
1300  /* @brief determine the lateral depart position
1301  * @param[in] veh The departing vehicle
1302  * @return the lateral depart position
1303  */
1304  double getDepartPosLat(const MSVehicle& veh);
1305 
1308  double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1309 
1311  bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1312 
1314  bool hasApproaching(const std::vector<MSLink*>& links) const;
1315 
1318 
1321 
1323  int myIndex;
1324 
1337 
1349 
1353 
1357 
1365 
1366  /* @brief list of vehicles that are parking near this lane
1367  * (not necessarily on the road but having reached their stop on this lane)
1368  * */
1369  std::set<const MSBaseVehicle*> myParkingVehicles;
1370 
1372  double myLength;
1373 
1375  const double myWidth;
1376 
1381 
1383  MSEdge* const myEdge;
1384 
1386  double myMaxSpeed;
1387 
1390 
1394 
1397 
1399  const std::map<SUMOVehicleClass, double>* myRestrictions;
1400 
1402  std::vector<IncomingLaneInfo> myIncomingLanes;
1403 
1406 
1409 
1412 
1415 
1418 
1421 
1424 
1427  std::vector<MSLink*> myLinks;
1428 
1430  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1431 
1436 
1441 
1444 
1446  const bool myIsRampAccel;
1447 
1449  const std::string myLaneType;
1450 
1455 
1458 
1459  // @brief the ids of neighboring lanes
1460  std::vector<std::string> myNeighs;
1461 
1462  // @brief transient changes in permissions
1463  std::map<long long, SVCPermissions> myPermissionChanges;
1464 
1465  // @brief index of the associated thread-rng
1467 
1469  typedef std::map< std::string, MSLane* > DictType;
1470 
1473 
1474  static std::vector<SumoRNG> myRNGs;
1475 
1476 private:
1478  std::vector< MSMoveReminder* > myMoveReminders;
1479 
1487 
1493  public:
1495  explicit vehicle_position_sorter(const MSLane* lane) :
1496  myLane(lane) {
1497  }
1498 
1499 
1505  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1506 
1507  const MSLane* myLane;
1508 
1509  };
1510 
1516  public:
1518  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1519  myLane(lane) {
1520  }
1521 
1522 
1528  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1529 
1530  const MSLane* myLane;
1531 
1532  };
1533 
1539  public:
1541  explicit by_connections_to_sorter(const MSEdge* const e);
1542 
1544  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1545 
1546  private:
1547  by_connections_to_sorter& operator=(const by_connections_to_sorter&) = delete; // just to avoid a compiler warning
1548  private:
1549  const MSEdge* const myEdge;
1550  double myLaneDir;
1551  };
1552 
1553 
1554 
1560  public:
1562  explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1563 
1565  int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1566 
1567  private:
1568  incoming_lane_priority_sorter& operator=(const incoming_lane_priority_sorter&) = delete; // just to avoid a compiler warning
1569  private:
1570  const MSLane* const myLane;
1571  double myLaneDir;
1572  };
1573 
1574 
1580  public:
1582  explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1583 
1585  int operator()(const MSLink* link1, const MSLink* link2) const;
1586 
1587  private:
1588  outgoing_lane_priority_sorter& operator=(const outgoing_lane_priority_sorter&) = delete; // just to avoid a compiler warning
1589  private:
1590  double myLaneDir;
1591  };
1592 
1596  class edge_finder {
1597  public:
1599  bool operator()(const IncomingLaneInfo& ili) const {
1600  return &(ili.lane->getEdge()) == myEdge;
1601  }
1602  private:
1603  edge_finder& operator=(const edge_finder&) = delete; // just to avoid a compiler warning
1604  private:
1605  const MSEdge* const myEdge;
1606  };
1607 
1608 #ifdef HAVE_FOX
1610  typedef void(MSLane::*Operation)(const SUMOTime);
1611 
1616  class SimulationTask : public FXWorkerThread::Task {
1617  public:
1618  SimulationTask(MSLane& l, const SUMOTime time)
1619  : myLane(l), myTime(time) {}
1620  void init(Operation operation, const SUMOTime time) {
1621  myOperation = operation;
1622  myTime = time;
1623  }
1624  void run(FXWorkerThread* /*context*/) {
1625  try {
1626  (myLane.*(myOperation))(myTime);
1627  } catch (ProcessError& e) {
1628  WRITE_ERROR(e.what());
1629  }
1630  }
1631  private:
1632  Operation myOperation = nullptr;
1633  MSLane& myLane;
1634  SUMOTime myTime;
1635  private:
1637  SimulationTask& operator=(const SimulationTask&) = delete;
1638  };
1639 
1640  SimulationTask mySimulationTask;
1642  mutable FXMutex myLeaderInfoMutex;
1644  mutable FXMutex myFollowerInfoMutex;
1646  mutable FXMutex myPartialOccupatorMutex;
1647 #endif
1648  std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
1649 
1650 private:
1652  MSLane(const MSLane&) = delete;
1653 
1655  MSLane& operator=(const MSLane&) = delete;
1656 
1657 
1658 };
std::map< const MSLane *, std::pair< double, double > > LaneCoverageInfo
Coverage info.
Definition: MSLane.h:63
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
long long int SUMOTime
Definition: SUMOTime.h:32
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
T MIN2(T a, T b)
Definition: StdDefs.h:74
size_t size() const
Definition: FXSynchQue.h:157
Abstract superclass of a task to be run with an index to keep track of pending tasks.
A thread repeatingly calculating incoming tasks.
void add(const MSLane *const l) const
Adds the given object to the container.
Definition: Helper.cpp:66
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
A road/street connecting two junctions.
Definition: MSEdge.h:77
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:133
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
Definition: MSLane.h:102
bool operator!=(AnyVehicleIterator const &other) const
Definition: MSLane.h:133
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:159
int myI2
index for myPartialVehicles
Definition: MSLane.h:153
bool myDownstream
iteration direction
Definition: MSLane.h:163
bool nextIsMyVehicles() const
Definition: MSLane.cpp:146
int myI3
index for myTmpVehicles
Definition: MSLane.h:155
int myDirection
index delta
Definition: MSLane.h:165
AnyVehicleIterator & operator++()
Definition: MSLane.cpp:112
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:149
bool operator==(AnyVehicleIterator const &other) const
Definition: MSLane.h:124
const MSVehicle * operator*()
Definition: MSLane.cpp:129
int myI3End
end index for myTmpVehicles
Definition: MSLane.h:161
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:104
int myI1End
end index for myVehicles
Definition: MSLane.h:157
int myI1
index for myVehicles
Definition: MSLane.h:151
const MSVehicle * operator->()
Definition: MSLane.h:137
Sorts edges by their angle relative to the given edge (straight comes first)
Definition: MSLane.h:1538
by_connections_to_sorter(const MSEdge *const e)
constructor
Definition: MSLane.cpp:2996
const MSEdge *const myEdge
Definition: MSLane.h:1549
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition: MSLane.cpp:3003
by_connections_to_sorter & operator=(const by_connections_to_sorter &)=delete
edge_finder & operator=(const edge_finder &)=delete
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1599
edge_finder(MSEdge *e)
Definition: MSLane.h:1598
const MSEdge *const myEdge
Definition: MSLane.h:1605
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
Definition: MSLane.h:1559
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
Definition: MSLane.cpp:3037
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Definition: MSLane.cpp:3042
incoming_lane_priority_sorter & operator=(const incoming_lane_priority_sorter &)=delete
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
Definition: MSLane.h:1579
outgoing_lane_priority_sorter & operator=(const outgoing_lane_priority_sorter &)=delete
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
Definition: MSLane.cpp:3115
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Definition: MSLane.cpp:3119
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1518
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:2985
Sorts vehicles by their position (descending)
Definition: MSLane.h:1492
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:2973
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1495
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:45
Performs lane changing of vehicles.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:2316
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
detect whether there is a collision between the two vehicles
Definition: MSLane.cpp:1616
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1389
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1405
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition: MSLane.cpp:1293
std::set< const MSBaseVehicle * > myParkingVehicles
Definition: MSLane.h:1369
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2896
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:641
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:3984
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2908
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:2300
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1452
const StopOffset & getLaneStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition: MSLane.cpp:3263
MSLane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: MSLane.cpp:182
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3160
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:222
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:565
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:1198
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:2068
double myLength
Lane length [m].
Definition: MSLane.h:1372
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.h:843
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition: MSLane.cpp:2803
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2282
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
Definition: MSLane.cpp:2777
SumoRNG * getRNG() const
return the associated RNG
Definition: MSLane.h:217
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1320
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1463
int getRNGIndex() const
returns the associated RNG index
Definition: MSLane.h:212
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1399
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:348
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:230
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition: MSLane.h:1478
bool hasApproaching() const
Definition: MSLane.cpp:3165
void addParking(MSBaseVehicle *veh)
add parking vehicle. This should only used during state loading
Definition: MSLane.cpp:3154
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1352
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:492
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1234
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:256
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1435
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:401
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:665
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1484
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1481
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1411
SVCPermissions myChangeLeft
The vClass permissions for changing from this lane.
Definition: MSLane.h:1392
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane * > &bestLaneConts, MSLeaderDistanceInfo &result, bool oppositeDirection=false) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
Definition: MSLane.cpp:3464
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1402
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:440
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:2023
const std::string & getLaneType() const
return the type of this lane
Definition: MSLane.h:493
bool hadPermissionChanges() const
Definition: MSLane.cpp:3965
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:2095
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2151
MSLane(const MSLane &)=delete
invalidated copy constructor
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
Definition: MSLane.cpp:2237
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:409
static bool myCheckJunctionCollisions
Definition: MSLane.h:1482
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:2014
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:1031
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition: MSLane.cpp:330
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1396
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1383
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1417
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:656
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:824
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:2165
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:2341
std::vector< std::string > myNeighs
Definition: MSLane.h:1460
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1386
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
Definition: MSLane.cpp:3978
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:3175
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:428
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2872
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2214
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1454
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1446
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:1253
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition: MSLane.cpp:4032
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1440
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1433
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:694
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1102
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition: MSLane.cpp:3250
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:3916
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1317
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:488
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1336
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:533
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition: MSLane.cpp:3656
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:92
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1472
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:2031
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:1113
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:3822
std::vector< StopWatch< std::chrono::nanoseconds > > & getStopWatch()
Definition: MSLane.h:1185
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:3743
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2306
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1967
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:250
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:3723
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2770
double getDepartPosLat(const MSVehicle &veh)
Definition: MSLane.cpp:541
int getThreadIndex() const
returns the associated thread index
Definition: MSLane.h:207
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:549
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:2728
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition: MSLane.cpp:1947
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1256
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:2683
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3950
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2128
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition: MSLane.cpp:4042
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1449
const std::set< const MSBaseVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition: MSLane.h:1153
int myRNGIndex
Definition: MSLane.h:1466
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
Definition: MSLane.h:1364
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition: MSLane.cpp:3571
bool needsCollisionCheck() const
short-circut collision check if nothing changed since the last check
Definition: MSLane.h:622
static double myCheckJunctionCollisionMinGap
Definition: MSLane.h:1483
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1414
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
Definition: MSLane.cpp:3754
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:1973
static int getNumRNGs()
return the number of RNGs
Definition: MSLane.h:222
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1700
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:2357
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
Definition: MSLane.cpp:2226
bool isLinkEnd(std::vector< MSLink * >::iterator &i)
Definition: MSLane.h:769
static std::vector< SumoRNG > myRNGs
Definition: MSLane.h:1474
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:819
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2268
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:2554
StopOffset myLaneStopOffset
Definition: MSLane.h:1380
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:1142
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition: MSLane.cpp:4019
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the road network starting on the given position...
Definition: MSLane.cpp:3671
void clearState()
Remove all vehicles before quick-loading state.
Definition: MSLane.cpp:3218
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1408
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition: MSLane.h:1457
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition: MSLane.h:763
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:814
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:277
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:519
double getRightSideOnEdge() const
Definition: MSLane.h:1094
void checkBufferType()
Definition: MSLane.cpp:238
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:3873
bool hasPedestrians() const
whether the lane has pedestrians on it
Definition: MSLane.cpp:3971
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2739
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:3633
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:563
void setLaneStopOffset(const StopOffset &stopOffset)
Set vehicle class specific stopOffsets.
Definition: MSLane.cpp:3269
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1420
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2763
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:2707
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition: MSLane.h:627
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:837
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
Definition: MSLane.h:1648
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:3938
const double myWidth
Lane width [m].
Definition: MSLane.h:1375
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:369
void changeLanes(const SUMOTime time)
Definition: MSLane.cpp:1961
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:3817
SVCPermissions myChangeRight
Definition: MSLane.h:1393
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1443
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1831
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2637
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2788
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2932
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:452
int myIndex
The lane index.
Definition: MSLane.h:1323
double getCenterOnEdge() const
Definition: MSLane.h:1102
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
Definition: MSLane.cpp:2847
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:1301
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:1356
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2818
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:2254
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1991
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition: MSLane.h:1158
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:1576
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1353
std::vector< MSLink * > myLinks
Definition: MSLane.h:1427
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:3275
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2137
bool isInternal() const
Definition: MSLane.cpp:2122
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1257
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1348
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2944
void sortManeuverReservations()
sorts myManeuverReservations
Definition: MSLane.cpp:2103
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible)
Definition: MSLane.h:417
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:511
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:446
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition: MSLane.cpp:2749
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:296
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:725
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:434
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2956
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:2368
static bool myExtrapolateSubstepDepart
Definition: MSLane.h:1486
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
Definition: MSLane.cpp:3802
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:2261
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1430
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:458
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition: MSLane.cpp:4064
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:499
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition: MSLane.cpp:319
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:4051
static double myCollisionMinGapFactor
Definition: MSLane.h:1485
MSLane & operator=(const MSLane &)=delete
invalidated assignment operator
bool isEmpty() const
Definition: MSLane.h:775
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:2433
bool hasApproaching(const std::vector< MSLink * > &links) const
check whether any of the outgoing links are being approached
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:483
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2884
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1438
CollisionAction
Definition: MSLane.h:174
@ COLLISION_ACTION_NONE
Definition: MSLane.h:175
@ COLLISION_ACTION_WARN
Definition: MSLane.h:176
@ COLLISION_ACTION_TELEPORT
Definition: MSLane.h:177
@ COLLISION_ACTION_REMOVE
Definition: MSLane.h:178
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
Definition: MSLane.cpp:3811
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1469
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
Definition: MSLane.cpp:3845
double getSpaceTillLastStanding(const MSVehicle *ego, bool &foundStopped) const
return the empty space up to the last standing vehicle or the empty space on the whole lane if no veh...
Definition: MSLane.cpp:4070
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
Definition: MSLane.cpp:2662
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:268
int getNumericalID() const
Returns this lane's numerical id.
Definition: MSLane.h:470
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:1084
virtual bool appropriate(const MSVehicle *veh) const
Definition: MSLane.cpp:2047
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:556
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:404
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:267
int getRightmostSublane() const
Definition: MSLane.h:1098
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2831
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1423
friend class AnyVehicleIterator
Definition: MSLane.h:89
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:3235
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2920
static CollisionAction getCollisionAction()
Definition: MSLane.h:1252
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:133
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Export the queueing length in front of a junction (very experimental!)
Definition: MSQueueExport.h:47
The class responsible for building and deletion of vehicles.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
Base class for objects which have an id.
Definition: Named.h:54
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a vehicle, person, or container.
virtual double getChosenSpeedFactor() const =0
virtual double getMaxSpeed() const =0
Returns the object's maximum speed.
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
stop offset