Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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 virtual void updateMesoGUISegments() {}
300
303
310 virtual void addMoveReminder(MSMoveReminder* rem, bool addToVehicles = true);
311
312
318 virtual void removeMoveReminder(MSMoveReminder* rem);
319
320
324 inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
325 return myMoveReminders;
326 }
328
329
330
333
349 bool insertVehicle(MSVehicle& v);
350
351
370 bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
371 bool recheckNextLanes,
372 MSMoveReminder::Notification notification);
373
374 // XXX: Documentation?
375 bool checkFailure(const MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const;
376
380 bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
381
389 bool freeInsertion(MSVehicle& veh, double speed, double posLat,
391
392
402 void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
404
405
406
410
417 virtual double setPartialOccupation(MSVehicle* v);
418
422 virtual void resetPartialOccupation(MSVehicle* v);
423
426 virtual void setManeuverReservation(MSVehicle* v);
427
431 virtual void resetManeuverReservation(MSVehicle* v);
432
443 const MSLeaderInfo getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true, const MSVehicle* ignore = nullptr) const;
444
446 const MSLeaderInfo getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
447
449
452
457 int getVehicleNumber() const {
458 return (int)myVehicles.size();
459 }
460
466 return (int)myVehicles.size() + (int)myPartialVehicles.size();
467 }
468
474 return (int)myPartialVehicles.size();
475 }
476
477
484 virtual const VehCont& getVehiclesSecure() const {
485 return myVehicles;
486 }
487
488
491 return AnyVehicleIterator(this, 0, 0, 0,
492 (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
493 }
494
497 return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(),
498 (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
499 }
500
503 return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, (int)myTmpVehicles.size() - 1,
504 -1, -1, -1, false);
505 }
506
509 return AnyVehicleIterator(this, -1, -1, -1, -1, -1, -1, false);
510 }
511
514 virtual void releaseVehicles() const { }
516
517
518
521
522
526 inline int getNumericalID() const {
527 return myNumericalID;
528 }
529
530
534 inline const PositionVector& getShape() const {
535 return myShape;
536 }
537
539 inline double getLengthGeometryFactor() const {
541 }
542
544 inline bool isAccelLane() const {
545 return myIsRampAccel;
546 }
547
549 const std::string& getLaneType() const {
550 return myLaneType;
551 }
552
553 /* @brief fit the given lane position to a visibly suitable geometry position
554 * (lane length might differ from geometry length) */
555 inline double interpolateLanePosToGeometryPos(double lanePos) const {
556 return lanePos * myLengthGeometryFactor;
557 }
558
559 /* @brief fit the given lane position to a visibly suitable geometry position
560 * and return the coordinates */
561 inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
562 return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
563 }
564
565 /* @brief fit the given geometry position to a valid lane position
566 * (lane length might differ from geometry length) */
567 inline double interpolateGeometryPosToLanePos(double geometryPos) const {
568 return geometryPos / myLengthGeometryFactor;
569 }
570
575 inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh) const {
576 return getVehicleMaxSpeed(veh, veh->getMaxSpeed());
577 }
578
579
580 inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh, double vehMaxSpeed) const {
581 if (myRestrictions != nullptr) {
582 std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
583 if (r != myRestrictions->end()) {
584 if (mySpeedModified) {
585 return MIN2(myMaxSpeed, MIN2(vehMaxSpeed, r->second * veh->getChosenSpeedFactor()));
586 } else {
587 return MIN2(vehMaxSpeed, r->second * veh->getChosenSpeedFactor());
588 }
589 }
590 }
591 return MIN2(vehMaxSpeed, myMaxSpeed * veh->getChosenSpeedFactor());
592 }
593
594 inline bool isSpeedModified() const {
595 return mySpeedModified;
596 }
597
598
602 inline double getSpeedLimit() const {
603 return myMaxSpeed;
604 }
605
606
607 inline double getSpeedLimit(SUMOVehicleClass svc) const {
608 if (myRestrictions != nullptr) {
609 std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(svc);
610 if (r != myRestrictions->end()) {
611 if (mySpeedModified) {
612 return MIN2(myMaxSpeed, r->second);
613 } else {
614 return r->second;
615 }
616 }
617 }
618 return myMaxSpeed;
619 }
620
621
625 inline double getFrictionCoefficient() const {
627 }
628
632 inline double getLength() const {
633 return myLength;
634 }
635
636
641 return myPermissions;
642 }
643
648 return myChangeLeft;
649 }
650
655 return myChangeRight;
656 }
657
661 double getWidth() const {
662 return myWidth;
663 }
664
668 int getIndex() const {
669 return myIndex;
670 }
672
674 int getCrossingIndex() const;
675
676
679
687 virtual void planMovements(const SUMOTime t);
688
694 virtual void setJunctionApproaches() const;
695
704 void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
705
716 virtual void executeMovements(const SUMOTime t);
717
719 virtual void integrateNewVehicles();
720
724
726 void updateLengthSum();
728
729
731 inline bool needsCollisionCheck() const {
733 }
734
736 inline void requireCollisionCheck() {
738 }
739
741 virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
742
743
746 virtual bool appropriate(const MSVehicle* veh) const;
747
748
750 const std::vector<MSLink*>& getLinkCont() const {
751 return myLinks;
752 }
753
755 const MSLink* getLinkTo(const MSLane* const) const;
756
758 const MSLane* getInternalFollowingLane(const MSLane* const) const;
759
761 const MSLink* getEntryLink() const;
762
763
765 bool empty() const {
766 assert(myVehBuffer.size() == 0);
767 return myVehicles.empty();
768 }
769
775 void setMaxSpeed(const double val, const bool modified = true, const double jamThreshold = -1);
776
780 void setFrictionCoefficient(double val);
781
785 void setLength(double val);
786
790 MSEdge& getEdge() const {
791 return *myEdge;
792 }
793
794 const MSJunction* getFromJunction() const;
795 const MSJunction* getToJunction() const;
796
800 const MSEdge* getNextNormal() const;
801
802
808 const MSLane* getFirstInternalInConnection(double& offset) const;
809
810
813
824 static bool dictionary(const std::string& id, MSLane* lane);
825
826
833 static MSLane* dictionary(const std::string& id);
834
835
837 static void clear();
838
839
843 static int dictSize() {
844 return (int)myDict.size();
845 }
846
847
851 static void insertIDs(std::vector<std::string>& into);
852
853
858 template<class RTREE>
859 static void fill(RTREE& into);
860
861
863 static void initRNGs(const OptionsCont& oc);
865
866
867
868 // XXX: succLink does not exist... Documentation?
873 static std::vector<MSLink*>::const_iterator succLinkSec(const SUMOVehicle& veh,
874 int nRouteSuccs,
875 const MSLane& succLinkSource,
876 const std::vector<MSLane*>& conts);
877
878
881 inline bool isLinkEnd(std::vector<MSLink*>::const_iterator& i) const {
882 return i == myLinks.end();
883 }
884
887 inline bool isLinkEnd(std::vector<MSLink*>::iterator& i) {
888 return i == myLinks.end();
889 }
890
893 inline bool isEmpty() const {
894 return myVehicles.empty() && myPartialVehicles.empty();
895 }
896
898 bool isInternal() const;
899
901 bool isNormal() const;
902
904 bool isCrossing() const;
905
907 bool isPriorityCrossing() const;
908
910 bool isWalkingArea() const;
911
914
917
920
923
924 /* @brief remove the vehicle from this lane
925 * @param[notify] whether moveReminders of the vehicle shall be triggered
926 */
927 virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
928
931
935 MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
936
937
942 void setPermissions(SVCPermissions permissions, long long transientID);
943 void resetPermissions(long long transientID);
944 bool hadPermissionChanges() const;
945
948
952 void setChangeLeft(SVCPermissions permissions);
953
957 void setChangeRight(SVCPermissions permissions);
958
959 inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
960 return (myPermissions & vclass) == vclass;
961 }
962
963 bool allowsVehicleClass(SUMOVehicleClass vclass, int routingMode) const;
964
966 inline bool allowsChangingLeft(SUMOVehicleClass vclass) const {
967 return (myChangeLeft & vclass) == vclass;
968 }
969
971 inline bool allowsChangingRight(SUMOVehicleClass vclass) const {
972 return (myChangeRight & vclass) == vclass;
973 }
974
975 void addIncomingLane(MSLane* lane, MSLink* viaLink);
976
977
983
984 const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
985 return myIncomingLanes;
986 }
987
988
989 void addApproachingLane(MSLane* lane, bool warnMultiCon);
990 inline bool isApproachedFrom(MSEdge* const edge) {
991 return myApproachingLanes.find(edge) != myApproachingLanes.end();
992 }
993 bool isApproachedFrom(MSLane* const lane, SUMOVehicleClass svc);
994
996 double getVehicleStopOffset(const MSVehicle* veh) const;
997
999 const StopOffset& getLaneStopOffsets() const;
1000
1002 void setLaneStopOffset(const StopOffset& stopOffset);
1003
1012
1014 MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
1015 bool allSublanes, double searchDist = -1, MinorLinkMode mLinkMode = FOLLOW_ALWAYS, bool maxSearchDist = false) const;
1016
1018 double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
1019
1032 std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
1033
1057 std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
1058 double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts, bool considerCrossingFoes = true) const;
1059
1061 void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
1062 const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result, bool oppositeDirection = false) const;
1063
1064
1066 void addLeaders(const MSVehicle* vehicle, double vehPos, MSLeaderDistanceInfo& result, bool oppositeDirection = false);
1067
1068
1086 std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
1087
1088 /* @brief return the partial vehicle closest behind ego or 0
1089 * if no such vehicle exists */
1090 MSVehicle* getPartialBehind(const MSVehicle* ego) const;
1091
1094
1105 std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
1106
1109 std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
1110
1112 std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1113
1115 std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1116
1121
1125 const MSLane* getNormalPredecessorLane() const;
1126
1130 const MSLane* getNormalSuccessorLane() const;
1131
1134 MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
1135
1136
1143
1144
1151
1154
1156 const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
1157
1159 std::vector<const MSLane*> getNormalIncomingLanes() const;
1160
1162
1163
1167 double getMeanSpeed() const;
1168
1170 double getMeanSpeedBike() const;
1171
1175 double getWaitingSeconds() const;
1176
1177
1181 double getBruttoOccupancy() const;
1182
1183
1187 double getNettoOccupancy() const;
1188
1189
1193 inline double getBruttoVehLenSum() const {
1195 }
1196
1197
1202 template<PollutantsInterface::EmissionType ET>
1203 double getEmissions() const {
1204 double ret = 0;
1205 for (MSVehicle* const v : getVehiclesSecure()) {
1206 ret += v->getEmissions<ET>();
1207 }
1209 return ret;
1210 }
1211
1212
1216 double getHarmonoise_NoiseEmissions() const;
1218
1219 void setRightSideOnEdge(double value, int rightmostSublane) {
1220 myRightSideOnEdge = value;
1221 myRightmostSublane = rightmostSublane;
1222 }
1223
1225 void initRestrictions();
1226
1227 void checkBufferType();
1228
1229 double getRightSideOnEdge() const {
1230 return myRightSideOnEdge;
1231 }
1232
1234 return myRightmostSublane;
1235 }
1236
1237 double getCenterOnEdge() const {
1238 return myRightSideOnEdge + 0.5 * myWidth;
1239 }
1240
1242 void sortPartialVehicles();
1243
1246
1248 MSLane* getOpposite() const;
1249
1251 MSLane* getParallelOpposite() const;
1252
1254 double getOppositePos(double pos) const;
1255
1256 /* @brief find leader for a vehicle depending on the relative driving direction
1257 * @param[in] ego The ego vehicle
1258 * @param[in] dist The look-ahead distance when looking at consecutive lanes
1259 * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1260 * @return the leader vehicle and its gap to ego
1261 */
1262 std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode = MinorLinkMode::FOLLOW_NEVER) const;
1263
1264 /* @brief find follower for a vehicle that is located on the opposite of this lane
1265 * @param[in] ego The ego vehicle
1266 * @return the follower vehicle and its gap to ego
1267 */
1268 std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1269
1270
1278 std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, MinorLinkMode mLinkMode, bool maxSearchDist = false) const;
1279
1280
1282 void addParking(MSBaseVehicle* veh);
1283
1285 virtual void removeParking(MSBaseVehicle* veh);
1286
1288 const std::set<const MSBaseVehicle*>& getParkingVehicles() const {
1289 return myParkingVehicles;
1290 }
1291
1293 virtual bool isSelected() const {
1294 return false;
1295 }
1296
1298 MSLane* getBidiLane() const;
1299
1301 bool mustCheckJunctionCollisions() const;
1302
1303#ifdef HAVE_FOX
1304 MFXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1305 mySimulationTask.init(&MSLane::planMovements, time);
1306 return &mySimulationTask;
1307 }
1308
1309 MFXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1310 mySimulationTask.init(&MSLane::executeMovements, time);
1311 return &mySimulationTask;
1312 }
1313
1314 MFXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1315 mySimulationTask.init(&MSLane::changeLanes, time);
1316 return &mySimulationTask;
1317 }
1318
1319 MFXWorkerThread::Task* getJunctionApproachTask(const SUMOTime time) {
1320 mySimulationTask.init(&MSLane::setJunctionApproachesTask, time);
1321 return &mySimulationTask;
1322 }
1323
1325 void setJunctionApproachesTask(const SUMOTime /* t */) {
1327 }
1328#endif
1329
1330 std::vector<StopWatch<std::chrono::nanoseconds> >& getStopWatch() {
1331 return myStopWatch;
1332 }
1333
1334 void changeLanes(const SUMOTime time);
1335
1338
1346 void saveState(OutputDevice& out);
1347
1349 void clearState();
1350
1361 void loadState(const std::vector<SUMOVehicle*>& vehs);
1362
1363
1364 /* @brief helper function for state saving: checks whether any outgoing
1365 * links are being approached */
1366 bool hasApproaching() const;
1367
1369
1370
1378 void visit(const MSLane::StoringVisitor& cont) const {
1379 cont.add(this);
1380 }
1381
1383 bool hasPedestrians() const;
1384
1386 std::pair<const MSPerson*, double> nextBlocking(double minPos, double minRight, double maxLeft, double stopTime = 0, bool bidi = false) const;
1387
1389 double getSpaceTillLastStanding(const MSVehicle* ego, bool& foundStopped) const;
1390
1392 double getMaximumBrakeDist() const;
1393
1394 inline const PositionVector* getOutlineShape() const {
1395 return myOutlineShape;
1396 }
1397
1398 static void initCollisionOptions(const OptionsCont& oc);
1399 static void initCollisionAction(const OptionsCont& oc, const std::string& option, CollisionAction& myAction);
1400
1404
1408
1412
1413 static double& getDefaultDepartSpeed() {
1414 return myDefaultDepartSpeed;
1415 }
1416
1417
1418 static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1419 static const long CHANGE_PERMISSIONS_GUI = 1;
1420
1421protected:
1423 virtual void swapAfterLaneChange(SUMOTime t);
1424
1436 virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1437 const MSLane::VehCont::iterator& at,
1439
1441 void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1442 SUMOTime timestep, const std::string& stage,
1443 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1444 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport);
1445
1447 bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1448 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1449 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1450
1452 void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1453 double gap, double latGap,
1454 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1455 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1456
1457 void handleIntermodalCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSTransportable* victim,
1458 double gap, const std::string& collisionType,
1459 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1460 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1461
1462 /* @brief determine depart speed and whether it may be patched
1463 * @param[in] veh The departing vehicle
1464 * @param[out] whether the speed may be patched to account for safety
1465 * @return the depart speed
1466 */
1467 double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1468
1469 /* @brief determine the lateral depart position
1470 * @param[in] veh The departing vehicle
1471 * @return the lateral depart position
1472 */
1473 double getDepartPosLat(const MSVehicle& veh);
1474
1477 double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1478
1480 bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1481
1483 bool hasApproaching(const std::vector<MSLink*>& links) const;
1484
1486 double getFractionalVehicleLength(bool brutto) const;
1487
1489 bool mayContinue(const MSVehicle* veh) const;
1490
1492 bool hasUnsafeLink() const;
1493
1495 static bool isFrontalCollision(const MSVehicle* collider, const MSVehicle* victim);
1496
1499
1502
1505
1508
1521
1533
1537
1541
1549
1550 /* @brief list of vehicles that are parking near this lane
1551 * (not necessarily on the road but having reached their stop on this lane)
1552 * */
1553 std::set<const MSBaseVehicle*> myParkingVehicles;
1554
1556 double myLength;
1557
1559 const double myWidth;
1560
1565
1568
1573
1576
1579
1583
1586
1588 const std::map<SUMOVehicleClass, double>* myRestrictions;
1589
1591 std::vector<IncomingLaneInfo> myIncomingLanes;
1592
1595
1598
1601
1604
1607
1610
1613
1616
1619 std::vector<MSLink*> myLinks;
1620
1622 std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1623
1628
1633
1636
1638 const bool myIsRampAccel;
1639
1641 const std::string myLaneType;
1642
1647
1650
1651 // @brief the neighboring opposite direction or nullptr
1653
1654 // @brief bidi lane or nullptr
1656
1657 // @brief transient changes in permissions
1658 std::map<long long, SVCPermissions> myPermissionChanges;
1659
1660 // @brief index of the associated thread-rng
1662
1664 typedef std::map< std::string, MSLane* > DictType;
1665
1666#ifdef HAVE_FOX
1668 mutable FXMutex myPartialOccupatorMutex;
1669#endif
1670
1673
1674 static std::vector<SumoRNG> myRNGs;
1675
1676private:
1678 std::vector< MSMoveReminder* > myMoveReminders;
1679
1696 public:
1698 explicit vehicle_position_sorter(const MSLane* lane) :
1699 myLane(lane) {
1700 }
1701
1702
1708 int operator()(MSVehicle* v1, MSVehicle* v2) const;
1709
1711
1712 };
1713
1719 public:
1722 myLane(lane) {
1723 }
1724
1725
1731 int operator()(MSVehicle* v1, MSVehicle* v2) const;
1732
1734
1735 };
1736
1742 public:
1744 explicit by_connections_to_sorter(const MSEdge* const e);
1745
1747 int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1748
1749 private:
1750 const MSEdge* const myEdge;
1752 };
1753
1754
1755
1761 public:
1763 explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1764
1766 int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1767
1768 private:
1769 const MSLane* const myLane;
1771 };
1772
1773
1779 public:
1781 explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1782
1784 int operator()(const MSLink* link1, const MSLink* link2) const;
1785
1786 private:
1788 };
1789
1794 public:
1796 bool operator()(const IncomingLaneInfo& ili) const {
1797 return &(ili.lane->getEdge()) == myEdge;
1798 }
1799 private:
1800 const MSEdge* const myEdge;
1801 };
1802
1803#ifdef HAVE_FOX
1805 typedef void(MSLane::*Operation)(const SUMOTime);
1806
1811 class SimulationTask : public MFXWorkerThread::Task {
1812 public:
1813 SimulationTask(MSLane& l, const SUMOTime time)
1814 : myLane(l), myTime(time) {}
1815 void init(Operation operation, const SUMOTime time) {
1816 myOperation = operation;
1817 myTime = time;
1818 }
1819 void run(MFXWorkerThread* /*context*/) {
1820 (myLane.*(myOperation))(myTime);
1821 }
1822 private:
1823 Operation myOperation = nullptr;
1824 MSLane& myLane;
1825 SUMOTime myTime;
1826 private:
1828 SimulationTask& operator=(const SimulationTask&) = delete;
1829 };
1830
1831 SimulationTask mySimulationTask;
1833 mutable FXMutex myLeaderInfoMutex;
1835 mutable FXMutex myFollowerInfoMutex;
1836#endif
1837 std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
1838
1839private:
1841 MSLane(const MSLane&) = delete;
1842
1844 MSLane& operator=(const MSLane&) = delete;
1845
1846
1847};
1848
1849// specialized implementation for speedup and avoiding warnings
1850#define LANE_RTREE_QUAL RTree<MSLane*, MSLane, float, 2, MSLane::StoringVisitor>
1851
1852template<>
1853inline float LANE_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
1854 ASSERT(a_rect);
1855 const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
1856 const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
1857 return .78539816f * (extent0 * extent0 + extent1 * extent1);
1858}
1859
1860template<>
1861inline LANE_RTREE_QUAL::Rect LANE_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
1862 ASSERT(a_rectA && a_rectB);
1863 Rect newRect;
1864 newRect.m_min[0] = rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
1865 newRect.m_max[0] = rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
1866 newRect.m_min[1] = rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
1867 newRect.m_max[1] = rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
1868 return newRect;
1869}
long long int SUMOTime
Definition GUI.h:36
std::map< const MSLane *, std::pair< double, double > > LaneCoverageInfo
Coverage info.
Definition MSLane.h:72
#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.
DepartSpeedDefinition
Possible ways to choose the departure speed.
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:80
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:78
static int gNumSimThreads
how many threads to use for simulation
Definition MSGlobals.h:149
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:206
int myI3
index for myTmpVehicles
Definition MSLane.h:182
int myDirection
index delta
Definition MSLane.h:192
AnyVehicleIterator & operator++()
Definition MSLane.cpp:172
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:189
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:125
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:1741
const MSEdge *const myEdge
Definition MSLane.h:1750
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition MSLane.cpp:3587
bool operator()(const IncomingLaneInfo &ili) const
Definition MSLane.h:1796
edge_finder(MSEdge *e)
Definition MSLane.h:1795
const MSEdge *const myEdge
Definition MSLane.h:1800
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
Definition MSLane.h:1760
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Definition MSLane.cpp:3626
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
Definition MSLane.h:1778
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Definition MSLane.cpp:3703
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition MSLane.h:1721
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition MSLane.cpp:3569
Sorts vehicles by their position (descending)
Definition MSLane.h:1695
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition MSLane.cpp:3557
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition MSLane.h:1698
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:1330
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition MSLane.cpp:2921
void loadState(const std::vector< SUMOVehicle * > &vehs)
Loads the state of this segment with the given parameters.
Definition MSLane.cpp:3820
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:1988
static SUMOTime myIntermodalCollisionStopTime
Definition MSLane.h:1686
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:1540
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition MSLane.h:1578
MSLane * myLogicalPredecessorLane
Definition MSLane.h:1594
static void initCollisionAction(const OptionsCont &oc, const std::string &option, CollisionAction &myAction)
Definition MSLane.cpp:4575
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition MSLane.h:324
std::set< const MSBaseVehicle * > myParkingVehicles
Definition MSLane.h:1553
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:4683
static DepartSpeedDefinition & getDefaultDepartSpeedDefinition()
Definition MSLane.h:1409
static double myDefaultDepartSpeed
Definition MSLane.h:1690
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:4677
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:2905
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition MSLane.h:1644
const StopOffset & getLaneStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition MSLane.cpp:3847
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition MSLane.cpp:3744
virtual ~MSLane()
Destructor.
Definition MSLane.cpp:307
static CollisionAction getIntermodalCollisionAction()
Definition MSLane.h:1405
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition MSLane.cpp:692
bool mySpeedModified
Whether the current speed limit is set by a variable speed sign (VSS), TraCI or a MSCalibrator.
Definition MSLane.h:1575
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:1550
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition MSLane.cpp:2615
double myLength
Lane length [m].
Definition MSLane.h:1556
bool isApproachedFrom(MSEdge *const edge)
Definition MSLane.h:990
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition MSLane.cpp:3466
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition MSLane.cpp:2887
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
Definition MSLane.cpp:3421
PositionVector myShape
The shape of the lane.
Definition MSLane.h:1501
PositionVector * myOutlineShape
the outline of the lane (optional)
Definition MSLane.h:1504
std::map< long long, SVCPermissions > myPermissionChanges
Definition MSLane.h:1658
int getRNGIndex() const
returns the associated RNG index
Definition MSLane.h:241
double getFrictionCoefficient() const
Returns the lane's friction coefficient.
Definition MSLane.h:625
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition MSLane.h:1588
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:457
void initRestrictions()
initialized vClass-specific speed limits
Definition MSLane.cpp:316
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition MSLane.h:1678
MSLane & operator=(const MSLane &)=delete
invalidated assignment operator
bool hasApproaching() const
Definition MSLane.cpp:3749
SVCPermissions getChangeRight() const
Returns the vehicle class permissions for changing to the right neighbour lane.
Definition MSLane.h:654
void addParking(MSBaseVehicle *veh)
add parking vehicle. This should only used during state loading
Definition MSLane.cpp:3738
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition MSLane.h:1536
static DepartSpeedDefinition myDefaultDepartSpeedDefinition
Definition MSLane.h:1689
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition MSLane.cpp:607
void updateInternalLanePermissions(SVCPermissions oldPermissions)
Propagate a permission change of this lane to internal lanes that mirror it.
Definition MSLane.cpp:4635
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition MSLane.h:1627
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
Definition MSLane.cpp:3306
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition MSLane.h:457
static SUMOTime myCollisionStopTime
Definition MSLane.h:1685
static CollisionAction myCollisionAction
the action to take on collisions
Definition MSLane.h:1681
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition MSLane.h:1600
SVCPermissions myChangeLeft
The vClass permissions for changing from this lane.
Definition MSLane.h:1581
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:4096
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition MSLane.h:1591
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
Definition MSLane.h:496
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition MSLane.cpp:2570
bool hadPermissionChanges() const
Definition MSLane.cpp:4652
void sortPartialVehicles()
sorts myPartialVehicles
Definition MSLane.cpp:2642
double myFrictionCoefficient
Lane-wide friction coefficient [0..1].
Definition MSLane.h:1572
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition MSLane.cpp:2736
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:2824
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition MSLane.h:465
static bool myCheckJunctionCollisions
Definition MSLane.h:1683
static void clear()
Clears the dictionary.
Definition MSLane.cpp:2561
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition MSLane.h:1193
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition MSLane.cpp:439
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition MSLane.h:1585
MSEdge *const myEdge
The lane's edge, for routing only.
Definition MSLane.h:1567
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition MSLane.h:1606
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode, bool maxSearchDist=false) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
Definition MSLane.cpp:4482
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition MSLane.h:765
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:971
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition MSLane.cpp:2750
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:1947
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:2946
double myMaxSpeed
Lane-wide speed limit [m/s].
Definition MSLane.h:1570
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition MSLane.cpp:3759
void markRecalculateBruttoSum()
Set a flag to recalculate the brutto (including minGaps) occupancy of this lane (used if mingap is ch...
Definition MSLane.cpp:2482
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition MSLane.cpp:2801
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition MSLane.h:1646
void setChangeRight(SVCPermissions permissions)
Sets the permissions for changing to the right neighbour lane.
Definition MSLane.cpp:4664
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true, const MSVehicle *ignore=nullptr) const
Returns the last vehicles on the lane.
Definition MSLane.cpp:1488
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition MSLane.h:1638
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:1605
virtual double getLengthGeometryFactor(bool) const
Definition MSLane.h:290
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS, bool maxSearchDist=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition MSLane.cpp:3859
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition MSLane.cpp:4763
void visit(const MSLane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition MSLane.h:1378
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition MSLane.h:1632
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition MSLane.h:1625
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:852
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition MSLane.cpp:1435
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition MSLane.cpp:3834
static void initCollisionOptions(const OptionsCont &oc)
Definition MSLane.cpp:4591
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition MSLane.h:1498
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition MSLane.h:544
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition MSLane.h:1520
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition MSLane.h:602
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition MSLane.cpp:4319
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:819
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition MSLane.h:1672
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition MSLane.cpp:2578
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:1446
MSLane * myBidiLane
Definition MSLane.h:1655
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:4406
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition MSLane.cpp:2911
bool isWalkingArea() const
Definition MSLane.cpp:2693
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition MSLane.cpp:2514
SVCPermissions getChangeLeft() const
Returns the vehicle class permissions for changing to the left neighbour lane.
Definition MSLane.h:647
void addLink(MSLink *link)
Delayed initialization.
Definition MSLane.cpp:335
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:4386
void enteredByLaneChange(MSVehicle *v)
Definition MSLane.cpp:3414
double getDepartPosLat(const MSVehicle &veh)
Definition MSLane.cpp:666
const std::string & getLaneType() const
return the type of this lane
Definition MSLane.h:549
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode=MinorLinkMode::FOLLOW_NEVER) const
Definition MSLane.cpp:4505
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:640
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition MSLane.cpp:3372
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition MSLane.cpp:2488
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition MSLane.h:984
static const long CHANGE_PERMISSIONS_PERMANENT
Definition MSLane.h:1418
virtual void addMoveReminder(MSMoveReminder *rem, bool addToVehicles=true)
Add a move-reminder to move-reminder container.
Definition MSLane.cpp:362
MSLane * getCanonicalPredecessorLane() const
Definition MSLane.cpp:3327
void resetPermissions(long long transientID)
Definition MSLane.cpp:4618
bool isPriorityCrossing() const
Definition MSLane.cpp:2687
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition MSLane.cpp:2699
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition MSLane.cpp:4773
const std::string myLaneType
the type of this lane
Definition MSLane.h:1641
int myRNGIndex
Definition MSLane.h:1661
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
Definition MSLane.h:1548
const MSJunction * getToJunction() const
Definition MSLane.cpp:4833
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition MSLane.cpp:4229
bool needsCollisionCheck() const
short-circuit collision check if nothing changed since the last check
Definition MSLane.h:731
static double myCheckJunctionCollisionMinGap
Definition MSLane.h:1684
double getLength() const
Returns the lane's length.
Definition MSLane.h:632
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition MSLane.h:1603
bool mayContinue(const MSVehicle *veh) const
whether the route of the give vehicle might be extended on insertion
Definition MSLane.cpp:4839
const PositionVector & getShape() const
Returns this lane's shape.
Definition MSLane.h:534
static bool isFrontalCollision(const MSVehicle *collider, const MSVehicle *victim)
detect frontal collisions
Definition MSLane.cpp:2309
void setChangeLeft(SVCPermissions permissions)
Sets the permissions for changing to the left neighbour lane.
Definition MSLane.cpp:4658
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:4417
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:2520
const MSJunction * getFromJunction() const
Definition MSLane.cpp:4827
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:2095
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition MSLane.cpp:2962
static CollisionAction myIntermodalCollisionAction
Definition MSLane.h:1682
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:2813
bool isLinkEnd(std::vector< MSLink * >::iterator &i)
Definition MSLane.h:887
static std::vector< SumoRNG > myRNGs
Definition MSLane.h:1674
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:966
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition MSLane.cpp:2870
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:3187
StopOffset myLaneStopOffset
Definition MSLane.h:1564
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition MSLane.cpp:4750
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:3046
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:4334
bool myRecalculateBruttoSum
Flag to recalculate the occupancy (including minGaps) after a change in minGap.
Definition MSLane.h:1615
virtual void removeMoveReminder(MSMoveReminder *rem)
Remove a move-reminder from move-reminder container.
Definition MSLane.cpp:374
void clearState()
Remove all vehicles before quick-loading state.
Definition MSLane.cpp:3803
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition MSLane.h:1597
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition MSLane.h:1649
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition MSLane.h:881
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition MSLane.h:959
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition MSLane.cpp:386
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:575
void setBidiLane(MSLane *bidyLane)
Adds the (overlapping) reverse direction lane to this lane.
Definition MSLane.cpp:349
double getRightSideOnEdge() const
Definition MSLane.h:1229
void checkBufferType()
Definition MSLane.cpp:323
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition MSLane.cpp:4533
bool hasPedestrians() const
whether the lane has pedestrians on it
Definition MSLane.cpp:4670
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition MSLane.cpp:3383
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition MSLane.cpp:4296
int getIndex() const
Returns the lane's index.
Definition MSLane.h:668
void setLaneStopOffset(const StopOffset &stopOffset)
Set vehicle class specific stopOffsets.
Definition MSLane.cpp:3853
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition MSLane.h:1609
void leftByLaneChange(MSVehicle *v)
Definition MSLane.cpp:3407
MSLane * getCanonicalSuccessorLane() const
Definition MSLane.cpp:3351
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition MSLane.h:736
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
Definition MSLane.h:1837
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:4604
const double myWidth
Lane width [m].
Definition MSLane.h:1559
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:482
virtual void addSecondaryShape(const PositionVector &)
Definition MSLane.h:288
void changeLanes(const SUMOTime time)
Definition MSLane.cpp:2508
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition MSLane.cpp:4477
SVCPermissions myChangeRight
Definition MSLane.h:1582
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition MSLane.h:1635
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition MSLane.cpp:2328
const std::set< const MSBaseVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition MSLane.h:1288
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
Definition MSLane.cpp:3271
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition MSLane.cpp:3451
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
Definition MSLane.h:508
int myIndex
The lane index.
Definition MSLane.h:1507
double getCenterOnEdge() const
Definition MSLane.h:1237
bool isNormal() const
Definition MSLane.cpp:2675
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh, double vehMaxSpeed) const
Definition MSLane.h:580
static double & getDefaultDepartSpeed()
Definition MSLane.h:1413
bool isSpeedModified() const
Definition MSLane.h:594
bool isCrossing() const
Definition MSLane.cpp:2681
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
Definition MSLane.cpp:3515
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:1653
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition MSLane.cpp:3481
bool hasUnsafeLink() const
whether any link from this lane is unsafe
Definition MSLane.cpp:4854
double getSpeedLimit(SUMOVehicleClass svc) const
Definition MSLane.h:607
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition MSLane.cpp:2538
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition MSLane.h:1293
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition MSLane.cpp:1706
std::vector< MSLink * > myLinks
Definition MSLane.h:1619
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition MSLane.cpp:2717
bool isInternal() const
Definition MSLane.cpp:2669
static const long CHANGE_PERMISSIONS_GUI
Definition MSLane.h:1419
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition MSLane.h:1532
void sortManeuverReservations()
sorts myManeuverReservations
Definition MSLane.cpp:2650
MinorLinkMode
determine whether/how getFollowers looks upstream beyond minor links
Definition MSLane.h:1007
@ FOLLOW_ONCOMING
Definition MSLane.h:1010
@ FOLLOW_ALWAYS
Definition MSLane.h:1009
@ FOLLOW_NEVER
Definition MSLane.h:1008
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible)
Definition MSLane.h:473
void setMaxSpeed(const double val, const bool modified=true, const double jamThreshold=-1)
Sets a new maximum speed for the lane (used by TraCI, MSLaneSpeedTrigger (VSS) and MSCalibrator)
Definition MSLane.cpp:2841
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition MSLane.h:567
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
Definition MSLane.h:502
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition MSLane.cpp:3393
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition MSLane.cpp:405
SumoRNG * getRNG() const
return the associated RNG
Definition MSLane.h:246
void setOpposite(MSLane *oppositeLane)
Adds a neighbor to this lane.
Definition MSLane.cpp:341
static int dictSize()
Returns the number of stored lanes.
Definition MSLane.h:843
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
Definition MSLane.h:490
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition MSLane.cpp:3540
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:2974
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:2232
static bool myExtrapolateSubstepDepart
Definition MSLane.h:1688
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
Definition MSLane.cpp:4465
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition MSLane.cpp:2863
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition MSLane.h:1622
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition MSLane.h:484
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition MSLane.h:514
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition MSLane.cpp:4788
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:555
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition MSLane.cpp:428
virtual void setJunctionApproaches() const
Register junction approaches for all vehicles after velocities have been planned.
Definition MSLane.cpp:1645
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition MSLane.cpp:4782
static double myCollisionMinGapFactor
Definition MSLane.h:1687
virtual void updateMesoGUISegments()
Definition MSLane.h:299
bool isEmpty() const
Definition MSLane.h:893
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:539
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition MSLane.h:1630
MSLane * myOpposite
Definition MSLane.h:1652
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:4471
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition MSLane.h:1664
double getFractionalVehicleLength(bool brutto) const
return length of fractional vehicles on this lane
Definition MSLane.cpp:3432
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:790
const PositionVector * getOutlineShape() const
Definition MSLane.h:1394
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:4797
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:1203
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
Definition MSLane.cpp:3296
int getNumericalID() const
Returns this lane's numerical id.
Definition MSLane.h:526
void setRightSideOnEdge(double value, int rightmostSublane)
Definition MSLane.h:1219
virtual bool appropriate(const MSVehicle *veh) const
Definition MSLane.cpp:2594
double getWidth() const
Returns the lane's width.
Definition MSLane.h:661
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition MSLane.h:750
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:517
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition MSLane.cpp:2708
int getRightmostSublane() const
Definition MSLane.h:1233
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition MSLane.cpp:3494
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition MSLane.h:1612
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:561
void setFrictionCoefficient(double val)
Sets a new friction coefficient for the lane [to be later (used by TraCI and MSCalibrator)].
Definition MSLane.cpp:2856
static CollisionAction getCollisionAction()
Definition MSLane.h:1401
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:53
A storage for options typed value containers)
Definition OptionsCont.h:92
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:63
stop offset