SUMO - Simulation of Urban MObility
MSLane.h
Go to the documentation of this file.
1 /****************************************************************************/
13 // Representation of a lane in the micro simulation
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 #ifndef MSLane_h
27 #define MSLane_h
28 
29 
30 // ===========================================================================
31 // included modules
32 // ===========================================================================
33 #ifdef _MSC_VER
34 #include <windows_config.h>
35 #else
36 #include <config.h>
37 #endif
38 
39 #include <vector>
40 #include <deque>
41 #include <cassert>
42 #include <utils/common/Named.h>
48 #include "MSLinkCont.h"
49 #include "MSLeaderInfo.h"
50 #include "MSMoveReminder.h"
51 #ifndef NO_TRACI
53 #endif
54 
55 
56 // ===========================================================================
57 // class declarations
58 // ===========================================================================
59 class MSEdge;
60 class MSVehicle;
61 class MSLaneChanger;
62 class MSLink;
63 class MSVehicleTransfer;
64 class MSVehicleControl;
65 class OutputDevice;
66 class MSLeaderInfo;
67 
68 
69 // ===========================================================================
70 // class definitions
71 // ===========================================================================
79 class MSLane : public Named, public Parameterised {
80 public:
82  friend class MSLaneChanger;
83  friend class MSLaneChangerSublane;
84 
85  friend class MSXMLRawOut;
86 
87  friend class MSQueueExport;
88  friend class AnyVehicleIterator;
89 
91  typedef std::vector<MSVehicle*> VehCont;
92 
95  struct VehPosition : public std::binary_function < const MSVehicle*, double, bool > {
97  bool operator()(const MSVehicle* cmp, double pos) const;
98  };
99 
101  public:
103  const MSLane* lane,
104  int i1,
105  int i2,
106  const int i1End,
107  const int i2End,
108  bool downstream = true) :
109  myLane(lane),
110  myI1(i1),
111  myI2(i2),
112  myI1End(i1End),
113  myI2End(i2End),
114  myDownstream(downstream),
115  myDirection(downstream ? 1 : -1) {
116  }
117 
118  bool operator== (AnyVehicleIterator const& other) const {
119  return (myI1 == other.myI1
120  && myI2 == other.myI2
121  && myI1End == other.myI1End
122  && myI2End == other.myI2End);
123  }
124 
125  bool operator!= (AnyVehicleIterator const& other) const {
126  return !(*this == other);
127  }
128 
130  return **this;
131  }
132 
133  const MSVehicle* operator*();
134 
135  AnyVehicleIterator& operator++();
136 
137  private:
138  bool nextIsMyVehicles() const;
139 
141  const MSLane* myLane;
143  int myI1;
145  int myI2;
147  int myI1End;
149  int myI2End;
154 
155  };
156 
157 
158 public:
167  };
168 
183  MSLane(const std::string& id, double maxSpeed, double length, MSEdge* const edge,
184  int numericalID, const PositionVector& shape, double width,
185  SVCPermissions permissions, int index, bool isRampAccel);
186 
187 
189  virtual ~MSLane();
190 
191 
192 
195 
203  void addLink(MSLink* link);
204 
209  void addNeigh(const std::string& id);
211 
212 
213 
216 
223  virtual void addMoveReminder(MSMoveReminder* rem);
224 
225 
229  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
230  return myMoveReminders;
231  }
233 
234 
235 
238 
254  bool insertVehicle(MSVehicle& v);
255 
256 
275  bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
276  bool recheckNextLanes,
277  MSMoveReminder::Notification notification);
278 
279  // XXX: Documentation?
280  bool checkFailure(MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const;
281 
285  bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
286 
294  bool freeInsertion(MSVehicle& veh, double speed, double posLat,
296 
297 
307  void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
309 
310 
311 
314 
321  virtual double setPartialOccupation(MSVehicle* v);
322 
326  virtual void resetPartialOccupation(MSVehicle* v);
327 
338  const MSLeaderInfo& getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
339 
341  const MSLeaderInfo& getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
342 
344 
347 
352  int getVehicleNumber() const {
353  return (int)myVehicles.size();
354  }
355 
361  return (int)myVehicles.size() + (int)myPartialVehicles.size();
362  }
363 
369  return (int)myPartialVehicles.size();
370  }
371 
372 
379  virtual const VehCont& getVehiclesSecure() const {
380  return myVehicles;
381  }
382 
383 
386  return AnyVehicleIterator(this, 0, 0, (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
387  }
388 
391  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
392  }
393 
396  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, -1, -1, false);
397  }
398 
401  return AnyVehicleIterator(this, -1, -1, -1, -1, false);
402  }
403 
406  virtual void releaseVehicles() const { }
408 
409 
410 
413 
414 
418  inline int getNumericalID() const {
419  return myNumericalID;
420  }
421 
422 
426  inline const PositionVector& getShape() const {
427  return myShape;
428  }
429 
431  inline double getLengthGeometryFactor() const {
432  return myLengthGeometryFactor;
433  }
434 
436  inline bool isAccelLane() const {
437  return myIsRampAccel;
438  }
439 
440  /* @brief fit the given lane position to a visibly suitable geometry position
441  * (lane length might differ from geometry length) */
442  inline double interpolateLanePosToGeometryPos(double lanePos) const {
443  return lanePos * myLengthGeometryFactor;
444  }
445 
446  /* @brief fit the given lane position to a visibly suitable geometry position
447  * and return the coordinates */
448  inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
449  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
450  }
451 
452  /* @brief fit the given geomtry position to a valid lane position
453  * (lane length might differ from geometry length) */
454  inline double interpolateGeometryPosToLanePos(double geometryPos) const {
455  return geometryPos / myLengthGeometryFactor;
456  }
457 
462  inline double getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
463  if (myRestrictions != 0) {
464  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
465  if (r != myRestrictions->end()) {
466  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
467  }
468  }
469  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
470  }
471 
472 
476  inline double getSpeedLimit() const {
477  return myMaxSpeed;
478  }
479 
480 
484  inline double getLength() const {
485  return myLength;
486  }
487 
488 
493  return myPermissions;
494  }
495 
496 
500  double getWidth() const {
501  return myWidth;
502  }
503 
507  int getIndex() const {
508  return myIndex;
509  }
511 
513  int getCrossingIndex() const;
514 
515 
518 
526  virtual void planMovements(const SUMOTime t);
527 
536  virtual bool executeMovements(SUMOTime t, std::vector<MSLane*>& lanesWithVehiclesToIntegrate);
537 
539  virtual bool integrateNewVehicle(SUMOTime t);
541 
542 
543 
545  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
546 
547 
550  virtual bool appropriate(const MSVehicle* veh);
551 
552 
554  const MSLinkCont& getLinkCont() const;
555 
557  MSLink* getLinkTo(const MSLane*) const;
558 
560  MSLink* getEntryLink() const;
561 
562 
564  bool empty() const {
565  assert(myVehBuffer.size() == 0);
566  return myVehicles.empty();
567  }
568 
572  void setMaxSpeed(double val);
573 
577  void setLength(double val);
578 
582  MSEdge& getEdge() const {
583  return *myEdge;
584  }
585 
586 
590  const MSEdge* getNextNormal() const;
591 
592 
598  const MSLane* getFirstInternalInConnection(double& offset) const;
599 
600 
603 
614  static bool dictionary(const std::string& id, MSLane* lane);
615 
616 
623  static MSLane* dictionary(const std::string& id);
624 
625 
627  static void clear();
628 
629 
633  static int dictSize() {
634  return (int)myDict.size();
635  }
636 
637 
641  static void insertIDs(std::vector<std::string>& into);
642 
643 
648  template<class RTREE>
649  static void fill(RTREE& into);
651 
652 
653 
654  // XXX: succLink does not exist... Documentation?
659  static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
660  int nRouteSuccs,
661  const MSLane& succLinkSource,
662  const std::vector<MSLane*>& conts);
663 
664 
667  bool isLinkEnd(MSLinkCont::const_iterator& i) const;
668 
671  bool isLinkEnd(MSLinkCont::iterator& i);
672 
675  bool isEmpty() const;
676 
678  bool isInternal() const;
679 
681  MSVehicle* getLastFullVehicle() const;
682 
685 
687  MSVehicle* getLastAnyVehicle() const;
688 
690  MSVehicle* getFirstAnyVehicle() const;
691 
692  /* @brief remove the vehicle from this lane
693  * @param[notify] whether moveReminders of the vehicle shall be triggered
694  */
695  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
696 
697  void leftByLaneChange(MSVehicle* v);
699 
703  MSLane* getParallelLane(int offset) const;
704 
705 
710  void setPermissions(SVCPermissions permissions, long transientID);
711  void resetPermissions(long transientID);
712 
713 
714  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
715  return (myPermissions & vclass) == vclass;
716  }
717 
718  void addIncomingLane(MSLane* lane, MSLink* viaLink);
719 
720 
723  double length;
725  };
726 
727  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
728  return myIncomingLanes;
729  }
730 
731 
732  void addApproachingLane(MSLane* lane, bool warnMultiCon);
733  bool isApproachedFrom(MSEdge* const edge);
734  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
735 
736 
737 
739  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
740  bool allSublanes, double searchDist = -1, bool ignoreMinorLinks = false) const;
741 
743  double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
744 
757  std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
758 
781  std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
782  double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
783 
785  void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
786  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
787 
805  std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
806 
807  /* @brief return the partial vehicle closest behind ego or 0
808  * if no such vehicle exists */
809  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
810 
813 
818 
821  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
822 
823 
830 
831 
838 
841 
843  std::vector<const MSLane*> getOutgoingLanes() const;
844 
846 
847 
851  double getMeanSpeed() const;
852 
856  double getWaitingSeconds() const;
857 
858 
862  double getBruttoOccupancy() const;
863 
864 
868  double getNettoOccupancy() const;
869 
870 
874  inline double getBruttoVehLenSum() const {
876  }
877 
878 
882  double getCO2Emissions() const;
883 
884 
888  double getCOEmissions() const;
889 
890 
894  double getPMxEmissions() const;
895 
896 
900  double getNOxEmissions() const;
901 
902 
906  double getHCEmissions() const;
907 
908 
912  double getFuelConsumption() const;
913 
914 
918  double getElectricityConsumption() const;
919 
920 
924  double getHarmonoise_NoiseEmissions() const;
926 
927  void setRightSideOnEdge(double value, int rightmostSublane) {
928  myRightSideOnEdge = value;
929  myRightmostSublane = rightmostSublane;
930  }
931 
933  void initRestrictions();
934 
935  double getRightSideOnEdge() const {
936  return myRightSideOnEdge;
937  }
938 
939  int getRightmostSublane() const {
940  return myRightmostSublane;
941  }
942 
943  double getCenterOnEdge() const {
944  return myRightSideOnEdge + 0.5 * myWidth;
945  }
946 
948  void sortPartialVehicles();
949 
951  MSLane* getOpposite() const;
952 
954  double getOppositePos(double pos) const;
955 
956  /* @brief find leader for a vehicle depending the relative driving direction
957  * @param[in] ego The ego vehicle
958  * @param[in] dist The look-ahead distance when looking at consecutive lanes
959  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
960  * @return the leader vehicle and it's gap to ego
961  */
962  std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir) const;
963 
964  /* @brief find follower for a vehicle that is located on the opposite of this lane
965  * @param[in] ego The ego vehicle
966  * @return the follower vehicle and it's gap to ego
967  */
968  std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
969 
970 
978  std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, bool ignoreMinorLinks) const;
979 
980 
982  void addParking(MSVehicle* veh);
983 
985  virtual void removeParking(MSVehicle* veh);
986 
988  const std::set<const MSVehicle*>& getParkingVehicles() const {
989  return myParkingVehicles;
990  }
991 
993  virtual bool isSelected() const {
994  return false;
995  }
996 
999 
1007  void saveState(OutputDevice& out);
1008 
1020  void loadState(std::vector<std::string>& vehIDs, MSVehicleControl& vc);
1022 
1023 
1024 #ifndef NO_TRACI
1025 
1032  void visit(const TraCIServerAPI_Lane::StoringVisitor& cont) const {
1033  cont.add(this);
1034  }
1035 #endif
1036 
1037  static void initCollisionOptions(const OptionsCont& oc);
1038 
1039  static bool teleportOnCollision() {
1041  }
1042 
1044  return myCollisionAction;
1045  }
1046 
1047  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1048  static const long CHANGE_PERMISSIONS_GUI = 1;
1049 
1050 protected:
1052  virtual void swapAfterLaneChange(SUMOTime t);
1053 
1065  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1066  const MSLane::VehCont::iterator& at,
1068 
1070  void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1071  SUMOTime timestep, const std::string& stage);
1072 
1074  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1075  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1076  std::set<const MSVehicle*>& toTeleport) const;
1077 
1079  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1080  double gap, double latGap,
1081  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1082  std::set<const MSVehicle*>& toTeleport) const;
1083 
1085  double getMaximumBrakeDist() const;
1086 
1087  /* @brief determine depart speed and whether it may be patched
1088  * @param[in] veh The departing vehicle
1089  * @param[out] whether the speed may be patched to account for safety
1090  * @return the depart speed
1091  */
1092  double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1093 
1094  /* @brief determine the lateral depart position
1095  * @param[in] veh The departing vehicle
1096  * @return the lateral depart position
1097  */
1098  double getDepartPosLat(const MSVehicle& veh);
1099 
1102  double safeInsertionSpeed(const MSVehicle* veh, const MSLeaderInfo& leaders, double speed);
1103 
1105  double basePos(const MSVehicle& veh) const;
1106 
1109 
1112 
1114  int myIndex;
1115 
1127  VehCont myVehicles;
1128 
1140 
1143  VehCont myTmpVehicles;
1144 
1147  VehCont myVehBuffer;
1148 
1149 
1150  /* @brief list of vehicles that are parking near this lane
1151  * (not necessarily on the road but having reached their stop on this lane)
1152  * */
1153  std::set<const MSVehicle*> myParkingVehicles;
1154 
1156  double myLength;
1157 
1159  const double myWidth;
1160 
1162  MSEdge* const myEdge;
1163 
1165  double myMaxSpeed;
1166 
1169 
1172 
1174  const std::map<SUMOVehicleClass, double>* myRestrictions;
1175 
1177  std::vector<IncomingLaneInfo> myIncomingLanes;
1178 
1181 
1184 
1187 
1190 
1193 
1197 
1199  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1200 
1205 
1207 
1212 
1215 
1217  const bool myIsRampAccel;
1218 
1223 
1224  // @brief the ids of neighboring lanes
1225  std::vector<std::string> myNeighs;
1226 
1227  // @brief transient changes in permissions
1228  std::map<long, SVCPermissions> myPermissionChanges;
1229 
1231  typedef std::map< std::string, MSLane* > DictType;
1232 
1234  static DictType myDict;
1235 
1236 private:
1238  std::vector< MSMoveReminder* > myMoveReminders;
1239 
1244 
1250  public:
1252  explicit vehicle_position_sorter(const MSLane* lane) :
1253  myLane(lane) {
1254  }
1255 
1256 
1262  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1263 
1264  const MSLane* myLane;
1265 
1266  };
1267 
1273  public:
1275  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1276  myLane(lane) {
1277  }
1278 
1279 
1285  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1286 
1287  const MSLane* myLane;
1288 
1289  };
1290 
1296  public:
1298  explicit by_connections_to_sorter(const MSEdge* const e);
1299 
1301  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1302 
1303  private:
1304  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1305  private:
1306  const MSEdge* const myEdge;
1307  double myLaneDir;
1308  };
1309 
1310 
1311 
1317  public:
1319  explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1320 
1322  int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1323 
1324  private:
1325  incoming_lane_priority_sorter& operator=(const incoming_lane_priority_sorter&); // just to avoid a compiler warning
1326  private:
1327  const MSLane* const myLane;
1328  double myLaneDir;
1329  };
1330 
1331 
1337  public:
1339  explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1340 
1342  int operator()(const MSLink* link1, const MSLink* link2) const;
1343 
1344  private:
1345  outgoing_lane_priority_sorter& operator=(const outgoing_lane_priority_sorter&); // just to avoid a compiler warning
1346  private:
1347  const MSLane* const myLane;
1348  double myLaneDir;
1349  };
1350 
1354  class edge_finder {
1355  public:
1356  edge_finder(MSEdge* e) : myEdge(e) {}
1357  bool operator()(const IncomingLaneInfo& ili) const {
1358  return &(ili.lane->getEdge()) == myEdge;
1359  }
1360  private:
1361  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1362  private:
1363  const MSEdge* const myEdge;
1364  };
1365 
1366 private:
1368  MSLane(const MSLane&);
1369 
1371  MSLane& operator=(const MSLane&);
1372 
1373 
1374 };
1375 
1376 
1377 #endif
1378 
1379 /****************************************************************************/
1380 
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:1247
int getRightmostSublane() const
Definition: MSLane.h:939
int getNumericalID() const
Returns this lane&#39;s numerical id.
Definition: MSLane.h:418
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:2650
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1168
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1127
double getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:476
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:136
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:582
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
Definition: MSLane.h:368
virtual double getChosenSpeedFactor() const =0
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2431
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:2012
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:500
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1663
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1702
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:1730
void resetPermissions(long transientID)
Definition: MSLane.cpp:3035
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:352
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)
Constructor.
Definition: MSLane.cpp:165
double getCenterOnEdge() const
Definition: MSLane.h:943
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1585
const MSEdge * getNextNormal() const
Returns the lane&#39;s follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1525
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:1947
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn&#39;t apply, wrt. the angle differenc...
Definition: MSLane.h:1316
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:2634
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1716
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:406
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
Definition: MSLane.cpp:1786
static bool teleportOnCollision()
Definition: MSLane.h:1039
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1048
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int myI2
index for myPartialVehicles
Definition: MSLane.h:145
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
Definition: MSLane.cpp:2957
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2288
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2359
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:2789
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:553
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:939
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:2917
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1593
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:1824
virtual double getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2371
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2303
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1177
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:149
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:205
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1183
int myIndex
The lane index.
Definition: MSLane.h:1114
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1629
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1209
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1693
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1243
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1849
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:442
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:436
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1189
const MSEdge *const myEdge
Definition: MSLane.h:1306
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:2098
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1873
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:2938
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:484
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:3004
Realises dumping the complete network state.
Definition: MSXMLRawOut.h:62
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:218
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2263
std::map< long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1228
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:211
bool isInternal() const
Definition: MSLane.cpp:1679
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1357
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:228
VehCont myPartialVehicles
The lane&#39;s partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1139
static bool myCheckJunctionCollisions
Definition: MSLane.h:1242
int myI1End
end index for myVehicles
Definition: MSLane.h:147
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2383
int myDirection
index delta
Definition: MSLane.h:153
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1111
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1153
const std::set< const MSVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition: MSLane.h:988
bool myDownstream
iteration direction
Definition: MSLane.h:151
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:379
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
Definition: MSLane.h:1225
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:2926
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1241
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1231
static CollisionAction getCollisionAction()
Definition: MSLane.h:1043
double basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Definition: MSLane.cpp:530
MSLinkCont myLinks
Definition: MSLane.h:1196
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1086
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1234
Sorts lanes (their origin link) by the priority of their noninternal target edges or...
Definition: MSLane.h:1336
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1883
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:81
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:455
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:874
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:2220
double myLength
Lane length [m].
Definition: MSLane.h:1156
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2407
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2161
#define max(a, b)
Definition: polyfonts.c:65
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1143
Allows to store the object; used as context while traveling the rtree in TraCI.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:714
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
Definition: MSLane.cpp:1807
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:633
Export the queueing length in front of a junction (very experimental!)
Definition: MSQueueExport.h:57
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:241
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:2241
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1217
const MSEdge *const myEdge
Definition: MSLane.h:1363
Representation of a vehicle.
Definition: SUMOVehicle.h:67
void add(const MSLane *const l) const
Adds the given object to the container.
friend class AnyVehicleIterator
Definition: MSLane.h:88
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:1831
Sorts vehicles by their position (descending)
Definition: MSLane.h:1249
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1220
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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:281
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1171
A list of positions.
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2270
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2419
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:992
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition: MSLane.cpp:1867
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:1535
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:2664
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1174
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Sorts edges by their angle relative to the given edge (straight comes first)
Definition: MSLane.h:1295
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:911
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:360
T MIN2(T a, T b)
Definition: StdDefs.h:68
CollisionAction
Definition: MSLane.h:162
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1222
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1180
Something on a lane to be noticed about vehicle movement.
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:564
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:492
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1838
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:507
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1199
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:91
Base class for objects which have an id.
Definition: Named.h:46
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1108
std::vector< MSMoveReminder * > myMoveReminders
This lane&#39;s move reminder.
Definition: MSLane.h:1238
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1337
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:199
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:2200
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
Definition: MSLane.cpp:2448
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2331
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:1656
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:3023
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:316
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2252
double safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition: MSLane.cpp:920
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1553
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:431
The vehicle has departed (was inserted into the network)
int myI1
index for myVehicles
Definition: MSLane.h:143
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1576
bool isEmpty() const
Definition: MSLane.cpp:1674
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1162
const MSVehicle * operator->()
Definition: MSLane.h:129
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:141
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:2879
bool checkFailure(MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:535
A storage for options typed value containers)
Definition: OptionsCont.h:99
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlaping from consecutve edges
Definition: MSLane.cpp:2902
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:1937
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.cpp:1897
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:2980
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:462
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:390
MSLane & operator=(const MSLane &)
invalidated assignment operator
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:2639
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1202
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
double getRightSideOnEdge() const
Definition: MSLane.h:935
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1032
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1186
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition: MSLane.h:993
long long int SUMOTime
Definition: TraCIDefs.h:52
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1192
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1204
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:191
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2395
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
Definition: MSLane.cpp:2628
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1779
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2347
The class responsible for building and deletion of vehicles.
double getMissingRearGap(const MSVehicle *leader, double backOffset, double leaderSpeed) const
return by how much further the leader must be inserted to avoid rear end collisions ...
Definition: MSLane.cpp:1921
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1214
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:454
MSLeaderInfo myLeaderInfoTmp
Definition: MSLane.h:1206
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1147
double getDepartPosLat(const MSVehicle &veh)
Definition: MSLane.cpp:431
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1047
AnyVehicleIterator(const MSLane *lane, int i1, int i2, const int i1End, const int i2End, bool downstream=true)
Definition: MSLane.h:102
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:727
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1426
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1211
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1684
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane&#39;s move reminders.
Definition: MSLane.h:229
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1165
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:385
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2318
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:400
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
Definition: MSLane.cpp:2277
const double myWidth
Lane width [m].
Definition: MSLane.h:1159
edge_finder(MSEdge *e)
Definition: MSLane.h:1356
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:927
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:261
virtual bool appropriate(const MSVehicle *veh)
Definition: MSLane.cpp:1611
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:1044
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
detect whether there is a collision between the two vehicles
Definition: MSLane.cpp:1280
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1252
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:395
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1275
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:404