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*, SUMOReal, bool > {
97  bool operator()(const MSVehicle* cmp, SUMOReal 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 
182  MSLane(const std::string& id, SUMOReal maxSpeed, SUMOReal length, MSEdge* const edge,
183  int numericalID, const PositionVector& shape, SUMOReal width,
184  SVCPermissions permissions, int index);
185 
186 
188  virtual ~MSLane();
189 
190 
191 
194 
202  void addLink(MSLink* link);
203 
208  void addNeigh(const std::string& id);
210 
211 
212 
215 
222  virtual void addMoveReminder(MSMoveReminder* rem);
223 
224 
228  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
229  return myMoveReminders;
230  }
232 
233 
234 
237 
253  bool insertVehicle(MSVehicle& v);
254 
255 
274  bool isInsertionSuccess(MSVehicle* vehicle, SUMOReal speed, SUMOReal pos, SUMOReal posLat,
275  bool recheckNextLanes,
276  MSMoveReminder::Notification notification);
277 
278  // XXX: Documentation?
279  bool checkFailure(MSVehicle* aVehicle, SUMOReal& speed, SUMOReal& dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const;
280 
284  bool lastInsertion(MSVehicle& veh, SUMOReal mspeed, bool patchSpeed);
285 
293  bool freeInsertion(MSVehicle& veh, SUMOReal speed,
295 
296 
306  void forceVehicleInsertion(MSVehicle* veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat = 0);
308 
309 
310 
313 
321 
325  virtual void resetPartialOccupation(MSVehicle* v);
326 
337  const MSLeaderInfo& getLastVehicleInformation(const MSVehicle* ego, SUMOReal latOffset, SUMOReal minPos = 0, bool allowCached = true) const;
338 
340  const MSLeaderInfo& getFirstVehicleInformation(const MSVehicle* ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos = std::numeric_limits<SUMOReal>::max(), bool allowCached = true) const;
341 
343 
344 
345 
348 
353  int getVehicleNumber() const {
354  return (int)myVehicles.size();
355  }
356 
362  return (int)myVehicles.size() + (int)myPartialVehicles.size();
363  }
364 
370  return (int)myPartialVehicles.size();
371  }
372 
373 
380  virtual const VehCont& getVehiclesSecure() const {
381  return myVehicles;
382  }
383 
384 
387  return AnyVehicleIterator(this, 0, 0, (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
388  }
389 
392  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
393  }
394 
397  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, -1, -1, false);
398  }
399 
402  return AnyVehicleIterator(this, -1, -1, -1, -1, false);
403  }
404 
407  virtual void releaseVehicles() const { }
409 
410 
411 
414 
415 
419  inline int getNumericalID() const {
420  return myNumericalID;
421  }
422 
423 
427  inline const PositionVector& getShape() const {
428  return myShape;
429  }
430 
433  return myLengthGeometryFactor;
434  }
435 
436  /* @brief fit the given lane position to a visibly suitable geometry position
437  * (lane length might differ from geometry length) */
439  return lanePos * myLengthGeometryFactor;
440  }
441 
442  /* @brief fit the given lane position to a visibly suitable geometry position
443  * and return the coordinates */
444  inline const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset = 0) const {
445  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
446  }
447 
448  /* @brief fit the given geomtry position to a valid lane position
449  * (lane length might differ from geometry length) */
451  return geometryPos / myLengthGeometryFactor;
452  }
453 
458  inline SUMOReal getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
459  if (myRestrictions != 0) {
460  std::map<SUMOVehicleClass, SUMOReal>::const_iterator r = myRestrictions->find(veh->getVClass());
461  if (r != myRestrictions->end()) {
462  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
463  }
464  }
465  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
466  }
467 
468 
472  inline SUMOReal getSpeedLimit() const {
473  return myMaxSpeed;
474  }
475 
476 
480  inline SUMOReal getLength() const {
481  return myLength;
482  }
483 
484 
489  return myPermissions;
490  }
491 
492 
496  SUMOReal getWidth() const {
497  return myWidth;
498  }
499 
503  int getIndex() const {
504  return myIndex;
505  }
507 
509  int getCrossingIndex() const;
510 
511 
514 
522  virtual void planMovements(const SUMOTime t);
523 
532  virtual bool executeMovements(SUMOTime t, std::vector<MSLane*>& lanesWithVehiclesToIntegrate);
533 
535  virtual bool integrateNewVehicle(SUMOTime t);
537 
538 
539 
541  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
542 
543 
546  virtual bool appropriate(const MSVehicle* veh);
547 
548 
550  const MSLinkCont& getLinkCont() const;
551 
553  bool empty() const {
554  assert(myVehBuffer.size() == 0);
555  return myVehicles.empty();
556  }
557 
561  void setMaxSpeed(SUMOReal val);
562 
566  void setLength(SUMOReal val);
567 
571  MSEdge& getEdge() const {
572  return *myEdge;
573  }
574 
575 
579  const MSEdge* getNextNormal() const;
580 
581 
584 
595  static bool dictionary(const std::string& id, MSLane* lane);
596 
597 
604  static MSLane* dictionary(const std::string& id);
605 
606 
608  static void clear();
609 
610 
614  static int dictSize() {
615  return (int)myDict.size();
616  }
617 
618 
622  static void insertIDs(std::vector<std::string>& into);
623 
624 
629  template<class RTREE>
630  static void fill(RTREE& into);
632 
633 
634 
635  // XXX: succLink does not exist... Documentation?
640  static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
641  int nRouteSuccs,
642  const MSLane& succLinkSource,
643  const std::vector<MSLane*>& conts);
644 
645 
648  bool isLinkEnd(MSLinkCont::const_iterator& i) const;
649 
652  bool isLinkEnd(MSLinkCont::iterator& i);
653 
656  bool isEmpty() const;
657 
659  bool isInternal() const;
660 
662  MSVehicle* getLastFullVehicle() const;
663 
666 
668  MSVehicle* getLastAnyVehicle() const;
669 
671  MSVehicle* getFirstAnyVehicle() const;
672 
673  /* @brief remove the vehicle from this lane
674  * @param[notify] whether moveReminders of the vehicle shall be triggered
675  */
676  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
677 
678  void leftByLaneChange(MSVehicle* v);
680 
684  MSLane* getParallelLane(int offset) const;
685 
686 
691  void setPermissions(SVCPermissions permissions, long transientID);
692  void resetPermissions(long transientID);
693 
694 
695  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
696  return (myPermissions & vclass) == vclass;
697  }
698 
699  void addIncomingLane(MSLane* lane, MSLink* viaLink);
700 
701 
706  };
707 
708  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
709  return myIncomingLanes;
710  }
711 
712 
713  void addApproachingLane(MSLane* lane, bool warnMultiCon);
714  bool isApproachedFrom(MSEdge* const edge);
715  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
716 
717 
718 
720  std::pair<MSVehicle* const, SUMOReal> getFollowerOnConsecutive(
721  SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist = -1, bool ignoreMinorLinks = false) const;
722 
724  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, bool allSublanes) const;
725 
727  SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const;
728 
741  std::pair<MSVehicle* const, SUMOReal> getLeader(const MSVehicle* veh, const SUMOReal vehPos, const std::vector<MSLane*>& bestLaneConts, SUMOReal dist = -1, bool checkTmpVehicles = false) const;
742 
765  std::pair<MSVehicle* const, SUMOReal> getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen,
766  SUMOReal speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
767 
769  void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle* ego,
770  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
771 
789  std::pair<MSVehicle* const, SUMOReal> getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle& veh) const;
790 
791  /* @brief return the partial vehicle closest behind ego or 0
792  * if no such vehicle exists */
793  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
794 
799 
802  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
803 
806 
808  std::vector<const MSLane*> getOutgoingLanes() const;
809 
811 
812 
816  SUMOReal getMeanSpeed() const;
817 
821  SUMOReal getWaitingSeconds() const;
822 
823 
828 
829 
833  SUMOReal getNettoOccupancy() const;
834 
835 
839  inline SUMOReal getBruttoVehLenSum() const {
841  }
842 
843 
847  SUMOReal getCO2Emissions() const;
848 
849 
853  SUMOReal getCOEmissions() const;
854 
855 
859  SUMOReal getPMxEmissions() const;
860 
861 
865  SUMOReal getNOxEmissions() const;
866 
867 
871  SUMOReal getHCEmissions() const;
872 
873 
878 
879 
884 
885 
891 
892  void setRightSideOnEdge(SUMOReal value, int rightmostSublane) {
893  myRightSideOnEdge = value;
894  myRightmostSublane = rightmostSublane;
895  }
896 
898  return myRightSideOnEdge;
899  }
900 
901  int getRightmostSublane() const {
902  return myRightmostSublane;
903  }
904 
906  return myRightSideOnEdge + 0.5 * myWidth;
907  }
908 
910  void sortPartialVehicles();
911 
913  MSLane* getOpposite() const;
914 
916  SUMOReal getOppositePos(SUMOReal pos) const;
917 
918  /* @brief find leader for a vehicle depending the relative driving direction
919  * @param[in] ego The ego vehicle
920  * @param[in] dist The look-ahead distance when looking at consecutive lanes
921  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
922  * @return the leader vehicle and it's gap to ego
923  */
924  std::pair<MSVehicle* const, SUMOReal> getOppositeLeader(const MSVehicle* ego, SUMOReal dist, bool oppositeDir) const;
925 
926  /* @brief find follower for a vehicle that is located on the opposite of this lane
927  * @param[in] ego The ego vehicle
928  * @return the follower vehicle and it's gap to ego
929  */
930  std::pair<MSVehicle* const, SUMOReal> getOppositeFollower(const MSVehicle* ego) const;
931 
932 
940  std::pair<MSVehicle* const, SUMOReal> getFollower(const MSVehicle* ego, SUMOReal egoPos, SUMOReal dist, bool ignoreMinorLinks) const;
941 
944 
952  void saveState(OutputDevice& out);
953 
965  void loadState(std::vector<std::string>& vehIDs, MSVehicleControl& vc);
967 
968 
969 #ifndef NO_TRACI
970 
977  void visit(const TraCIServerAPI_Lane::StoringVisitor& cont) const {
978  cont.add(this);
979  }
980 #endif
981 
982  static void initCollisionOptions(const OptionsCont& oc);
983 
984  static bool teleportOnCollision() {
986  }
987 
988  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
989  static const long CHANGE_PERMISSIONS_GUI = 1;
990 
991 protected:
993  virtual void swapAfterLaneChange(SUMOTime t);
994 
1006  virtual void incorporateVehicle(MSVehicle* veh, SUMOReal pos, SUMOReal speed, SUMOReal posLat,
1007  const MSLane::VehCont::iterator& at,
1009 
1010 
1012  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1013  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1014  std::set<const MSVehicle*>& toTeleport) const;
1015 
1017  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1018  SUMOReal gap, SUMOReal latGap,
1019  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1020  std::set<const MSVehicle*>& toTeleport) const;
1021 
1023  SUMOReal getMaximumBrakeDist() const;
1024 
1025  /* @brief determine depart speed and whether it may be patched
1026  * @param[in] veh The departing vehicle
1027  * @param[out] whether the speed may be patched to account for safety
1028  * @return the depart speed
1029  */
1030  SUMOReal getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1031 
1034  SUMOReal safeInsertionSpeed(const MSVehicle* veh, const MSLeaderInfo& leaders, SUMOReal speed);
1035 
1037  SUMOReal basePos(const MSVehicle& veh) const;
1038 
1041 
1044 
1046  int myIndex;
1047 
1059  VehCont myVehicles;
1060 
1072 
1075  VehCont myTmpVehicles;
1076 
1079  VehCont myVehBuffer;
1080 
1081 
1084 
1087 
1089  MSEdge* const myEdge;
1090 
1093 
1096 
1099 
1101  const std::map<SUMOVehicleClass, SUMOReal>* myRestrictions;
1102 
1103  std::vector<IncomingLaneInfo> myIncomingLanes;
1105 
1106 
1109 
1112 
1116 
1117  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1118 
1123 
1125 
1130 
1133 
1138 
1139  // @brief the ids of neighboring lanes
1140  std::vector<std::string> myNeighs;
1141 
1142  // @brief transient changes in permissions
1143  std::map<long, SVCPermissions> myPermissionChanges;
1144 
1146  typedef std::map< std::string, MSLane* > DictType;
1147 
1149  static DictType myDict;
1150 
1151 private:
1153  std::vector< MSMoveReminder* > myMoveReminders;
1154 
1158 
1164  public:
1166  explicit vehicle_position_sorter(const MSLane* lane) :
1167  myLane(lane) {
1168  }
1169 
1170 
1176  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1177 
1178  const MSLane* myLane;
1179 
1180  };
1181 
1187  public:
1189  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1190  myLane(lane) {
1191  }
1192 
1193 
1199  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1200 
1201  const MSLane* myLane;
1202 
1203  };
1204 
1210  public:
1212  explicit by_connections_to_sorter(const MSEdge* const e);
1213 
1215  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1216 
1217  private:
1218  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1219  private:
1220  const MSEdge* const myEdge;
1222  };
1223 
1227  class edge_finder {
1228  public:
1229  edge_finder(MSEdge* e) : myEdge(e) {}
1230  bool operator()(const IncomingLaneInfo& ili) const {
1231  return &(ili.lane->getEdge()) == myEdge;
1232  }
1233  private:
1234  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1235  private:
1236  const MSEdge* const myEdge;
1237  };
1238 
1239 private:
1241  MSLane(const MSLane&);
1242 
1244  MSLane& operator=(const MSLane&);
1245 
1246 
1247 };
1248 
1249 
1250 #endif
1251 
1252 /****************************************************************************/
1253 
int getRightmostSublane() const
Definition: MSLane.h:901
int getNumericalID() const
Returns this lane&#39;s numerical id.
Definition: MSLane.h:419
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1101
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:2296
std::pair< MSVehicle *const, SUMOReal > getFollowerOnConsecutive(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist=-1, bool ignoreMinorLinks=false) const
return the follower with the largest missing rear gap among all predecessor lanes (within dist) ...
Definition: MSLane.cpp:1673
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1095
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1059
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:127
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:571
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
Definition: MSLane.h:369
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1427
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1466
long long int SUMOTime
Definition: SUMOTime.h:43
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:1494
void resetPermissions(long transientID)
Definition: MSLane.cpp:2659
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:353
SUMOReal getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2111
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1349
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:1306
std::pair< MSVehicle *const, SUMOReal > getFollower(const MSVehicle *ego, SUMOReal egoPos, SUMOReal dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
Definition: MSLane.cpp:2563
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1480
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:407
static bool teleportOnCollision()
Definition: MSLane.h:984
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:989
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, SUMOReal > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:2605
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:2542
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1357
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
std::vector< IncomingLaneInfo > myIncomingLanes
Definition: MSLane.h:1103
int SVCPermissions
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:149
void setLength(SUMOReal val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:1558
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:192
int myIndex
The lane index.
Definition: MSLane.h:1046
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1393
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1127
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1457
Notification
Definition of a vehicle state.
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2200
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1576
const MSEdge *const myEdge
Definition: MSLane.h:1220
SUMOReal getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:496
SUMOReal getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:1664
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1600
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2096
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:2629
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:205
SUMOReal getCenterOnEdge() const
Definition: MSLane.h:905
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2056
void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal 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:2427
SUMOReal getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2212
std::map< long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1143
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:198
bool isInternal() const
Definition: MSLane.cpp:1443
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1230
std::pair< MSVehicle *const, SUMOReal > getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
Definition: MSLane.cpp:1925
const SUMOReal myWidth
Lane width [m].
Definition: MSLane.h:1086
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
bool freeInsertion(MSVehicle &veh, SUMOReal speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Definition: MSLane.cpp:304
VehCont myPartialVehicles
The lane&#39;s partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1071
static bool myCheckJunctionCollisions
Definition: MSLane.h:1157
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:444
SUMOReal myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1092
SUMOReal getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:839
int myI1End
end index for myVehicles
Definition: MSLane.h:147
int myDirection
index delta
Definition: MSLane.h:153
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1043
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, bool allSublanes) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition: MSLane.cpp:2310
bool myDownstream
iteration direction
Definition: MSLane.h:151
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2188
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:380
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
Definition: MSLane.h:1140
void setMaxSpeed(SUMOReal val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:1551
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1156
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:1146
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, SUMOReal 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:247
MSLinkCont myLinks
Definition: MSLane.h:1115
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:999
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1149
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1610
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:80
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:419
SUMOReal myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1135
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1994
#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:1075
Allows to store the object; used as context while traveling the rtree in TraCI.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:695
std::pair< MSVehicle *const, SUMOReal > getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
Definition: MSLane.cpp:1833
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:614
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:227
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:2034
SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const
return by how much further the leader must be inserted to avoid rear end collisions ...
Definition: MSLane.cpp:1648
SUMOReal basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Definition: MSLane.cpp:503
const MSEdge *const myEdge
Definition: MSLane.h:1236
Representation of a vehicle.
Definition: SUMOVehicle.h:67
void add(const MSLane *const l) const
Adds the given object to the container.
virtual SUMOReal getChosenSpeedFactor() const =0
friend class AnyVehicleIterator
Definition: MSLane.h:88
SUMOReal getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:392
Sorts vehicles by their position (descending)
Definition: MSLane.h:1163
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1098
A list of positions.
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2063
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:1594
SUMOReal getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2124
bool lastInsertion(MSVehicle &veh, SUMOReal mspeed, 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:267
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, SUMOReal minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
Definition: MSLane.cpp:854
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:361
T MIN2(T a, T b)
Definition: StdDefs.h:64
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:472
CollisionAction
Definition: MSLane.h:162
MSLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge *const edge, int numericalID, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, int index)
Constructor.
Definition: MSLane.cpp:162
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1137
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1104
Something on a lane to be noticed about vehicle movement.
SUMOReal myLength
Lane length [m].
Definition: MSLane.h:1083
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:553
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:488
virtual SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:214
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1565
SUMOReal getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:432
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:503
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, SUMOReal gap, SUMOReal latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1168
void setRightSideOnEdge(SUMOReal value, int rightmostSublane)
Definition: MSLane.h:892
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
Definition: MSLane.h:1117
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:1040
std::vector< MSMoveReminder * > myMoveReminders
This lane&#39;s move reminder.
Definition: MSLane.h:1153
SUMOReal safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, SUMOReal speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition: MSLane.cpp:835
const SUMOReal myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1132
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:826
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:1420
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:2647
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2045
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1317
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2176
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2164
The vehicle has departed (was inserted into the network)
int myI1
index for myVehicles
Definition: MSLane.h:143
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const 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:1110
bool operator()(const MSVehicle *cmp, SUMOReal pos) const
compares vehicle position to the detector position
Definition: MSLane.cpp:2241
SUMOReal myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1108
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1340
bool isEmpty() const
Definition: MSLane.cpp:1438
SUMOReal interpolateLanePosToGeometryPos(SUMOReal lanePos) const
Definition: MSLane.h:438
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2140
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1089
const MSVehicle * operator->()
Definition: MSLane.h:129
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2152
Point2D< point_type > operator*(mul_type val, const Point2D< point_type > pt)
Definition: points.h:180
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:141
bool checkFailure(MSVehicle *aVehicle, SUMOReal &speed, SUMOReal &dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:508
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:2518
A storage for options typed value containers)
Definition: OptionsCont.h:99
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.cpp:1624
std::pair< MSVehicle *const, SUMOReal > getOppositeLeader(const MSVehicle *ego, SUMOReal dist, bool oppositeDir) const
Definition: MSLane.cpp:2582
const MSLeaderInfo & getFirstVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos=std::numeric_limits< SUMOReal >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
Definition: MSLane.cpp:905
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:391
MSLane & operator=(const MSLane &)
invalidated assignment operator
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:2285
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1120
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:2551
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:977
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:208
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1122
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:184
SUMOReal myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1111
bool isInsertionSuccess(MSVehicle *vehicle, SUMOReal speed, SUMOReal pos, SUMOReal posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
Definition: MSLane.cpp:526
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1545
The class responsible for building and deletion of vehicles.
MSLeaderInfo myLeaderInfoTmp
Definition: MSLane.h:1124
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1079
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:458
SUMOReal getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2224
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:988
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:708
SUMOReal interpolateGeometryPosToLanePos(SUMOReal geometryPos) const
Definition: MSLane.h:450
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2081
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1223
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1129
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1448
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane&#39;s move reminders.
Definition: MSLane.h:228
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:386
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:401
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
Definition: MSLane.cpp:2070
std::pair< MSVehicle *const, SUMOReal > getLeader(const MSVehicle *veh, const SUMOReal vehPos, const std::vector< MSLane * > &bestLaneConts, SUMOReal dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
Definition: MSLane.cpp:1768
edge_finder(MSEdge *e)
Definition: MSLane.h:1229
virtual bool appropriate(const MSVehicle *veh)
Definition: MSLane.cpp:1375
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:957
SUMOReal getRightSideOnEdge() const
Definition: MSLane.h:897
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1166
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:396
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1189