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-2020 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, int index, bool isRampAccel,
198  const std::string& type);
199 
200 
202  virtual ~MSLane();
203 
205  inline int getThreadIndex() const {
207  }
208 
210  inline int getRNGIndex() const {
211  return myRNGIndex;
212  }
213 
215  std::mt19937* getRNG() const {
216  return &myRNGs[myRNGIndex];
217  }
218 
220  static int getNumRNGs() {
221  return (int)myRNGs.size();
222  }
223 
225  static void saveRNGStates(OutputDevice& out);
226 
228  static void loadRNGState(int index, const std::string& state);
229 
232 
240  void addLink(MSLink* link);
241 
246  void addNeigh(const std::string& id);
248 
249 
250 
253 
260  virtual void addMoveReminder(MSMoveReminder* rem);
261 
262 
266  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
267  return myMoveReminders;
268  }
270 
271 
272 
275 
291  bool insertVehicle(MSVehicle& v);
292 
293 
312  bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
313  bool recheckNextLanes,
314  MSMoveReminder::Notification notification);
315 
316  // XXX: Documentation?
317  bool checkFailure(const MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const;
318 
322  bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
323 
331  bool freeInsertion(MSVehicle& veh, double speed, double posLat,
333 
334 
344  void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
346 
347 
348 
352 
359  virtual double setPartialOccupation(MSVehicle* v);
360 
364  virtual void resetPartialOccupation(MSVehicle* v);
365 
368  virtual void setManeuverReservation(MSVehicle* v);
369 
373  virtual void resetManeuverReservation(MSVehicle* v);
374 
385  const MSLeaderInfo getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
386 
388  const MSLeaderInfo getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
389 
391 
394 
399  int getVehicleNumber() const {
400  return (int)myVehicles.size();
401  }
402 
408  return (int)myVehicles.size() + (int)myPartialVehicles.size();
409  }
410 
416  return (int)myPartialVehicles.size();
417  }
418 
419 
426  virtual const VehCont& getVehiclesSecure() const {
427  return myVehicles;
428  }
429 
430 
433  return AnyVehicleIterator(this, 0, 0, 0,
434  (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
435  }
436 
439  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(),
440  (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
441  }
442 
445  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, (int)myTmpVehicles.size() - 1,
446  -1, -1, -1, false);
447  }
448 
451  return AnyVehicleIterator(this, -1, -1, -1, -1, -1, -1, false);
452  }
453 
456  virtual void releaseVehicles() const { }
458 
459 
460 
463 
464 
468  inline int getNumericalID() const {
469  return myNumericalID;
470  }
471 
472 
476  inline const PositionVector& getShape() const {
477  return myShape;
478  }
479 
481  inline double getLengthGeometryFactor() const {
482  return myLengthGeometryFactor;
483  }
484 
486  inline bool isAccelLane() const {
487  return myIsRampAccel;
488  }
489 
491  const std::string& getLaneType() const {
492  return myLaneType;
493  }
494 
495  /* @brief fit the given lane position to a visibly suitable geometry position
496  * (lane length might differ from geometry length) */
497  inline double interpolateLanePosToGeometryPos(double lanePos) const {
498  return lanePos * myLengthGeometryFactor;
499  }
500 
501  /* @brief fit the given lane position to a visibly suitable geometry position
502  * and return the coordinates */
503  inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
504  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
505  }
506 
507  /* @brief fit the given geometry position to a valid lane position
508  * (lane length might differ from geometry length) */
509  inline double interpolateGeometryPosToLanePos(double geometryPos) const {
510  return geometryPos / myLengthGeometryFactor;
511  }
512 
517  inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh) const {
518  if (myRestrictions != nullptr) {
519  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
520  if (r != myRestrictions->end()) {
521  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
522  }
523  }
524  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
525  }
526 
527 
531  inline double getSpeedLimit() const {
532  return myMaxSpeed;
533  }
534 
535 
539  inline double getLength() const {
540  return myLength;
541  }
542 
543 
548  return myPermissions;
549  }
550 
551 
555  double getWidth() const {
556  return myWidth;
557  }
558 
562  int getIndex() const {
563  return myIndex;
564  }
566 
568  int getCrossingIndex() const;
569 
570 
573 
581  virtual void planMovements(const SUMOTime t);
582 
588  virtual void setJunctionApproaches(const SUMOTime t) const;
589 
598  void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
599 
610  virtual void executeMovements(const SUMOTime t);
611 
613  virtual void integrateNewVehicles();
614 
616  void updateLengthSum();
618 
619 
621  inline bool needsCollisionCheck() const {
622  return myNeedsCollisionCheck;
623  }
624 
626  inline void requireCollisionCheck() {
627  myNeedsCollisionCheck = true;
628  }
629 
631  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
632 
633 
636  virtual bool appropriate(const MSVehicle* veh) const;
637 
638 
640  const std::vector<MSLink*>& getLinkCont() const {
641  return myLinks;
642  }
643 
645  const MSLink* getLinkTo(const MSLane* const) const;
646 
648  const MSLane* getInternalFollowingLane(const MSLane* const) const;
649 
651  const MSLink* getEntryLink() const;
652 
653 
655  bool empty() const {
656  assert(myVehBuffer.size() == 0);
657  return myVehicles.empty();
658  }
659 
663  void setMaxSpeed(double val);
664 
668  void setLength(double val);
669 
673  MSEdge& getEdge() const {
674  return *myEdge;
675  }
676 
677 
681  const MSEdge* getNextNormal() const;
682 
683 
689  const MSLane* getFirstInternalInConnection(double& offset) const;
690 
691 
694 
705  static bool dictionary(const std::string& id, MSLane* lane);
706 
707 
714  static MSLane* dictionary(const std::string& id);
715 
716 
718  static void clear();
719 
720 
724  static int dictSize() {
725  return (int)myDict.size();
726  }
727 
728 
732  static void insertIDs(std::vector<std::string>& into);
733 
734 
739  template<class RTREE>
740  static void fill(RTREE& into);
741 
742 
744  static void initRNGs(const OptionsCont& oc);
746 
747 
748 
749  // XXX: succLink does not exist... Documentation?
754  static std::vector<MSLink*>::const_iterator succLinkSec(const SUMOVehicle& veh,
755  int nRouteSuccs,
756  const MSLane& succLinkSource,
757  const std::vector<MSLane*>& conts);
758 
759 
762  inline bool isLinkEnd(std::vector<MSLink*>::const_iterator& i) const {
763  return i == myLinks.end();
764  }
765 
768  inline bool isLinkEnd(std::vector<MSLink*>::iterator& i) {
769  return i == myLinks.end();
770  }
771 
774  inline bool isEmpty() const {
775  return myVehicles.empty() && myPartialVehicles.empty();
776  }
777 
779  bool isInternal() const;
780 
782  MSVehicle* getLastFullVehicle() const;
783 
785  MSVehicle* getLastAnyVehicle() const;
786 
788  MSVehicle* getFirstAnyVehicle() const;
789 
790  /* @brief remove the vehicle from this lane
791  * @param[notify] whether moveReminders of the vehicle shall be triggered
792  */
793  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
794 
795  void leftByLaneChange(MSVehicle* v);
797 
801  MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
802 
803 
808  void setPermissions(SVCPermissions permissions, long long transientID);
809  void resetPermissions(long long transientID);
810 
811 
812  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
813  return (myPermissions & vclass) == vclass;
814  }
815 
816  void addIncomingLane(MSLane* lane, MSLink* viaLink);
817 
818 
821  double length;
823  };
824 
825  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
826  return myIncomingLanes;
827  }
828 
829 
830  void addApproachingLane(MSLane* lane, bool warnMultiCon);
831  inline bool isApproachedFrom(MSEdge* const edge) {
832  return myApproachingLanes.find(edge) != myApproachingLanes.end();
833  }
834  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
835 
837  double getStopOffset(const MSVehicle* veh) const;
838 
840  const std::map<SVCPermissions, double>& getStopOffsets() const {
841  return myStopOffsets;
842  };
843 
845  void setStopOffsets(std::map<SVCPermissions, double> stopOffsets) {
846  myStopOffsets = stopOffsets;
847  };
848 
850  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
851  bool allSublanes, double searchDist = -1, bool ignoreMinorLinks = false) const;
852 
854  double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
855 
868  std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
869 
892  std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
893  double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
894 
896  void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
897  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
898 
916  std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
917 
918  /* @brief return the partial vehicle closest behind ego or 0
919  * if no such vehicle exists */
920  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
921 
924 
936  std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
937 
940  std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
941 
942 
944  std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
946  std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
947 
952 
956  const MSLane* getNormalPredecessorLane() const;
957 
960  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
961 
962 
969 
970 
977 
980 
982  const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
983 
985  std::vector<const MSLane*> getNormalIncomingLanes() const;
986 
988 
989 
993  double getMeanSpeed() const;
994 
996  double getMeanSpeedBike() const;
997 
1001  double getWaitingSeconds() const;
1002 
1003 
1007  double getBruttoOccupancy() const;
1008 
1009 
1013  double getNettoOccupancy() const;
1014 
1015 
1019  inline double getBruttoVehLenSum() const {
1020  return myBruttoVehicleLengthSum;
1021  }
1022 
1023 
1027  double getCO2Emissions() const;
1028 
1029 
1033  double getCOEmissions() const;
1034 
1035 
1039  double getPMxEmissions() const;
1040 
1041 
1045  double getNOxEmissions() const;
1046 
1047 
1051  double getHCEmissions() const;
1052 
1053 
1057  double getFuelConsumption() const;
1058 
1059 
1063  double getElectricityConsumption() const;
1064 
1065 
1069  double getHarmonoise_NoiseEmissions() const;
1071 
1072  void setRightSideOnEdge(double value, int rightmostSublane) {
1073  myRightSideOnEdge = value;
1074  myRightmostSublane = rightmostSublane;
1075  }
1076 
1078  void initRestrictions();
1079 
1080  void checkBufferType();
1081 
1082  double getRightSideOnEdge() const {
1083  return myRightSideOnEdge;
1084  }
1085 
1086  int getRightmostSublane() const {
1087  return myRightmostSublane;
1088  }
1089 
1090  double getCenterOnEdge() const {
1091  return myRightSideOnEdge + 0.5 * myWidth;
1092  }
1093 
1095  void sortPartialVehicles();
1096 
1098  void sortManeuverReservations();
1099 
1101  MSLane* getOpposite() const;
1102 
1104  double getOppositePos(double pos) const;
1105 
1106  /* @brief find leader for a vehicle depending on the relative driving direction
1107  * @param[in] ego The ego vehicle
1108  * @param[in] dist The look-ahead distance when looking at consecutive lanes
1109  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1110  * @return the leader vehicle and it's gap to ego
1111  */
1112  std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir) const;
1113 
1114  /* @brief find follower for a vehicle that is located on the opposite of this lane
1115  * @param[in] ego The ego vehicle
1116  * @return the follower vehicle and it's gap to ego
1117  */
1118  std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1119 
1120 
1128  std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, bool ignoreMinorLinks) const;
1129 
1130 
1132  void addParking(MSVehicle* veh);
1133 
1135  virtual void removeParking(MSVehicle* veh);
1136 
1138  const std::set<const MSVehicle*>& getParkingVehicles() const {
1139  return myParkingVehicles;
1140  }
1141 
1143  virtual bool isSelected() const {
1144  return false;
1145  }
1146 
1148  MSLane* getBidiLane() const;
1149 
1151  bool mustCheckJunctionCollisions() const;
1152 
1153 #ifdef HAVE_FOX
1154  FXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1155  mySimulationTask.init(&MSLane::planMovements, time);
1156  return &mySimulationTask;
1157  }
1158 
1159  FXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1160  mySimulationTask.init(&MSLane::executeMovements, time);
1161  return &mySimulationTask;
1162  }
1163 
1164  FXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1165  mySimulationTask.init(&MSLane::changeLanes, time);
1166  return &mySimulationTask;
1167  }
1168 #endif
1169 
1170  std::vector<StopWatch<std::chrono::nanoseconds> >& getStopWatch() {
1171  return myStopWatch;
1172  }
1173 
1174  void changeLanes(const SUMOTime time);
1175 
1178 
1186  void saveState(OutputDevice& out);
1187 
1189  void clearState();
1190 
1202  void loadState(const std::vector<std::string>& vehIDs, MSVehicleControl& vc);
1203 
1204 
1205  /* @brief helper function for state saving: checks whether any outgoing
1206  * links are being approached */
1207  bool hasApproaching() const;
1208 
1210 
1211 
1219  void visit(const LaneStoringVisitor& cont) const {
1220  cont.add(this);
1221  }
1222 
1224  bool hasPedestrians() const;
1225 
1227  std::pair<const MSPerson*, double> nextBlocking(double minPos, double minRight, double maxLeft, double stopTime = 0) const;
1228 
1229  static void initCollisionOptions(const OptionsCont& oc);
1230 
1231  static bool teleportOnCollision() {
1233  }
1234 
1236  return myCollisionAction;
1237  }
1238 
1239  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1240  static const long CHANGE_PERMISSIONS_GUI = 1;
1241 
1242 protected:
1244  virtual void swapAfterLaneChange(SUMOTime t);
1245 
1257  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1258  const MSLane::VehCont::iterator& at,
1260 
1262  void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1263  SUMOTime timestep, const std::string& stage);
1264 
1266  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1267  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1268  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1269 
1271  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1272  double gap, double latGap,
1273  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1274  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1275 
1277  double getMaximumBrakeDist() const;
1278 
1279  /* @brief determine depart speed and whether it may be patched
1280  * @param[in] veh The departing vehicle
1281  * @param[out] whether the speed may be patched to account for safety
1282  * @return the depart speed
1283  */
1284  double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1285 
1286  /* @brief determine the lateral depart position
1287  * @param[in] veh The departing vehicle
1288  * @return the lateral depart position
1289  */
1290  double getDepartPosLat(const MSVehicle& veh);
1291 
1294  double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1295 
1297  bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1298 
1300  bool hasApproaching(const std::vector<MSLink*>& links) const;
1301 
1304 
1307 
1309  int myIndex;
1310 
1323 
1335 
1339 
1343 
1351 
1352  /* @brief list of vehicles that are parking near this lane
1353  * (not necessarily on the road but having reached their stop on this lane)
1354  * */
1355  std::set<const MSVehicle*> myParkingVehicles;
1356 
1358  double myLength;
1359 
1361  const double myWidth;
1362 
1366  std::map<SVCPermissions, double> myStopOffsets;
1367 
1369  MSEdge* const myEdge;
1370 
1372  double myMaxSpeed;
1373 
1376 
1379 
1381  const std::map<SUMOVehicleClass, double>* myRestrictions;
1382 
1384  std::vector<IncomingLaneInfo> myIncomingLanes;
1385 
1388 
1391 
1394 
1397 
1400 
1403 
1406 
1409  std::vector<MSLink*> myLinks;
1410 
1412  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1413 
1418 
1423 
1426 
1428  const bool myIsRampAccel;
1429 
1431  const std::string myLaneType;
1432 
1437 
1440 
1441  // @brief the ids of neighboring lanes
1442  std::vector<std::string> myNeighs;
1443 
1444  // @brief transient changes in permissions
1445  std::map<long long, SVCPermissions> myPermissionChanges;
1446 
1447  // @brief index of the associated thread-rng
1449 
1451  typedef std::map< std::string, MSLane* > DictType;
1452 
1455 
1456  static std::vector<std::mt19937> myRNGs;
1457 
1458 private:
1460  std::vector< MSMoveReminder* > myMoveReminders;
1461 
1468 
1474  public:
1476  explicit vehicle_position_sorter(const MSLane* lane) :
1477  myLane(lane) {
1478  }
1479 
1480 
1486  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1487 
1488  const MSLane* myLane;
1489 
1490  };
1491 
1497  public:
1499  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1500  myLane(lane) {
1501  }
1502 
1503 
1509  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1510 
1511  const MSLane* myLane;
1512 
1513  };
1514 
1520  public:
1522  explicit by_connections_to_sorter(const MSEdge* const e);
1523 
1525  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1526 
1527  private:
1528  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1529  private:
1530  const MSEdge* const myEdge;
1531  double myLaneDir;
1532  };
1533 
1534 
1535 
1541  public:
1543  explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1544 
1546  int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1547 
1548  private:
1549  incoming_lane_priority_sorter& operator=(const incoming_lane_priority_sorter&); // just to avoid a compiler warning
1550  private:
1551  const MSLane* const myLane;
1552  double myLaneDir;
1553  };
1554 
1555 
1561  public:
1563  explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1564 
1566  int operator()(const MSLink* link1, const MSLink* link2) const;
1567 
1568  private:
1569  outgoing_lane_priority_sorter& operator=(const outgoing_lane_priority_sorter&); // just to avoid a compiler warning
1570  private:
1571  const MSLane* const myLane;
1572  double myLaneDir;
1573  };
1574 
1578  class edge_finder {
1579  public:
1581  bool operator()(const IncomingLaneInfo& ili) const {
1582  return &(ili.lane->getEdge()) == myEdge;
1583  }
1584  private:
1585  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1586  private:
1587  const MSEdge* const myEdge;
1588  };
1589 
1590 #ifdef HAVE_FOX
1592  typedef void(MSLane::*Operation)(const SUMOTime);
1593 
1598  class SimulationTask : public FXWorkerThread::Task {
1599  public:
1600  SimulationTask(MSLane& l, const SUMOTime time)
1601  : myLane(l), myTime(time) {}
1602  void init(Operation operation, const SUMOTime time) {
1603  myOperation = operation;
1604  myTime = time;
1605  }
1606  void run(FXWorkerThread* /*context*/) {
1607  try {
1608  (myLane.*(myOperation))(myTime);
1609  } catch (ProcessError& e) {
1610  WRITE_ERROR(e.what());
1611  }
1612  }
1613  private:
1614  Operation myOperation = nullptr;
1615  MSLane& myLane;
1616  SUMOTime myTime;
1617  private:
1619  SimulationTask& operator=(const SimulationTask&) = delete;
1620  };
1621 
1622  SimulationTask mySimulationTask;
1624  mutable FXMutex myLeaderInfoMutex;
1626  mutable FXMutex myFollowerInfoMutex;
1628  mutable FXMutex myPartialOccupatorMutex;
1629 #endif
1630  std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
1631 
1632 private:
1634  MSLane(const MSLane&);
1635 
1638 
1639 
1640 };
std::map< const MSLane *, std::pair< double, double > > LaneCoverageInfo
Coverage info.
Definition: MSLane.h:63
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
long long int SUMOTime
Definition: SUMOTime.h:31
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:73
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:62
A road/street connecting two junctions.
Definition: MSEdge.h:77
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:115
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:144
int myI3
index for myTmpVehicles
Definition: MSLane.h:155
int myDirection
index delta
Definition: MSLane.h:165
AnyVehicleIterator & operator++()
Definition: MSLane.cpp:111
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:128
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:1519
by_connections_to_sorter & operator=(const by_connections_to_sorter &)
by_connections_to_sorter(const MSEdge *const e)
constructor
Definition: MSLane.cpp:2901
const MSEdge *const myEdge
Definition: MSLane.h:1530
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition: MSLane.cpp:2908
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1581
edge_finder & operator=(const edge_finder &)
edge_finder(MSEdge *e)
Definition: MSLane.h:1580
const MSEdge *const myEdge
Definition: MSLane.h:1587
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
Definition: MSLane.h:1540
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
Definition: MSLane.cpp:2942
incoming_lane_priority_sorter & operator=(const incoming_lane_priority_sorter &)
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Definition: MSLane.cpp:2947
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
Definition: MSLane.h:1560
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
Definition: MSLane.cpp:3019
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Definition: MSLane.cpp:3024
outgoing_lane_priority_sorter & operator=(const outgoing_lane_priority_sorter &)
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1499
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:2890
Sorts vehicles by their position (descending)
Definition: MSLane.h:1473
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:2878
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1476
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:2227
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:1570
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1375
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1387
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition: MSLane.cpp:1258
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2801
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:640
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:3768
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2813
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:2211
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1434
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:216
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:544
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:1163
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1982
double myLength
Lane length [m].
Definition: MSLane.h:1358
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.h:831
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition: MSLane.cpp:2708
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2193
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
Definition: MSLane.cpp:2682
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1306
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1445
int getRNGIndex() const
returns the associated RNG index
Definition: MSLane.h:210
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1381
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:341
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:224
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition: MSLane.h:1460
bool hasApproaching() const
Definition: MSLane.cpp:3070
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1338
MSLane & operator=(const MSLane &)
invalidated assignment operator
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:485
void visit(const LaneStoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1219
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:250
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1417
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:399
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:642
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1465
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1463
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1393
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1384
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:438
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1940
const std::string & getLaneType() const
return the type of this lane
Definition: MSLane.h:491
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:2009
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2065
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 *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1641
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
Definition: MSLane.cpp:2151
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3065
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:407
static bool myCheckJunctionCollisions
Definition: MSLane.h:1464
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1931
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:1019
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition: MSLane.cpp:323
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1378
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1369
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1399
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:655
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:2079
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:2251
std::vector< std::string > myNeighs
Definition: MSLane.h:1442
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1372
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:3762
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:3080
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:426
MSLane(const MSLane &)
invalidated copy constructor
static std::vector< std::mt19937 > myRNGs
Definition: MSLane.h:1456
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2777
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2128
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1436
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1428
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:1218
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition: MSLane.cpp:3816
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1422
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1415
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:671
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1067
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:3707
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1303
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:486
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1322
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:531
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition: MSLane.cpp:3466
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:1454
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1948
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:1078
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:3633
std::vector< StopWatch< std::chrono::nanoseconds > > & getStopWatch()
Definition: MSLane.h:1170
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:3553
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2217
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1884
const std::set< const MSVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition: MSLane.h:1138
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:244
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:3533
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2675
double getDepartPosLat(const MSVehicle &veh)
Definition: MSLane.cpp:520
int getThreadIndex() const
returns the associated thread index
Definition: MSLane.h:205
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:547
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:2633
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition: MSLane.cpp:1864
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:180
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1239
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:2588
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1355
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3740
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2042
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition: MSLane.cpp:3826
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1431
int myRNGIndex
Definition: MSLane.h:1448
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
Definition: MSLane.h:1350
bool needsCollisionCheck() const
short-circut collision check if nothing changed since the last check
Definition: MSLane.h:621
double getLength() const
Returns the lane's length.
Definition: MSLane.h:539
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1396
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:3564
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:1890
static int getNumRNGs()
return the number of RNGs
Definition: MSLane.h:220
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:2267
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:2140
bool isLinkEnd(std::vector< MSLink * >::iterator &i)
Definition: MSLane.h:768
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2182
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:2469
static bool teleportOnCollision()
Definition: MSLane.h:1231
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:1107
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition: MSLane.cpp:3803
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:3481
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition: MSLane.cpp:3152
void clearState()
Remove all vehicles before quick-loading state.
Definition: MSLane.cpp:3120
void setStopOffsets(std::map< SVCPermissions, double > stopOffsets)
Set vehicle class specific stopOffsets.
Definition: MSLane.h:845
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1390
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition: MSLane.h:1439
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition: MSLane.h:762
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:812
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:272
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:517
double getRightSideOnEdge() const
Definition: MSLane.h:1082
void checkBufferType()
Definition: MSLane.cpp:232
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:3678
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:3353
bool hasPedestrians() const
whether the lane has pedestrians on it
Definition: MSLane.cpp:3755
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2644
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:3443
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:562
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1402
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2668
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:2612
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition: MSLane.h:626
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:825
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
Definition: MSLane.h:1630
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:3728
const double myWidth
Lane width [m].
Definition: MSLane.h:1361
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:362
void changeLanes(const SUMOTime time)
Definition: MSLane.cpp:1878
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:3621
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1425
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1760
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2542
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2693
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2837
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:450
const std::map< SVCPermissions, double > & getStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition: MSLane.h:840
int myIndex
The lane index.
Definition: MSLane.h:1309
double getCenterOnEdge() const
Definition: MSLane.h:1090
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
Definition: MSLane.cpp:2752
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:1266
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:1342
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2723
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:2168
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1908
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition: MSLane.h:1143
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:1536
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1316
std::vector< MSLink * > myLinks
Definition: MSLane.h:1409
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:3166
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2051
bool isInternal() const
Definition: MSLane.cpp:2036
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1240
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1334
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2849
void sortManeuverReservations()
sorts myManeuverReservations
Definition: MSLane.cpp:2017
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
std::map< SVCPermissions, double > myStopOffsets
Definition: MSLane.h:1366
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:476
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible)
Definition: MSLane.h:415
std::mt19937 * getRNG() const
return the associated RNG
Definition: MSLane.h:215
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:509
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:444
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition: MSLane.cpp:2654
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:290
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:724
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:432
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2861
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:2278
static bool myExtrapolateSubstepDepart
Definition: MSLane.h:1467
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:3612
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:2175
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1412
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:456
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition: MSLane.cpp:3848
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:497
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
Definition: MSLane.cpp:3059
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition: MSLane.cpp:312
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:3835
static double myCollisionMinGapFactor
Definition: MSLane.h:1466
bool isEmpty() const
Definition: MSLane.h:774
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:2343
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:481
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2789
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1420
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
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1451
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
Definition: MSLane.cpp:3655
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
Definition: MSLane.cpp:2567
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:266
int getNumericalID() const
Returns this lane's numerical id.
Definition: MSLane.h:468
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:1072
virtual bool appropriate(const MSVehicle *veh) const
Definition: MSLane.cpp:1964
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:555
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:397
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:262
int getRightmostSublane() const
Definition: MSLane.h:1086
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2736
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1405
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:3137
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:503
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2825
static CollisionAction getCollisionAction()
Definition: MSLane.h:1235
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:130
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:77
Base class for objects which have an id.
Definition: Named.h:53
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:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
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:58