Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MSLane.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
25// Representation of a lane in the micro simulation
26/****************************************************************************/
27#pragma once
28#include <config.h>
29
30#include <memory>
31#include <vector>
32#include <map>
33#include <deque>
34#include <cassert>
35#include <utils/common/Named.h>
42#include "MSGlobals.h"
43#include "MSLeaderInfo.h"
44#include "MSMoveReminder.h"
45#include "MSVehicle.h"
46
48#ifdef HAVE_FOX
50#endif
52
53
54// ===========================================================================
55// class declarations
56// ===========================================================================
57class MSEdge;
58class MSBaseVehicle;
59class MSLaneChanger;
60class MSLink;
63class OutputDevice;
64class MSLeaderInfo;
65class MSJunction;
66
67
68// ===========================================================================
69// type definitions
70// ===========================================================================
72typedef std::map<const MSLane*, std::pair<double, double> > LaneCoverageInfo;
73
74// ===========================================================================
75// class definitions
76// ===========================================================================
84class MSLane : public Named, public Parameterised {
85public:
87 public:
89 StoringVisitor(std::set<const Named*>& objects, const PositionVector& shape,
90 const double range, const int domain)
91 : myObjects(objects), myShape(shape), myRange(range), myDomain(domain) {}
92
94 void add(const MSLane* const l) const;
95
96 private:
98 std::set<const Named*>& myObjects;
100 const double myRange;
101 const int myDomain;
102
103 private:
106
109 };
110
112 friend class MSLaneChanger;
114
115 friend class MSQueueExport;
116 friend class AnyVehicleIterator;
117
119 typedef std::vector<MSVehicle*> VehCont;
120
121 // TODO: Better documentation
130 public:
132 const MSLane* lane,
133 int i1,
134 int i2,
135 int i3,
136 const int i1End,
137 const int i2End,
138 const int i3End,
139 bool downstream = true) :
140 myLane(lane),
141 myI1(i1),
142 myI2(i2),
143 myI3(i3),
144 myI1End(i1End),
145 myI2End(i2End),
146 myI3End(i3End),
147 myDownstream(downstream),
148 myDirection(downstream ? 1 : -1) {
149 }
150
151 bool operator== (AnyVehicleIterator const& other) const {
152 return (myI1 == other.myI1
153 && myI2 == other.myI2
154 && myI3 == other.myI3
155 && myI1End == other.myI1End
156 && myI2End == other.myI2End
157 && myI3End == other.myI3End);
158 }
159
160 bool operator!= (AnyVehicleIterator const& other) const {
161 return !(*this == other);
162 }
163
165 return **this;
166 }
167
168 const MSVehicle* operator*();
169
171
172 private:
173 bool nextIsMyVehicles() const;
174
178 int myI1;
180 int myI2;
182 int myI3;
193
194 };
195
196
197public:
207
223 MSLane(const std::string& id, double maxSpeed, double friction, double length, MSEdge* const edge,
224 int numericalID, const PositionVector& shape, double width,
225 SVCPermissions permissions,
226 SVCPermissions changeLeft, SVCPermissions changeRight,
227 int index, bool isRampAccel,
228 const std::string& type,
229 const PositionVector& outlineShape);
230
231
233 virtual ~MSLane();
234
236 inline int getThreadIndex() const {
238 }
239
241 inline int getRNGIndex() const {
242 return myRNGIndex;
243 }
244
246 SumoRNG* getRNG() const {
247 return &myRNGs[myRNGIndex];
248 }
249
251 static int getNumRNGs() {
252 return (int)myRNGs.size();
253 }
254
256 static void saveRNGStates(OutputDevice& out);
257
259 static void loadRNGState(int index, const std::string& state);
260
263
271 void addLink(MSLink* link);
272
277 void setOpposite(MSLane* oppositeLane);
278
283 void setBidiLane(MSLane* bidyLane);
285
288 virtual void addSecondaryShape(const PositionVector& /*shape*/) {}
289
290 virtual double getLengthGeometryFactor(bool /*secondaryShape*/) const {
292 }
293
294 virtual const PositionVector& getShape(bool /*secondaryShape*/) const {
295 return myShape;
296 }
298
299
302
309 virtual void addMoveReminder(MSMoveReminder* rem, bool addToVehicles = true);
310
311
317 virtual void removeMoveReminder(MSMoveReminder* rem);
318
319
323 inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
324 return myMoveReminders;
325 }
327
328
329
332
348 bool insertVehicle(MSVehicle& v);
349
350
369 bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
370 bool recheckNextLanes,
371 MSMoveReminder::Notification notification);
372
373 // XXX: Documentation?
374 bool checkFailure(const MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const;
375
379 bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
380
388 bool freeInsertion(MSVehicle& veh, double speed, double posLat,
390
391
401 void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
403
404
405
409
416 virtual double setPartialOccupation(MSVehicle* v);
417
421 virtual void resetPartialOccupation(MSVehicle* v);
422
425 virtual void setManeuverReservation(MSVehicle* v);
426
430 virtual void resetManeuverReservation(MSVehicle* v);
431
442 const MSLeaderInfo getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
443
445 const MSLeaderInfo getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
446
448
451
456 int getVehicleNumber() const {
457 return (int)myVehicles.size();
458 }
459
465 return (int)myVehicles.size() + (int)myPartialVehicles.size();
466 }
467
473 return (int)myPartialVehicles.size();
474 }
475
476
483 virtual const VehCont& getVehiclesSecure() const {
484 return myVehicles;
485 }
486
487
490 return AnyVehicleIterator(this, 0, 0, 0,
491 (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
492 }
493
496 return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(),
497 (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
498 }
499
502 return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, (int)myTmpVehicles.size() - 1,
503 -1, -1, -1, false);
504 }
505
508 return AnyVehicleIterator(this, -1, -1, -1, -1, -1, -1, false);
509 }
510
513 virtual void releaseVehicles() const { }
515
516
517
520
521
525 inline int getNumericalID() const {
526 return myNumericalID;
527 }
528
529
533 inline const PositionVector& getShape() const {
534 return myShape;
535 }
536
538 inline double getLengthGeometryFactor() const {
540 }
541
543 inline bool isAccelLane() const {
544 return myIsRampAccel;
545 }
546
548 const std::string& getLaneType() const {
549 return myLaneType;
550 }
551
552 /* @brief fit the given lane position to a visibly suitable geometry position
553 * (lane length might differ from geometry length) */
554 inline double interpolateLanePosToGeometryPos(double lanePos) const {
555 return lanePos * myLengthGeometryFactor;
556 }
557
558 /* @brief fit the given lane position to a visibly suitable geometry position
559 * and return the coordinates */
560 inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
561 return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
562 }
563
564 /* @brief fit the given geometry position to a valid lane position
565 * (lane length might differ from geometry length) */
566 inline double interpolateGeometryPosToLanePos(double geometryPos) const {
567 return geometryPos / myLengthGeometryFactor;
568 }
569
574 inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh) const {
575 if (myRestrictions != nullptr) {
576 std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
577 if (r != myRestrictions->end()) {
579 return MIN2(myMaxSpeed, MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor()));
580 } else {
581 return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
582 }
583 }
584 }
585 return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
586 }
587
588
592 inline double getSpeedLimit() const {
593 return myMaxSpeed;
594 }
595
599 inline double getFrictionCoefficient() const {
601 }
602
606 inline double getLength() const {
607 return myLength;
608 }
609
610
615 return myPermissions;
616 }
617
622 return myChangeLeft;
623 }
624
629 return myChangeRight;
630 }
631
635 double getWidth() const {
636 return myWidth;
637 }
638
642 int getIndex() const {
643 return myIndex;
644 }
646
648 int getCrossingIndex() const;
649
650
653
661 virtual void planMovements(const SUMOTime t);
662
668 virtual void setJunctionApproaches() const;
669
678 void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
679
690 virtual void executeMovements(const SUMOTime t);
691
693 virtual void integrateNewVehicles();
694
698
700 void updateLengthSum();
702
703
705 inline bool needsCollisionCheck() const {
707 }
708
710 inline void requireCollisionCheck() {
712 }
713
715 virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
716
717
720 virtual bool appropriate(const MSVehicle* veh) const;
721
722
724 const std::vector<MSLink*>& getLinkCont() const {
725 return myLinks;
726 }
727
729 const MSLink* getLinkTo(const MSLane* const) const;
730
732 const MSLane* getInternalFollowingLane(const MSLane* const) const;
733
735 const MSLink* getEntryLink() const;
736
737
739 bool empty() const {
740 assert(myVehBuffer.size() == 0);
741 return myVehicles.empty();
742 }
743
749 void setMaxSpeed(double val, bool byVSS = false, bool byTraCI = false, double jamThreshold = -1);
750
754 void setFrictionCoefficient(double val);
755
759 void setLength(double val);
760
764 MSEdge& getEdge() const {
765 return *myEdge;
766 }
767
768
772 const MSEdge* getNextNormal() const;
773
774
780 const MSLane* getFirstInternalInConnection(double& offset) const;
781
782
785
796 static bool dictionary(const std::string& id, MSLane* lane);
797
798
805 static MSLane* dictionary(const std::string& id);
806
807
809 static void clear();
810
811
815 static int dictSize() {
816 return (int)myDict.size();
817 }
818
819
823 static void insertIDs(std::vector<std::string>& into);
824
825
830 template<class RTREE>
831 static void fill(RTREE& into);
832
833
835 static void initRNGs(const OptionsCont& oc);
837
838
839
840 // XXX: succLink does not exist... Documentation?
845 static std::vector<MSLink*>::const_iterator succLinkSec(const SUMOVehicle& veh,
846 int nRouteSuccs,
847 const MSLane& succLinkSource,
848 const std::vector<MSLane*>& conts);
849
850
853 inline bool isLinkEnd(std::vector<MSLink*>::const_iterator& i) const {
854 return i == myLinks.end();
855 }
856
859 inline bool isLinkEnd(std::vector<MSLink*>::iterator& i) {
860 return i == myLinks.end();
861 }
862
865 inline bool isEmpty() const {
866 return myVehicles.empty() && myPartialVehicles.empty();
867 }
868
870 bool isInternal() const;
871
873 bool isNormal() const;
874
876 bool isCrossing() const;
877
879 bool isWalkingArea() const;
880
883
886
889
892
893 /* @brief remove the vehicle from this lane
894 * @param[notify] whether moveReminders of the vehicle shall be triggered
895 */
896 virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
897
900
904 MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
905
906
911 void setPermissions(SVCPermissions permissions, long long transientID);
912 void resetPermissions(long long transientID);
913 bool hadPermissionChanges() const;
914
918 void setChangeLeft(SVCPermissions permissions);
919
923 void setChangeRight(SVCPermissions permissions);
924
925 inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
926 return (myPermissions & vclass) == vclass;
927 }
928
929 bool allowsVehicleClass(SUMOVehicleClass vclass, int routingMode) const;
930
932 inline bool allowsChangingLeft(SUMOVehicleClass vclass) const {
933 return (myChangeLeft & vclass) == vclass;
934 }
935
937 inline bool allowsChangingRight(SUMOVehicleClass vclass) const {
938 return (myChangeRight & vclass) == vclass;
939 }
940
941 void addIncomingLane(MSLane* lane, MSLink* viaLink);
942
943
949
950 const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
951 return myIncomingLanes;
952 }
953
954
955 void addApproachingLane(MSLane* lane, bool warnMultiCon);
956 inline bool isApproachedFrom(MSEdge* const edge) {
957 return myApproachingLanes.find(edge) != myApproachingLanes.end();
958 }
959 bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
960
962 double getVehicleStopOffset(const MSVehicle* veh) const;
963
965 const StopOffset& getLaneStopOffsets() const;
966
968 void setLaneStopOffset(const StopOffset& stopOffset);
969
978
980 MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
981 bool allSublanes, double searchDist = -1, MinorLinkMode mLinkMode = FOLLOW_ALWAYS) const;
982
984 double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
985
998 std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
999
1023 std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
1024 double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts, bool considerCrossingFoes = true) const;
1025
1027 void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
1028 const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result, bool oppositeDirection = false) const;
1029
1030
1032 void addLeaders(const MSVehicle* vehicle, double vehPos, MSLeaderDistanceInfo& result, bool oppositeDirection = false);
1033
1034
1052 std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
1053
1054 /* @brief return the partial vehicle closest behind ego or 0
1055 * if no such vehicle exists */
1056 MSVehicle* getPartialBehind(const MSVehicle* ego) const;
1057
1060
1071 std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
1072
1075 std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
1076
1078 std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1079
1081 std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1082
1087
1091 const MSLane* getNormalPredecessorLane() const;
1092
1096 const MSLane* getNormalSuccessorLane() const;
1097
1100 MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
1101
1102
1109
1110
1117
1120
1122 const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
1123
1125 std::vector<const MSLane*> getNormalIncomingLanes() const;
1126
1128
1129
1133 double getMeanSpeed() const;
1134
1136 double getMeanSpeedBike() const;
1137
1141 double getWaitingSeconds() const;
1142
1143
1147 double getBruttoOccupancy() const;
1148
1149
1153 double getNettoOccupancy() const;
1154
1155
1159 inline double getBruttoVehLenSum() const {
1161 }
1162
1163
1168 template<PollutantsInterface::EmissionType ET>
1169 double getEmissions() const {
1170 double ret = 0;
1171 for (MSVehicle* const v : getVehiclesSecure()) {
1172 ret += v->getEmissions<ET>();
1173 }
1175 return ret;
1176 }
1177
1178
1182 double getHarmonoise_NoiseEmissions() const;
1184
1185 void setRightSideOnEdge(double value, int rightmostSublane) {
1186 myRightSideOnEdge = value;
1187 myRightmostSublane = rightmostSublane;
1188 }
1189
1191 void initRestrictions();
1192
1193 void checkBufferType();
1194
1195 double getRightSideOnEdge() const {
1196 return myRightSideOnEdge;
1197 }
1198
1200 return myRightmostSublane;
1201 }
1202
1203 double getCenterOnEdge() const {
1204 return myRightSideOnEdge + 0.5 * myWidth;
1205 }
1206
1208 void sortPartialVehicles();
1209
1212
1214 MSLane* getOpposite() const;
1215
1217 MSLane* getParallelOpposite() const;
1218
1220 double getOppositePos(double pos) const;
1221
1222 /* @brief find leader for a vehicle depending on the relative driving direction
1223 * @param[in] ego The ego vehicle
1224 * @param[in] dist The look-ahead distance when looking at consecutive lanes
1225 * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1226 * @return the leader vehicle and its gap to ego
1227 */
1228 std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode = MinorLinkMode::FOLLOW_NEVER) const;
1229
1230 /* @brief find follower for a vehicle that is located on the opposite of this lane
1231 * @param[in] ego The ego vehicle
1232 * @return the follower vehicle and its gap to ego
1233 */
1234 std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1235
1236
1244 std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, MinorLinkMode mLinkMode) const;
1245
1246
1248 void addParking(MSBaseVehicle* veh);
1249
1251 virtual void removeParking(MSBaseVehicle* veh);
1252
1254 const std::set<const MSBaseVehicle*>& getParkingVehicles() const {
1255 return myParkingVehicles;
1256 }
1257
1259 virtual bool isSelected() const {
1260 return false;
1261 }
1262
1264 MSLane* getBidiLane() const;
1265
1267 bool mustCheckJunctionCollisions() const;
1268
1269#ifdef HAVE_FOX
1270 MFXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1271 mySimulationTask.init(&MSLane::planMovements, time);
1272 return &mySimulationTask;
1273 }
1274
1275 MFXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1276 mySimulationTask.init(&MSLane::executeMovements, time);
1277 return &mySimulationTask;
1278 }
1279
1280 MFXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1281 mySimulationTask.init(&MSLane::changeLanes, time);
1282 return &mySimulationTask;
1283 }
1284#endif
1285
1286 std::vector<StopWatch<std::chrono::nanoseconds> >& getStopWatch() {
1287 return myStopWatch;
1288 }
1289
1290 void changeLanes(const SUMOTime time);
1291
1294
1302 void saveState(OutputDevice& out);
1303
1305 void clearState();
1306
1317 void loadState(const std::vector<SUMOVehicle*>& vehs);
1318
1319
1320 /* @brief helper function for state saving: checks whether any outgoing
1321 * links are being approached */
1322 bool hasApproaching() const;
1323
1325
1326
1334 void visit(const MSLane::StoringVisitor& cont) const {
1335 cont.add(this);
1336 }
1337
1339 bool hasPedestrians() const;
1340
1342 std::pair<const MSPerson*, double> nextBlocking(double minPos, double minRight, double maxLeft, double stopTime = 0, bool bidi = false) const;
1343
1345 double getSpaceTillLastStanding(const MSVehicle* ego, bool& foundStopped) const;
1346
1348 double getMaximumBrakeDist() const;
1349
1350 inline const PositionVector* getOutlineShape() const {
1351 return myOutlineShape;
1352 }
1353
1354 static void initCollisionOptions(const OptionsCont& oc);
1355 static void initCollisionAction(const OptionsCont& oc, const std::string& option, CollisionAction& myAction);
1356
1360
1364
1365 static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1366 static const long CHANGE_PERMISSIONS_GUI = 1;
1367
1368protected:
1370 virtual void swapAfterLaneChange(SUMOTime t);
1371
1383 virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1384 const MSLane::VehCont::iterator& at,
1386
1388 void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1389 SUMOTime timestep, const std::string& stage,
1390 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1391 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport);
1392
1394 bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1395 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1396 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1397
1399 void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1400 double gap, double latGap,
1401 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1402 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1403
1404 void handleIntermodalCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSTransportable* victim,
1405 double gap, const std::string& collisionType,
1406 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1407 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1408
1409 /* @brief determine depart speed and whether it may be patched
1410 * @param[in] veh The departing vehicle
1411 * @param[out] whether the speed may be patched to account for safety
1412 * @return the depart speed
1413 */
1414 double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1415
1416 /* @brief determine the lateral depart position
1417 * @param[in] veh The departing vehicle
1418 * @return the lateral depart position
1419 */
1420 double getDepartPosLat(const MSVehicle& veh);
1421
1424 double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1425
1427 bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1428
1430 bool hasApproaching(const std::vector<MSLink*>& links) const;
1431
1433 double getFractionalVehicleLength(bool brutto) const;
1434
1436 static bool isFrontalCollision(const MSVehicle* collider, const MSVehicle* victim);
1437
1440
1443
1446
1449
1462
1474
1478
1482
1490
1491 /* @brief list of vehicles that are parking near this lane
1492 * (not necessarily on the road but having reached their stop on this lane)
1493 * */
1494 std::set<const MSBaseVehicle*> myParkingVehicles;
1495
1497 double myLength;
1498
1500 const double myWidth;
1501
1506
1509
1514
1517
1520
1523
1527
1530
1532 const std::map<SUMOVehicleClass, double>* myRestrictions;
1533
1535 std::vector<IncomingLaneInfo> myIncomingLanes;
1536
1539
1542
1545
1548
1551
1554
1557
1560
1563 std::vector<MSLink*> myLinks;
1564
1566 std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1567
1572
1577
1580
1582 const bool myIsRampAccel;
1583
1585 const std::string myLaneType;
1586
1591
1594
1595 // @brief the neighboring opposite direction or nullptr
1597
1598 // @brief bidi lane or nullptr
1600
1601 // @brief transient changes in permissions
1602 std::map<long long, SVCPermissions> myPermissionChanges;
1603
1604 // @brief index of the associated thread-rng
1606
1608 typedef std::map< std::string, MSLane* > DictType;
1609
1612
1613 static std::vector<SumoRNG> myRNGs;
1614
1615private:
1617 std::vector< MSMoveReminder* > myMoveReminders;
1618
1628
1634 public:
1636 explicit vehicle_position_sorter(const MSLane* lane) :
1637 myLane(lane) {
1638 }
1639
1640
1646 int operator()(MSVehicle* v1, MSVehicle* v2) const;
1647
1649
1650 };
1651
1657 public:
1660 myLane(lane) {
1661 }
1662
1663
1669 int operator()(MSVehicle* v1, MSVehicle* v2) const;
1670
1672
1673 };
1674
1680 public:
1682 explicit by_connections_to_sorter(const MSEdge* const e);
1683
1685 int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1686
1687 private:
1688 const MSEdge* const myEdge;
1690 };
1691
1692
1693
1699 public:
1701 explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1702
1704 int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1705
1706 private:
1707 const MSLane* const myLane;
1709 };
1710
1711
1717 public:
1719 explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1720
1722 int operator()(const MSLink* link1, const MSLink* link2) const;
1723
1724 private:
1726 };
1727
1732 public:
1734 bool operator()(const IncomingLaneInfo& ili) const {
1735 return &(ili.lane->getEdge()) == myEdge;
1736 }
1737 private:
1738 const MSEdge* const myEdge;
1739 };
1740
1741#ifdef HAVE_FOX
1743 typedef void(MSLane::*Operation)(const SUMOTime);
1744
1749 class SimulationTask : public MFXWorkerThread::Task {
1750 public:
1751 SimulationTask(MSLane& l, const SUMOTime time)
1752 : myLane(l), myTime(time) {}
1753 void init(Operation operation, const SUMOTime time) {
1754 myOperation = operation;
1755 myTime = time;
1756 }
1757 void run(MFXWorkerThread* /*context*/) {
1758 try {
1759 (myLane.*(myOperation))(myTime);
1760 } catch (ProcessError& e) {
1761 WRITE_ERROR(e.what());
1762 }
1763 }
1764 private:
1765 Operation myOperation = nullptr;
1766 MSLane& myLane;
1767 SUMOTime myTime;
1768 private:
1770 SimulationTask& operator=(const SimulationTask&) = delete;
1771 };
1772
1773 SimulationTask mySimulationTask;
1775 mutable FXMutex myLeaderInfoMutex;
1777 mutable FXMutex myFollowerInfoMutex;
1779 mutable FXMutex myPartialOccupatorMutex;
1780#endif
1781 std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
1782
1783private:
1785 MSLane(const MSLane&) = delete;
1786
1788 MSLane& operator=(const MSLane&) = delete;
1789
1790
1791};
1792
1793// specialized implementation for speedup and avoiding warnings
1794#define LANE_RTREE_QUAL RTree<MSLane*, MSLane, float, 2, MSLane::StoringVisitor>
1795
1796template<>
1797inline float LANE_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
1798 ASSERT(a_rect);
1799 const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
1800 const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
1801 return .78539816f * (extent0 * extent0 + extent1 * extent1);
1802}
1803
1804template<>
1805inline LANE_RTREE_QUAL::Rect LANE_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
1806 ASSERT(a_rectA && a_rectB);
1807 Rect newRect;
1808 newRect.m_min[0] = rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
1809 newRect.m_max[0] = rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
1810 newRect.m_min[1] = rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
1811 newRect.m_max[1] = rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
1812 return newRect;
1813}
long long int SUMOTime
Definition GUI.h:36
std::map< const MSLane *, std::pair< double, double > > LaneCoverageInfo
Coverage info.
Definition MSLane.h:72
#define WRITE_ERROR(msg)
Definition MsgHandler.h:296
#define rtree_min(a, b)
Definition RTree.h:20
#define rtree_max(a, b)
Definition RTree.h:21
#define ASSERT
Definition RTree.h:12
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
InsertionCheck
different checking levels for vehicle insertion
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
T MIN2(T a, T b)
Definition StdDefs.h:76
size_t size() const
Abstract superclass of a task to be run with an index to keep track of pending tasks.
A thread repeatingly calculating incoming tasks.
The base class for microscopic and mesoscopic vehicles.
A road/street connecting two junctions.
Definition MSEdge.h:77
static int gNumSimThreads
how many threads to use for simulation
Definition MSGlobals.h:146
The base class for an intersection.
Definition MSJunction.h:58
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
Definition MSLane.h:129
bool operator!=(AnyVehicleIterator const &other) const
Definition MSLane.h:160
int myI2End
end index for myPartialVehicles
Definition MSLane.h:186
int myI2
index for myPartialVehicles
Definition MSLane.h:180
bool myDownstream
iteration direction
Definition MSLane.h:190
const MSVehicle * operator->()
Definition MSLane.h:164
bool nextIsMyVehicles() const
Definition MSLane.cpp:204
int myI3
index for myTmpVehicles
Definition MSLane.h:182
int myDirection
index delta
Definition MSLane.h:192
AnyVehicleIterator & operator++()
Definition MSLane.cpp:170
const MSLane * myLane
the lane that is being iterated
Definition MSLane.h:176
bool operator==(AnyVehicleIterator const &other) const
Definition MSLane.h:151
const MSVehicle * operator*()
Definition MSLane.cpp:187
int myI3End
end index for myTmpVehicles
Definition MSLane.h:188
AnyVehicleIterator(const MSLane *lane, int i1, int i2, int i3, const int i1End, const int i2End, const int i3End, bool downstream=true)
Definition MSLane.h:131
int myI1End
end index for myVehicles
Definition MSLane.h:184
int myI1
index for myVehicles
Definition MSLane.h:178
StoringVisitor(const StoringVisitor &src)
invalidated copy constructor
void add(const MSLane *const l) const
Adds the given object to the container.
Definition MSLane.cpp:123
StoringVisitor(std::set< const Named * > &objects, const PositionVector &shape, const double range, const int domain)
Constructor.
Definition MSLane.h:89
StoringVisitor & operator=(const StoringVisitor &src)
invalidated assignment operator
std::set< const Named * > & myObjects
The container.
Definition MSLane.h:98
const double myRange
Definition MSLane.h:100
const PositionVector & myShape
Definition MSLane.h:99
Sorts edges by their angle relative to the given edge (straight comes first)
Definition MSLane.h:1679
const MSEdge *const myEdge
Definition MSLane.h:1688
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition MSLane.cpp:3506
bool operator()(const IncomingLaneInfo &ili) const
Definition MSLane.h:1734
edge_finder(MSEdge *e)
Definition MSLane.h:1733
const MSEdge *const myEdge
Definition MSLane.h:1738
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
Definition MSLane.h:1698
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Definition MSLane.cpp:3545
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
Definition MSLane.h:1716
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Definition MSLane.cpp:3622
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition MSLane.h:1659
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition MSLane.cpp:3488
Sorts vehicles by their position (descending)
Definition MSLane.h:1633
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition MSLane.cpp:3476
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition MSLane.h:1636
Performs lane changing of vehicles.
Performs lane changing of vehicles.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
std::vector< StopWatch< std::chrono::nanoseconds > > & getStopWatch()
Definition MSLane.h:1286
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition MSLane.cpp:2840
void loadState(const std::vector< SUMOVehicle * > &vehs)
Loads the state of this segment with the given parameters.
Definition MSLane.cpp:3737
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
detect whether there is a collision between the two vehicles
Definition MSLane.cpp:1913
static SUMOTime myIntermodalCollisionStopTime
Definition MSLane.h:1625
MFXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition MSLane.h:1481
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition MSLane.h:1522
MSLane * myLogicalPredecessorLane
Definition MSLane.h:1538
static void initCollisionAction(const OptionsCont &oc, const std::string &option, CollisionAction &myAction)
Definition MSLane.cpp:4461
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition MSLane.h:323
std::set< const MSBaseVehicle * > myParkingVehicles
Definition MSLane.h:1494
bool checkForPedestrians(const MSVehicle *aVehicle, double &speed, double &dist, double pos, bool patchSpeed) const
check whether pedestrians on this lane interfere with vehicle insertion
Definition MSLane.cpp:4548
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
Definition MSLane.cpp:4368
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0, bool bidi=false) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
Definition MSLane.cpp:4542
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition MSLane.cpp:2824
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition MSLane.h:1588
const StopOffset & getLaneStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition MSLane.cpp:3765
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition MSLane.cpp:3663
virtual ~MSLane()
Destructor.
Definition MSLane.cpp:305
static CollisionAction getIntermodalCollisionAction()
Definition MSLane.h:1361
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition MSLane.cpp:682
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:1475
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition MSLane.cpp:2540
double myLength
Lane length [m].
Definition MSLane.h:1497
bool isApproachedFrom(MSEdge *const edge)
Definition MSLane.h:956
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition MSLane.cpp:3385
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition MSLane.cpp:2806
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
Definition MSLane.cpp:3340
PositionVector myShape
The shape of the lane.
Definition MSLane.h:1442
PositionVector * myOutlineShape
the outline of the lane (optional)
Definition MSLane.h:1445
std::map< long long, SVCPermissions > myPermissionChanges
Definition MSLane.h:1602
int getRNGIndex() const
returns the associated RNG index
Definition MSLane.h:241
double getFrictionCoefficient() const
Returns the lane's friction coefficient.
Definition MSLane.h:599
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition MSLane.h:1532
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:455
void initRestrictions()
initialized vClass-specific speed limits
Definition MSLane.cpp:314
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition MSLane.h:1617
MSLane & operator=(const MSLane &)=delete
invalidated assignment operator
bool hasApproaching() const
Definition MSLane.cpp:3668
SVCPermissions getChangeRight() const
Returns the vehicle class permissions for changing to the right neighbour lane.
Definition MSLane.h:628
void addParking(MSBaseVehicle *veh)
add parking vehicle. This should only used during state loading
Definition MSLane.cpp:3657
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition MSLane.h:1477
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition MSLane.cpp:605
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition MSLane.h:1571
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
Definition MSLane.cpp:3225
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition MSLane.h:456
static SUMOTime myCollisionStopTime
Definition MSLane.h:1624
static CollisionAction myCollisionAction
the action to take on collisions
Definition MSLane.h:1620
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition MSLane.h:1544
SVCPermissions myChangeLeft
The vClass permissions for changing from this lane.
Definition MSLane.h:1525
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane * > &bestLaneConts, MSLeaderDistanceInfo &result, bool oppositeDirection=false) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
Definition MSLane.cpp:4005
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition MSLane.h:1535
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
Definition MSLane.h:495
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition MSLane.cpp:2495
bool hadPermissionChanges() const
Definition MSLane.cpp:4517
void sortPartialVehicles()
sorts myPartialVehicles
Definition MSLane.cpp:2567
double myFrictionCoefficient
Lane-wide friction coefficient [0..1].
Definition MSLane.h:1513
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition MSLane.cpp:2654
MSLane(const MSLane &)=delete
invalidated copy constructor
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
Definition MSLane.cpp:2742
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition MSLane.h:464
static bool myCheckJunctionCollisions
Definition MSLane.h:1622
static void clear()
Clears the dictionary.
Definition MSLane.cpp:2486
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition MSLane.h:1159
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition MSLane.cpp:437
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition MSLane.h:1529
MSEdge *const myEdge
The lane's edge, for routing only.
Definition MSLane.h:1508
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition MSLane.h:1550
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition MSLane.h:739
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:937
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition MSLane.cpp:2668
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport)
detect whether a vehicle collids with pedestrians on the junction
Definition MSLane.cpp:1872
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:2865
double myMaxSpeed
Lane-wide speed limit [m/s].
Definition MSLane.h:1511
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition MSLane.cpp:3678
void markRecalculateBruttoSum()
Set a flag to recalculate the brutto (including minGaps) occupancy of this lane (used if mingap is ch...
Definition MSLane.cpp:2407
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition MSLane.cpp:2719
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition MSLane.h:1590
void setChangeRight(SVCPermissions permissions)
Sets the permissions for changing to the right neighbour lane.
Definition MSLane.cpp:4529
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition MSLane.h:1582
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:1530
virtual double getLengthGeometryFactor(bool) const
Definition MSLane.h:290
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition MSLane.cpp:4628
void visit(const MSLane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition MSLane.h:1334
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition MSLane.h:1576
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition MSLane.h:1569
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:841
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition MSLane.cpp:1366
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition MSLane.cpp:3752
static void initCollisionOptions(const OptionsCont &oc)
Definition MSLane.cpp:4477
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition MSLane.h:1439
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition MSLane.h:543
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition MSLane.h:1461
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition MSLane.h:592
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition MSLane.cpp:4205
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition MSLane.h:119
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const
Definition MSLane.cpp:809
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition MSLane.h:1611
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition MSLane.cpp:2503
double safeInsertionSpeed(const MSVehicle *veh, double seen, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition MSLane.cpp:1377
MSLane * myBidiLane
Definition MSLane.h:1599
std::vector< const MSJunction * > getUpcomingJunctions(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming junctions within given range along the given (non-internal) continuation lanes m...
Definition MSLane.cpp:4292
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition MSLane.cpp:2830
bool isWalkingArea() const
Definition MSLane.cpp:2611
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition MSLane.cpp:2439
SVCPermissions getChangeLeft() const
Returns the vehicle class permissions for changing to the left neighbour lane.
Definition MSLane.h:621
void addLink(MSLink *link)
Delayed initialization.
Definition MSLane.cpp:333
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
Definition MSLane.cpp:4272
void enteredByLaneChange(MSVehicle *v)
Definition MSLane.cpp:3333
double getDepartPosLat(const MSVehicle &veh)
Definition MSLane.cpp:656
const std::string & getLaneType() const
return the type of this lane
Definition MSLane.h:548
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode=MinorLinkMode::FOLLOW_NEVER) const
Definition MSLane.cpp:4391
int getThreadIndex() const
returns the associated thread index
Definition MSLane.h:236
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition MSLane.h:614
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition MSLane.cpp:3291
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition MSLane.cpp:2413
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition MSLane.h:950
static const long CHANGE_PERMISSIONS_PERMANENT
Definition MSLane.h:1365
virtual void addMoveReminder(MSMoveReminder *rem, bool addToVehicles=true)
Add a move-reminder to move-reminder container.
Definition MSLane.cpp:360
MSLane * getCanonicalPredecessorLane() const
Definition MSLane.cpp:3246
void resetPermissions(long long transientID)
Definition MSLane.cpp:4502
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition MSLane.cpp:2617
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition MSLane.cpp:4638
const std::string myLaneType
the type of this lane
Definition MSLane.h:1585
int myRNGIndex
Definition MSLane.h:1605
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
Definition MSLane.h:1489
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition MSLane.cpp:4116
bool needsCollisionCheck() const
short-circut collision check if nothing changed since the last check
Definition MSLane.h:705
static double myCheckJunctionCollisionMinGap
Definition MSLane.h:1623
double getLength() const
Returns the lane's length.
Definition MSLane.h:606
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition MSLane.h:1547
const PositionVector & getShape() const
Returns this lane's shape.
Definition MSLane.h:533
static bool isFrontalCollision(const MSVehicle *collider, const MSVehicle *victim)
detect frontal collisions
Definition MSLane.cpp:2234
void setChangeLeft(SVCPermissions permissions)
Sets the permissions for changing to the left neighbour lane.
Definition MSLane.cpp:4523
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
Definition MSLane.cpp:4303
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:2445
static int getNumRNGs()
return the number of RNGs
Definition MSLane.h:251
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
Definition MSLane.cpp:2020
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition MSLane.cpp:2881
static CollisionAction myIntermodalCollisionAction
Definition MSLane.h:1621
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
Definition MSLane.cpp:2731
bool isLinkEnd(std::vector< MSLink * >::iterator &i)
Definition MSLane.h:859
static std::vector< SumoRNG > myRNGs
Definition MSLane.h:1613
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:932
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition MSLane.cpp:2789
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:3106
StopOffset myLaneStopOffset
Definition MSLane.h:1505
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:1419
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition MSLane.cpp:4615
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts, bool considerCrossingFoes=true) const
Returns the immediate leader and the distance to him.
Definition MSLane.cpp:2965
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the road network starting on the given position...
Definition MSLane.cpp:4220
bool myRecalculateBruttoSum
Flag to recalculate the occupancy (including minGaps) after a change in minGap.
Definition MSLane.h:1559
virtual void removeMoveReminder(MSMoveReminder *rem)
Remove a move-reminder from move-reminder container.
Definition MSLane.cpp:372
void clearState()
Remove all vehicles before quick-loading state.
Definition MSLane.cpp:3720
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition MSLane.h:1541
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition MSLane.h:1593
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition MSLane.h:853
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition MSLane.h:925
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition MSLane.cpp:384
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:574
void setBidiLane(MSLane *bidyLane)
Adds the (overlapping) reverse direction lane to this lane.
Definition MSLane.cpp:347
double getRightSideOnEdge() const
Definition MSLane.h:1195
void checkBufferType()
Definition MSLane.cpp:321
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition MSLane.cpp:4419
bool mySpeedByTraCI
Whether the current speed limit has been set through TraCI.
Definition MSLane.h:1519
bool hasPedestrians() const
whether the lane has pedestrians on it
Definition MSLane.cpp:4535
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition MSLane.cpp:3302
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition MSLane.cpp:4182
int getIndex() const
Returns the lane's index.
Definition MSLane.h:642
void setLaneStopOffset(const StopOffset &stopOffset)
Set vehicle class specific stopOffsets.
Definition MSLane.cpp:3771
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition MSLane.h:1553
void leftByLaneChange(MSVehicle *v)
Definition MSLane.cpp:3326
MSLane * getCanonicalSuccessorLane() const
Definition MSLane.cpp:3270
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition MSLane.h:710
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
Definition MSLane.h:1781
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition MSLane.cpp:4490
const double myWidth
Lane width [m].
Definition MSLane.h:1500
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:480
virtual void addSecondaryShape(const PositionVector &)
Definition MSLane.h:288
void changeLanes(const SUMOTime time)
Definition MSLane.cpp:2433
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition MSLane.cpp:4363
SVCPermissions myChangeRight
Definition MSLane.h:1526
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition MSLane.h:1579
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition MSLane.cpp:2253
const std::set< const MSBaseVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition MSLane.h:1254
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition MSLane.cpp:3190
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition MSLane.cpp:3370
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
Definition MSLane.h:507
int myIndex
The lane index.
Definition MSLane.h:1448
double getCenterOnEdge() const
Definition MSLane.h:1203
bool isNormal() const
Definition MSLane.cpp:2600
bool isCrossing() const
Definition MSLane.cpp:2606
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
Definition MSLane.cpp:3434
void updateLeaderInfo(const MSVehicle *veh, VehCont::reverse_iterator &vehPart, VehCont::reverse_iterator &vehRes, MSLeaderInfo &ahead) const
This updates the MSLeaderInfo argument with respect to the given MSVehicle. All leader-vehicles on th...
Definition MSLane.cpp:1578
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition MSLane.cpp:3400
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition MSLane.cpp:2463
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition MSLane.h:1259
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition MSLane.cpp:1631
std::vector< MSLink * > myLinks
Definition MSLane.h:1563
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition MSLane.cpp:2635
bool isInternal() const
Definition MSLane.cpp:2594
static const long CHANGE_PERMISSIONS_GUI
Definition MSLane.h:1366
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition MSLane.h:1473
void sortManeuverReservations()
sorts myManeuverReservations
Definition MSLane.cpp:2575
MinorLinkMode
determine whether/how getFollowers looks upstream beyond minor links
Definition MSLane.h:973
@ FOLLOW_ONCOMING
Definition MSLane.h:976
@ FOLLOW_ALWAYS
Definition MSLane.h:975
@ FOLLOW_NEVER
Definition MSLane.h:974
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible)
Definition MSLane.h:472
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition MSLane.h:566
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
Definition MSLane.h:501
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition MSLane.cpp:3312
bool mySpeedByVSS
Whether the current speed limit is set by a variable speed sign (VSS)
Definition MSLane.h:1516
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition MSLane.cpp:403
SumoRNG * getRNG() const
return the associated RNG
Definition MSLane.h:246
void setOpposite(MSLane *oppositeLane)
Adds a neighbor to this lane.
Definition MSLane.cpp:339
static int dictSize()
Returns the number of stored lanes.
Definition MSLane.h:815
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
Definition MSLane.h:489
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition MSLane.cpp:3459
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:2893
void handleIntermodalCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSTransportable *victim, double gap, const std::string &collisionType, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
Definition MSLane.cpp:2157
static bool myExtrapolateSubstepDepart
Definition MSLane.h:1627
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
Definition MSLane.cpp:4351
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition MSLane.cpp:2782
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition MSLane.h:1566
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition MSLane.h:483
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition MSLane.h:513
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition MSLane.cpp:4653
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:554
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition MSLane.cpp:426
virtual void setJunctionApproaches() const
Register junction approaches for all vehicles after velocities have been planned.
Definition MSLane.cpp:1570
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition MSLane.cpp:4647
static double myCollisionMinGapFactor
Definition MSLane.h:1626
bool isEmpty() const
Definition MSLane.h:865
bool hasApproaching(const std::vector< MSLink * > &links) const
check whether any of the outgoing links are being approached
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition MSLane.h:538
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition MSLane.h:1574
MSLane * myOpposite
Definition MSLane.h:1596
CollisionAction
Definition MSLane.h:201
@ COLLISION_ACTION_NONE
Definition MSLane.h:202
@ COLLISION_ACTION_WARN
Definition MSLane.h:203
@ COLLISION_ACTION_TELEPORT
Definition MSLane.h:204
@ COLLISION_ACTION_REMOVE
Definition MSLane.h:205
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
Definition MSLane.cpp:4357
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition MSLane.h:1608
double getFractionalVehicleLength(bool brutto) const
return length of fractional vehicles on this lane
Definition MSLane.cpp:3351
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:764
const PositionVector * getOutlineShape() const
Definition MSLane.h:1350
double getSpaceTillLastStanding(const MSVehicle *ego, bool &foundStopped) const
return the empty space up to the last standing vehicle or the empty space on the whole lane if no veh...
Definition MSLane.cpp:4662
double getEmissions() const
Returns the sum of last step emissions The value is always per 1s, so multiply by step length if nece...
Definition MSLane.h:1169
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
Definition MSLane.cpp:3215
int getNumericalID() const
Returns this lane's numerical id.
Definition MSLane.h:525
void setRightSideOnEdge(double value, int rightmostSublane)
Definition MSLane.h:1185
virtual bool appropriate(const MSVehicle *veh) const
Definition MSLane.cpp:2519
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition MSLane.cpp:3777
double getWidth() const
Returns the lane's width.
Definition MSLane.h:635
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition MSLane.h:724
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:515
void setMaxSpeed(double val, bool byVSS=false, bool byTraCI=false, double jamThreshold=-1)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition MSLane.cpp:2759
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition MSLane.cpp:2626
int getRightmostSublane() const
Definition MSLane.h:1199
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition MSLane.cpp:3413
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition MSLane.h:1556
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
void setFrictionCoefficient(double val)
Sets a new friction coefficient for the lane [to be later (used by TraCI and MSCalibrator)].
Definition MSLane.cpp:2775
static CollisionAction getCollisionAction()
Definition MSLane.h:1357
saves leader/follower vehicles and their distances relative to an ego vehicle
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Export the queueing length in front of a junction (very experimental!)
The class responsible for building and deletion of vehicles.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
Base class for objects which have an id.
Definition Named.h:54
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a vehicle, person, or container.
virtual double getChosenSpeedFactor() const =0
virtual double getMaxSpeed() const =0
Returns the object's maximum speed (minimum of technical and desired maximum speed)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
Representation of a vehicle.
Definition SUMOVehicle.h:62
stop offset