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-2016 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  bool checkFailure(MSVehicle* aVehicle, SUMOReal& speed, SUMOReal& dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const;
279  bool lastInsertion(MSVehicle& veh, SUMOReal mspeed);
280 
288  bool freeInsertion(MSVehicle& veh, SUMOReal speed,
290 
291 
301  void forceVehicleInsertion(MSVehicle* veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat = 0);
303 
304 
305 
308 
316 
320  virtual void resetPartialOccupation(MSVehicle* v);
321 
332  const MSLeaderInfo& getLastVehicleInformation(const MSVehicle* ego, SUMOReal latOffset, SUMOReal minPos = 0, bool allowCached = true) const;
333 
335  const MSLeaderInfo& getFirstVehicleInformation(const MSVehicle* ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos = std::numeric_limits<SUMOReal>::max(), bool allowCached = true) const;
336 
338 
339 
340 
343 
348  int getVehicleNumber() const {
349  return (int)myVehicles.size();
350  }
351 
357  return (int)myVehicles.size() + (int)myPartialVehicles.size();
358  }
359 
365  return (int)myPartialVehicles.size();
366  }
367 
368 
375  virtual const VehCont& getVehiclesSecure() const {
376  return myVehicles;
377  }
378 
379 
382  return AnyVehicleIterator(this, 0, 0, (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
383  }
384 
387  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
388  }
389 
392  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, -1, -1, false);
393  }
394 
397  return AnyVehicleIterator(this, -1, -1, -1, -1, false);
398  }
399 
402  virtual void releaseVehicles() const { }
404 
405 
406 
409 
410 
414  inline int getNumericalID() const {
415  return myNumericalID;
416  }
417 
418 
422  inline const PositionVector& getShape() const {
423  return myShape;
424  }
425 
428  return myLengthGeometryFactor;
429  }
430 
431  /* @brief fit the given lane position to a visibly suitable geometry position
432  * (lane length might differ from geometry length) */
434  return lanePos * myLengthGeometryFactor;
435  }
436 
437  /* @brief fit the given lane position to a visibly suitable geometry position
438  * and return the coordinates */
439  inline const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset = 0) const {
440  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
441  }
442 
443  /* @brief fit the given geomtry position to a valid lane position
444  * (lane length might differ from geometry length) */
446  return geometryPos / myLengthGeometryFactor;
447  }
448 
453  inline SUMOReal getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
454  if (myRestrictions != 0) {
455  std::map<SUMOVehicleClass, SUMOReal>::const_iterator r = myRestrictions->find(veh->getVClass());
456  if (r != myRestrictions->end()) {
457  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
458  }
459  }
460  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
461  }
462 
463 
467  inline SUMOReal getSpeedLimit() const {
468  return myMaxSpeed;
469  }
470 
471 
475  inline SUMOReal getLength() const {
476  return myLength;
477  }
478 
479 
484  return myPermissions;
485  }
486 
487 
491  SUMOReal getWidth() const {
492  return myWidth;
493  }
494 
498  int getIndex() const {
499  return myIndex;
500  }
502 
504  int getCrossingIndex() const;
505 
506 
509 
517  virtual void planMovements(const SUMOTime t);
518 
527  virtual bool executeMovements(SUMOTime t, std::vector<MSLane*>& lanesWithVehiclesToIntegrate);
528 
530  virtual bool integrateNewVehicle(SUMOTime t);
532 
533 
534 
536  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
537 
538 
541  virtual bool appropriate(const MSVehicle* veh);
542 
543 
545  const MSLinkCont& getLinkCont() const;
546 
547 
549  bool empty() const {
550  assert(myVehBuffer.size() == 0);
551  return myVehicles.empty();
552  }
553 
557  void setMaxSpeed(SUMOReal val);
558 
562  void setLength(SUMOReal val);
563 
567  MSEdge& getEdge() const {
568  return *myEdge;
569  }
570 
571 
575  const MSEdge* getInternalFollower() const;
576 
577 
580 
591  static bool dictionary(const std::string& id, MSLane* lane);
592 
593 
600  static MSLane* dictionary(const std::string& id);
601 
602 
604  static void clear();
605 
606 
610  static int dictSize() {
611  return (int)myDict.size();
612  }
613 
614 
618  static void insertIDs(std::vector<std::string>& into);
619 
620 
625  template<class RTREE>
626  static void fill(RTREE& into);
628 
629 
630 
635  static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
636  int nRouteSuccs,
637  const MSLane& succLinkSource,
638  const std::vector<MSLane*>& conts);
639 
640 
643  bool isLinkEnd(MSLinkCont::const_iterator& i) const;
644 
647  bool isLinkEnd(MSLinkCont::iterator& i);
648 
651  bool isEmpty() const;
652 
654  MSVehicle* getLastFullVehicle() const;
655 
658 
660  MSVehicle* getLastAnyVehicle() const;
661 
663  MSVehicle* getFirstAnyVehicle() const;
664 
665  /* @brief remove the vehicle from this lane
666  * @param[notify] whether moveReminders of the vehicle shall be triggered
667  */
668  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
669 
670  void leftByLaneChange(MSVehicle* v);
672 
676  MSLane* getParallelLane(int offset) const;
677 
678 
679  inline void setPermissions(SVCPermissions permissions) {
680  myPermissions = permissions;
681  }
682 
683 
684  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
685  return (myPermissions & vclass) == vclass;
686  }
687 
688  void addIncomingLane(MSLane* lane, MSLink* viaLink);
689 
690 
695  };
696 
697  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
698  return myIncomingLanes;
699  }
700 
701 
702  void addApproachingLane(MSLane* lane, bool warnMultiCon);
703  bool isApproachedFrom(MSEdge* const edge);
704  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
705 
706 
707 
709  std::pair<MSVehicle* const, SUMOReal> getFollowerOnConsecutive(
710  SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist = -1) const;
711 
713  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, bool allSublanes) const;
714 
716  SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const;
717 
730  std::pair<MSVehicle* const, SUMOReal> getLeader(const MSVehicle* veh, const SUMOReal vehPos, const std::vector<MSLane*>& bestLaneConts, SUMOReal dist = -1, bool checkTmpVehicles = false) const;
731 
754  std::pair<MSVehicle* const, SUMOReal> getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen,
755  SUMOReal speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
756 
758  void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle* ego,
759  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
760 
778  std::pair<MSVehicle* const, SUMOReal> getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle& veh) const;
779 
780  /* @brief return the partial vehicle closest behind ego or 0
781  * if no such vehicle exists */
782  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
783 
788 
791  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
792 
795 
797  std::vector<const MSLane*> getOutgoingLanes() const;
798 
800 
801 
805  SUMOReal getMeanSpeed() const;
806 
810  SUMOReal getWaitingSeconds() const;
811 
812 
817 
818 
822  SUMOReal getNettoOccupancy() const;
823 
824 
828  inline SUMOReal getBruttoVehLenSum() const {
830  }
831 
832 
836  SUMOReal getCO2Emissions() const;
837 
838 
842  SUMOReal getCOEmissions() const;
843 
844 
848  SUMOReal getPMxEmissions() const;
849 
850 
854  SUMOReal getNOxEmissions() const;
855 
856 
860  SUMOReal getHCEmissions() const;
861 
862 
867 
868 
873 
874 
880 
881  void setRightSideOnEdge(SUMOReal value, int rightmostSublane) {
882  myRightSideOnEdge = value;
883  myRightmostSublane = rightmostSublane;
884  }
885 
887  return myRightSideOnEdge;
888  }
889 
890  int getRightmostSublane() const {
891  return myRightmostSublane;
892  }
893 
895  return myRightSideOnEdge + 0.5 * myWidth;
896  }
897 
899  void sortPartialVehicles();
900 
902  MSLane* getOpposite() const;
903 
905  SUMOReal getOppositePos(SUMOReal pos) const;
906 
907  std::pair<MSVehicle* const, SUMOReal> getOppositeLeader(const MSVehicle* ego, SUMOReal dist) const;
908 
909  std::pair<MSVehicle* const, SUMOReal> getOppositeFollower(const MSVehicle* ego) const;
910 
911 
918  std::pair<MSVehicle* const, SUMOReal> getFollower(const MSVehicle* ego, SUMOReal egoPos, SUMOReal dist) const;
919 
922 
930  void saveState(OutputDevice& out);
931 
943  void loadState(std::vector<std::string>& vehIDs, MSVehicleControl& vc);
945 
946 
947 #ifndef NO_TRACI
948 
955  void visit(const TraCIServerAPI_Lane::StoringVisitor& cont) const {
956  cont.add(this);
957  }
958 #endif
959 
960  static void initCollisionOptions(const OptionsCont& oc);
961 
962  static bool teleportOnCollision() {
964  }
965 
966 protected:
968  virtual void swapAfterLaneChange(SUMOTime t);
969 
981  virtual void incorporateVehicle(MSVehicle* veh, SUMOReal pos, SUMOReal speed, SUMOReal posLat,
982  const MSLane::VehCont::iterator& at,
984 
985 
987  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
988  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
989  std::set<const MSVehicle*>& toTeleport) const;
990 
992  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
993  SUMOReal gap, SUMOReal latGap,
994  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
995  std::set<const MSVehicle*>& toTeleport) const;
996 
999 
1000  /* @brief determine depart speed and whether it may be patched
1001  * @param[in] veh The departing vehicle
1002  * @param[out] whether the speed may be patched to account for safety
1003  * @return the depart speed
1004  */
1005  SUMOReal getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1006 
1009  SUMOReal safeInsertionSpeed(const MSVehicle* veh, const MSLeaderInfo& leaders, SUMOReal speed);
1010 
1012  SUMOReal basePos(const MSVehicle& veh) const;
1013 
1016 
1019 
1021  int myIndex;
1022 
1034  VehCont myVehicles;
1035 
1047 
1050  VehCont myTmpVehicles;
1051 
1054  VehCont myVehBuffer;
1055 
1056 
1059 
1062 
1064  MSEdge* const myEdge;
1065 
1068 
1071 
1073  const std::map<SUMOVehicleClass, SUMOReal>* myRestrictions;
1074 
1075  std::vector<IncomingLaneInfo> myIncomingLanes;
1077 
1078 
1081 
1084 
1088 
1089  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1090 
1095 
1097 
1102 
1105 
1110 
1111  // @brief the ids of neighboring lanes
1112  std::vector<std::string> myNeighs;
1113 
1115  typedef std::map< std::string, MSLane* > DictType;
1116 
1118  static DictType myDict;
1119 
1120 private:
1122  std::vector< MSMoveReminder* > myMoveReminders;
1123 
1127 
1133  public:
1135  explicit vehicle_position_sorter(const MSLane* lane) :
1136  myLane(lane) {
1137  }
1138 
1139 
1145  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1146 
1147  const MSLane* myLane;
1148 
1149  };
1150 
1156  public:
1158  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1159  myLane(lane) {
1160  }
1161 
1162 
1168  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1169 
1170  const MSLane* myLane;
1171 
1172  };
1173 
1179  public:
1181  explicit by_connections_to_sorter(const MSEdge* const e);
1182 
1184  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1185 
1186  private:
1187  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1188  private:
1189  const MSEdge* const myEdge;
1191  };
1192 
1196  class edge_finder {
1197  public:
1198  edge_finder(MSEdge* e) : myEdge(e) {}
1199  bool operator()(const IncomingLaneInfo& ili) const {
1200  return &(ili.lane->getEdge()) == myEdge;
1201  }
1202  private:
1203  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1204  private:
1205  const MSEdge* const myEdge;
1206  };
1207 
1208 private:
1210  MSLane(const MSLane&);
1211 
1213  MSLane& operator=(const MSLane&);
1214 
1215 
1216 };
1217 
1218 
1219 #endif
1220 
1221 /****************************************************************************/
1222 
int getRightmostSublane() const
Definition: MSLane.h:890
int getNumericalID() const
Returns this lane&#39;s numerical id.
Definition: MSLane.h:414
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1073
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:2185
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1070
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1034
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:567
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
Definition: MSLane.h:364
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:81
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1334
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1368
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:1396
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:348
SUMOReal getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2000
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1258
const MSEdge * getInternalFollower() const
Returns the lane&#39;s follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1215
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1382
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:402
static bool teleportOnCollision()
Definition: MSLane.h:962
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:2490
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:2429
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1266
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:475
std::vector< IncomingLaneInfo > myIncomingLanes
Definition: MSLane.h:1075
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:1458
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:189
int myIndex
The lane index.
Definition: MSLane.h:1021
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1302
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1099
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1359
Notification
Definition of a vehicle state.
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2089
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1476
const MSEdge *const myEdge
Definition: MSLane.h:1189
SUMOReal getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:491
SUMOReal getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:1564
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1500
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:1985
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:2514
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:202
SUMOReal getCenterOnEdge() const
Definition: MSLane.h:894
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:1945
void setPermissions(SVCPermissions permissions)
Definition: MSLane.h:679
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:2314
SUMOReal getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2101
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:195
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1199
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:1814
const SUMOReal myWidth
Lane width [m].
Definition: MSLane.h:1061
bool freeInsertion(MSVehicle &veh, SUMOReal speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Definition: MSLane.cpp:283
VehCont myPartialVehicles
The lane&#39;s partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1046
static bool myCheckJunctionCollisions
Definition: MSLane.h:1126
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:439
SUMOReal myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1067
SUMOReal getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:828
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:1018
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:2197
bool myDownstream
iteration direction
Definition: MSLane.h:151
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2077
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:375
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
Definition: MSLane.h:1112
void setMaxSpeed(SUMOReal val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:1451
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1125
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1115
bool lastInsertion(MSVehicle &veh, SUMOReal mspeed)
Definition: MSLane.cpp:264
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:244
MSLinkCont myLinks
Definition: MSLane.h:1087
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:916
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1118
virtual SUMOReal getChosenSpeedFactor() const =0
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1510
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:398
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
SUMOReal myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1107
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1883
#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:1050
Allows to store the object; used as context while traveling the rtree in TraCI.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:684
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:1722
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:610
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:224
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:1923
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:1548
SUMOReal basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Definition: MSLane.cpp:482
const MSEdge *const myEdge
Definition: MSLane.h:1205
Representation of a vehicle.
Definition: SUMOVehicle.h:66
void add(const MSLane *const l) const
Adds the given object to the container.
friend class AnyVehicleIterator
Definition: MSLane.h:88
SUMOReal getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:371
Sorts vehicles by their position (descending)
Definition: MSLane.h:1132
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:1952
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:1494
SUMOReal getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2013
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:771
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:356
T MIN2(T a, T b)
Definition: StdDefs.h:69
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:467
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:160
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1109
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1076
Something on a lane to be noticed about vehicle movement.
SUMOReal myLength
Lane length [m].
Definition: MSLane.h:1058
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:549
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:483
virtual SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:211
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1465
SUMOReal getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:427
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:498
An upper class for objects with additional parameters.
Definition: Parameterised.h:47
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:1069
void setRightSideOnEdge(SUMOReal value, int rightmostSublane)
Definition: MSLane.h:881
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
Definition: MSLane.h:1089
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:1015
std::vector< MSMoveReminder * > myMoveReminders
This lane&#39;s move reminder.
Definition: MSLane.h:1122
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:752
const SUMOReal myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1104
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:743
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:1327
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:1934
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1226
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2065
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2053
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:1023
bool operator()(const MSVehicle *cmp, SUMOReal pos) const
compares vehicle position to the detector position
Definition: MSLane.cpp:2130
std::pair< MSVehicle *const, SUMOReal > getOppositeLeader(const MSVehicle *ego, SUMOReal dist) const
Definition: MSLane.cpp:2469
SUMOReal myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1080
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1249
bool isEmpty() const
Definition: MSLane.cpp:1345
SUMOReal interpolateLanePosToGeometryPos(SUMOReal lanePos) const
Definition: MSLane.h:433
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2029
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1064
const MSVehicle * operator->()
Definition: MSLane.h:129
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2041
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:487
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:2405
A storage for options typed value containers)
Definition: OptionsCont.h:99
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.cpp:1524
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:822
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:386
MSLane & operator=(const MSLane &)
invalidated assignment operator
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:2174
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1092
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:422
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:2438
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:955
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1094
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:181
SUMOReal myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1083
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:505
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1445
The class responsible for building and deletion of vehicles.
std::pair< MSVehicle *const, SUMOReal > getFollower(const MSVehicle *ego, SUMOReal egoPos, SUMOReal dist) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
Definition: MSLane.cpp:2450
MSLeaderInfo myLeaderInfoTmp
Definition: MSLane.h:1096
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1054
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:453
SUMOReal getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2113
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:697
SUMOReal interpolateGeometryPosToLanePos(SUMOReal geometryPos) const
Definition: MSLane.h:445
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:1970
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1124
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1101
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1350
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:381
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:396
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
Definition: MSLane.cpp:1959
std::pair< MSVehicle *const, SUMOReal > getFollowerOnConsecutive(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist=-1) const
return the follower with the largest missing rear gap among all predecessor lanes (within dist) ...
Definition: MSLane.cpp:1573
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:1664
edge_finder(MSEdge *e)
Definition: MSLane.h:1198
virtual bool appropriate(const MSVehicle *veh)
Definition: MSLane.cpp:1284
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:874
SUMOReal getRightSideOnEdge() const
Definition: MSLane.h:886
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1135
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:391
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1158