Eclipse SUMO - Simulation of Urban MObility
MSLane.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2023 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:
206 };
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
230
232 virtual ~MSLane();
233
235 inline int getThreadIndex() const {
237 }
238
240 inline int getRNGIndex() const {
241 return myRNGIndex;
242 }
243
245 SumoRNG* getRNG() const {
246 return &myRNGs[myRNGIndex];
247 }
248
250 static int getNumRNGs() {
251 return (int)myRNGs.size();
252 }
253
255 static void saveRNGStates(OutputDevice& out);
256
258 static void loadRNGState(int index, const std::string& state);
259
262
270 void addLink(MSLink* link);
271
276 void setOpposite(MSLane* oppositeLane);
277
282 void setBidiLane(MSLane* bidyLane);
284
287 virtual void addSecondaryShape(const PositionVector& /*shape*/) {}
288
289 virtual double getLengthGeometryFactor(bool /*secondaryShape*/) const {
291 }
292
293 virtual const PositionVector& getShape(bool /*secondaryShape*/) const {
294 return myShape;
295 }
297
298
301
308 virtual void addMoveReminder(MSMoveReminder* rem);
309
310
314 inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
315 return myMoveReminders;
316 }
318
319
320
323
339 bool insertVehicle(MSVehicle& v);
340
341
360 bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
361 bool recheckNextLanes,
362 MSMoveReminder::Notification notification);
363
364 // XXX: Documentation?
365 bool checkFailure(const MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const;
366
370 bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
371
379 bool freeInsertion(MSVehicle& veh, double speed, double posLat,
381
382
392 void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
394
395
396
400
407 virtual double setPartialOccupation(MSVehicle* v);
408
412 virtual void resetPartialOccupation(MSVehicle* v);
413
416 virtual void setManeuverReservation(MSVehicle* v);
417
421 virtual void resetManeuverReservation(MSVehicle* v);
422
433 const MSLeaderInfo getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
434
436 const MSLeaderInfo getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
437
439
442
447 int getVehicleNumber() const {
448 return (int)myVehicles.size();
449 }
450
456 return (int)myVehicles.size() + (int)myPartialVehicles.size();
457 }
458
464 return (int)myPartialVehicles.size();
465 }
466
467
474 virtual const VehCont& getVehiclesSecure() const {
475 return myVehicles;
476 }
477
478
481 return AnyVehicleIterator(this, 0, 0, 0,
482 (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
483 }
484
487 return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(),
488 (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
489 }
490
493 return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, (int)myTmpVehicles.size() - 1,
494 -1, -1, -1, false);
495 }
496
499 return AnyVehicleIterator(this, -1, -1, -1, -1, -1, -1, false);
500 }
501
504 virtual void releaseVehicles() const { }
506
507
508
511
512
516 inline int getNumericalID() const {
517 return myNumericalID;
518 }
519
520
524 inline const PositionVector& getShape() const {
525 return myShape;
526 }
527
529 inline double getLengthGeometryFactor() const {
531 }
532
534 inline bool isAccelLane() const {
535 return myIsRampAccel;
536 }
537
539 const std::string& getLaneType() const {
540 return myLaneType;
541 }
542
543 /* @brief fit the given lane position to a visibly suitable geometry position
544 * (lane length might differ from geometry length) */
545 inline double interpolateLanePosToGeometryPos(double lanePos) const {
546 return lanePos * myLengthGeometryFactor;
547 }
548
549 /* @brief fit the given lane position to a visibly suitable geometry position
550 * and return the coordinates */
551 inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
552 return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
553 }
554
555 /* @brief fit the given geometry position to a valid lane position
556 * (lane length might differ from geometry length) */
557 inline double interpolateGeometryPosToLanePos(double geometryPos) const {
558 return geometryPos / myLengthGeometryFactor;
559 }
560
565 inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh) const {
566 if (myRestrictions != nullptr) {
567 std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
568 if (r != myRestrictions->end()) {
569 return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
570 }
571 }
572 return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
573 }
574
575
579 inline double getSpeedLimit() const {
580 return myMaxSpeed;
581 }
582
586 inline double getFrictionCoefficient() const {
588 }
589
593 inline double getLength() const {
594 return myLength;
595 }
596
597
602 return myPermissions;
603 }
604
609 return myChangeLeft;
610 }
611
616 return myChangeRight;
617 }
618
622 double getWidth() const {
623 return myWidth;
624 }
625
629 int getIndex() const {
630 return myIndex;
631 }
633
635 int getCrossingIndex() const;
636
637
640
648 virtual void planMovements(const SUMOTime t);
649
655 virtual void setJunctionApproaches(const SUMOTime t) const;
656
665 void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
666
677 virtual void executeMovements(const SUMOTime t);
678
680 virtual void integrateNewVehicles();
681
683 void updateLengthSum();
685
686
688 inline bool needsCollisionCheck() const {
690 }
691
693 inline void requireCollisionCheck() {
695 }
696
698 virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
699
700
703 virtual bool appropriate(const MSVehicle* veh) const;
704
705
707 const std::vector<MSLink*>& getLinkCont() const {
708 return myLinks;
709 }
710
712 const MSLink* getLinkTo(const MSLane* const) const;
713
715 const MSLane* getInternalFollowingLane(const MSLane* const) const;
716
718 const MSLink* getEntryLink() const;
719
720
722 bool empty() const {
723 assert(myVehBuffer.size() == 0);
724 return myVehicles.empty();
725 }
726
730 void setMaxSpeed(double val);
731
735 void setFrictionCoefficient(double val);
736
740 void setLength(double val);
741
745 MSEdge& getEdge() const {
746 return *myEdge;
747 }
748
749
753 const MSEdge* getNextNormal() const;
754
755
761 const MSLane* getFirstInternalInConnection(double& offset) const;
762
763
766
777 static bool dictionary(const std::string& id, MSLane* lane);
778
779
786 static MSLane* dictionary(const std::string& id);
787
788
790 static void clear();
791
792
796 static int dictSize() {
797 return (int)myDict.size();
798 }
799
800
804 static void insertIDs(std::vector<std::string>& into);
805
806
811 template<class RTREE>
812 static void fill(RTREE& into);
813
814
816 static void initRNGs(const OptionsCont& oc);
818
819
820
821 // XXX: succLink does not exist... Documentation?
826 static std::vector<MSLink*>::const_iterator succLinkSec(const SUMOVehicle& veh,
827 int nRouteSuccs,
828 const MSLane& succLinkSource,
829 const std::vector<MSLane*>& conts);
830
831
834 inline bool isLinkEnd(std::vector<MSLink*>::const_iterator& i) const {
835 return i == myLinks.end();
836 }
837
840 inline bool isLinkEnd(std::vector<MSLink*>::iterator& i) {
841 return i == myLinks.end();
842 }
843
846 inline bool isEmpty() const {
847 return myVehicles.empty() && myPartialVehicles.empty();
848 }
849
851 bool isInternal() const;
852
854 bool isNormal() const;
855
857 bool isCrossing() const;
858
861
864
867
868 /* @brief remove the vehicle from this lane
869 * @param[notify] whether moveReminders of the vehicle shall be triggered
870 */
871 virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
872
875
879 MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
880
881
886 void setPermissions(SVCPermissions permissions, long long transientID);
887 void resetPermissions(long long transientID);
888 bool hadPermissionChanges() const;
889
893 void setChangeLeft(SVCPermissions permissions);
894
898 void setChangeRight(SVCPermissions permissions);
899
900 inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
901 return (myPermissions & vclass) == vclass;
902 }
903
905 inline bool allowsChangingLeft(SUMOVehicleClass vclass) const {
906 return (myChangeLeft & vclass) == vclass;
907 }
908
910 inline bool allowsChangingRight(SUMOVehicleClass vclass) const {
911 return (myChangeRight & vclass) == vclass;
912 }
913
914 void addIncomingLane(MSLane* lane, MSLink* viaLink);
915
916
919 double length;
921 };
922
923 const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
924 return myIncomingLanes;
925 }
926
927
928 void addApproachingLane(MSLane* lane, bool warnMultiCon);
929 inline bool isApproachedFrom(MSEdge* const edge) {
930 return myApproachingLanes.find(edge) != myApproachingLanes.end();
931 }
932 bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
933
935 double getVehicleStopOffset(const MSVehicle* veh) const;
936
938 const StopOffset& getLaneStopOffsets() const;
939
941 void setLaneStopOffset(const StopOffset& stopOffset);
942
950 };
951
953 MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
954 bool allSublanes, double searchDist = -1, MinorLinkMode mLinkMode = FOLLOW_ALWAYS) const;
955
957 double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
958
971 std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
972
995 std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
996 double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
997
999 void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
1000 const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result, bool oppositeDirection = false) const;
1001
1002
1004 void addLeaders(const MSVehicle* vehicle, double vehPos, MSLeaderDistanceInfo& result, bool oppositeDirection = false);
1005
1006
1024 std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
1025
1026 /* @brief return the partial vehicle closest behind ego or 0
1027 * if no such vehicle exists */
1028 MSVehicle* getPartialBehind(const MSVehicle* ego) const;
1029
1032
1043 std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
1044
1047 std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
1048
1050 std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1051
1053 std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1054
1059
1063 const MSLane* getNormalPredecessorLane() const;
1064
1068 const MSLane* getNormalSuccessorLane() const;
1069
1072 MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
1073
1074
1081
1082
1089
1092
1094 const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
1095
1097 std::vector<const MSLane*> getNormalIncomingLanes() const;
1098
1100
1101
1105 double getMeanSpeed() const;
1106
1108 double getMeanSpeedBike() const;
1109
1113 double getWaitingSeconds() const;
1114
1115
1119 double getBruttoOccupancy() const;
1120
1121
1125 double getNettoOccupancy() const;
1126
1127
1131 inline double getBruttoVehLenSum() const {
1133 }
1134
1135
1140 template<PollutantsInterface::EmissionType ET>
1141 double getEmissions() const {
1142 double ret = 0;
1143 for (MSVehicle* const v : getVehiclesSecure()) {
1144 ret += v->getEmissions<ET>();
1145 }
1147 return ret;
1148 }
1149
1150
1154 double getHarmonoise_NoiseEmissions() const;
1156
1157 void setRightSideOnEdge(double value, int rightmostSublane) {
1158 myRightSideOnEdge = value;
1159 myRightmostSublane = rightmostSublane;
1160 }
1161
1163 void initRestrictions();
1164
1165 void checkBufferType();
1166
1167 double getRightSideOnEdge() const {
1168 return myRightSideOnEdge;
1169 }
1170
1172 return myRightmostSublane;
1173 }
1174
1175 double getCenterOnEdge() const {
1176 return myRightSideOnEdge + 0.5 * myWidth;
1177 }
1178
1180 void sortPartialVehicles();
1181
1184
1186 MSLane* getOpposite() const;
1187
1189 MSLane* getParallelOpposite() const;
1190
1192 double getOppositePos(double pos) const;
1193
1194 /* @brief find leader for a vehicle depending on the relative driving direction
1195 * @param[in] ego The ego vehicle
1196 * @param[in] dist The look-ahead distance when looking at consecutive lanes
1197 * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1198 * @return the leader vehicle and it's gap to ego
1199 */
1200 std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode = MinorLinkMode::FOLLOW_NEVER) const;
1201
1202 /* @brief find follower for a vehicle that is located on the opposite of this lane
1203 * @param[in] ego The ego vehicle
1204 * @return the follower vehicle and it's gap to ego
1205 */
1206 std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1207
1208
1216 std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, MinorLinkMode mLinkMode) const;
1217
1218
1220 void addParking(MSBaseVehicle* veh);
1221
1223 virtual void removeParking(MSBaseVehicle* veh);
1224
1226 const std::set<const MSBaseVehicle*>& getParkingVehicles() const {
1227 return myParkingVehicles;
1228 }
1229
1231 virtual bool isSelected() const {
1232 return false;
1233 }
1234
1236 MSLane* getBidiLane() const;
1237
1239 bool mustCheckJunctionCollisions() const;
1240
1241#ifdef HAVE_FOX
1242 MFXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1243 mySimulationTask.init(&MSLane::planMovements, time);
1244 return &mySimulationTask;
1245 }
1246
1247 MFXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1248 mySimulationTask.init(&MSLane::executeMovements, time);
1249 return &mySimulationTask;
1250 }
1251
1252 MFXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1253 mySimulationTask.init(&MSLane::changeLanes, time);
1254 return &mySimulationTask;
1255 }
1256#endif
1257
1258 std::vector<StopWatch<std::chrono::nanoseconds> >& getStopWatch() {
1259 return myStopWatch;
1260 }
1261
1262 void changeLanes(const SUMOTime time);
1263
1266
1274 void saveState(OutputDevice& out);
1275
1277 void clearState();
1278
1290 void loadState(const std::vector<std::string>& vehIDs, MSVehicleControl& vc);
1291
1292
1293 /* @brief helper function for state saving: checks whether any outgoing
1294 * links are being approached */
1295 bool hasApproaching() const;
1296
1298
1299
1307 void visit(const MSLane::StoringVisitor& cont) const {
1308 cont.add(this);
1309 }
1310
1312 bool hasPedestrians() const;
1313
1315 std::pair<const MSPerson*, double> nextBlocking(double minPos, double minRight, double maxLeft, double stopTime = 0, bool bidi = false) const;
1316
1318 double getSpaceTillLastStanding(const MSVehicle* ego, bool& foundStopped) const;
1319
1321 double getMaximumBrakeDist() const;
1322
1323 static void initCollisionOptions(const OptionsCont& oc);
1324
1326 return myCollisionAction;
1327 }
1328
1329 static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1330 static const long CHANGE_PERMISSIONS_GUI = 1;
1331
1332protected:
1334 virtual void swapAfterLaneChange(SUMOTime t);
1335
1347 virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1348 const MSLane::VehCont::iterator& at,
1350
1352 void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1353 SUMOTime timestep, const std::string& stage);
1354
1356 bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1357 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1358 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1359
1361 void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1362 double gap, double latGap,
1363 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1364 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1365
1366 /* @brief determine depart speed and whether it may be patched
1367 * @param[in] veh The departing vehicle
1368 * @param[out] whether the speed may be patched to account for safety
1369 * @return the depart speed
1370 */
1371 double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1372
1373 /* @brief determine the lateral depart position
1374 * @param[in] veh The departing vehicle
1375 * @return the lateral depart position
1376 */
1377 double getDepartPosLat(const MSVehicle& veh);
1378
1381 double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1382
1384 bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1385
1387 bool hasApproaching(const std::vector<MSLink*>& links) const;
1388
1390 double getFractionalVehicleLength(bool brutto) const;
1391
1394
1397
1400
1413
1425
1429
1433
1441
1442 /* @brief list of vehicles that are parking near this lane
1443 * (not necessarily on the road but having reached their stop on this lane)
1444 * */
1445 std::set<const MSBaseVehicle*> myParkingVehicles;
1446
1448 double myLength;
1449
1451 const double myWidth;
1452
1457
1460
1465
1468
1472
1475
1477 const std::map<SUMOVehicleClass, double>* myRestrictions;
1478
1480 std::vector<IncomingLaneInfo> myIncomingLanes;
1481
1484
1487
1490
1493
1496
1499
1502
1505 std::vector<MSLink*> myLinks;
1506
1508 std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1509
1514
1519
1522
1524 const bool myIsRampAccel;
1525
1527 const std::string myLaneType;
1528
1533
1536
1537 // @brief the neighboring opposite direction or nullptr
1539
1540 // @brief bidi lane or nullptr
1542
1543 // @brief transient changes in permissions
1544 std::map<long long, SVCPermissions> myPermissionChanges;
1545
1546 // @brief index of the associated thread-rng
1548
1550 typedef std::map< std::string, MSLane* > DictType;
1551
1554
1555 static std::vector<SumoRNG> myRNGs;
1556
1557private:
1559 std::vector< MSMoveReminder* > myMoveReminders;
1560
1568
1574 public:
1576 explicit vehicle_position_sorter(const MSLane* lane) :
1577 myLane(lane) {
1578 }
1579
1580
1586 int operator()(MSVehicle* v1, MSVehicle* v2) const;
1587
1589
1590 };
1591
1597 public:
1600 myLane(lane) {
1601 }
1602
1603
1609 int operator()(MSVehicle* v1, MSVehicle* v2) const;
1610
1612
1613 };
1614
1620 public:
1622 explicit by_connections_to_sorter(const MSEdge* const e);
1623
1625 int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1626
1627 private:
1628 const MSEdge* const myEdge;
1630 };
1631
1632
1633
1639 public:
1641 explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1642
1644 int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1645
1646 private:
1647 const MSLane* const myLane;
1649 };
1650
1651
1657 public:
1659 explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1660
1662 int operator()(const MSLink* link1, const MSLink* link2) const;
1663
1664 private:
1666 };
1667
1672 public:
1674 bool operator()(const IncomingLaneInfo& ili) const {
1675 return &(ili.lane->getEdge()) == myEdge;
1676 }
1677 private:
1678 const MSEdge* const myEdge;
1679 };
1680
1681#ifdef HAVE_FOX
1683 typedef void(MSLane::*Operation)(const SUMOTime);
1684
1689 class SimulationTask : public MFXWorkerThread::Task {
1690 public:
1691 SimulationTask(MSLane& l, const SUMOTime time)
1692 : myLane(l), myTime(time) {}
1693 void init(Operation operation, const SUMOTime time) {
1694 myOperation = operation;
1695 myTime = time;
1696 }
1697 void run(MFXWorkerThread* /*context*/) {
1698 try {
1699 (myLane.*(myOperation))(myTime);
1700 } catch (ProcessError& e) {
1701 WRITE_ERROR(e.what());
1702 }
1703 }
1704 private:
1705 Operation myOperation = nullptr;
1706 MSLane& myLane;
1707 SUMOTime myTime;
1708 private:
1710 SimulationTask& operator=(const SimulationTask&) = delete;
1711 };
1712
1713 SimulationTask mySimulationTask;
1715 mutable FXMutex myLeaderInfoMutex;
1717 mutable FXMutex myFollowerInfoMutex;
1719 mutable FXMutex myPartialOccupatorMutex;
1720#endif
1721 std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
1722
1723private:
1725 MSLane(const MSLane&) = delete;
1726
1728 MSLane& operator=(const MSLane&) = delete;
1729
1730
1731};
1732
1733// specialized implementation for speedup and avoiding warnings
1734#define LANE_RTREE_QUAL RTree<MSLane*, MSLane, float, 2, MSLane::StoringVisitor>
1735
1736template<>
1737inline float LANE_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
1738 ASSERT(a_rect);
1739 const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
1740 const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
1741 return .78539816f * (extent0 * extent0 + extent1 * extent1);
1742}
1743
1744template<>
1745inline LANE_RTREE_QUAL::Rect LANE_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
1746 ASSERT(a_rectA && a_rectB);
1747 Rect newRect;
1748 newRect.m_min[0] = rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
1749 newRect.m_max[0] = rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
1750 newRect.m_min[1] = rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
1751 newRect.m_max[1] = rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
1752 return newRect;
1753}
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:276
#define rtree_min(a, b)
Definition: RTree.h:20
#define rtree_max(a, b)
Definition: RTree.h:21
#define ASSERT
Definition: RTree.h:12
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
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
Definition: MFXSynchQue.h:156
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.
Definition: MSBaseVehicle.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:77
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:143
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:196
int myI3
index for myTmpVehicles
Definition: MSLane.h:182
int myDirection
index delta
Definition: MSLane.h:192
AnyVehicleIterator & operator++()
Definition: MSLane.cpp:162
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:179
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:115
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
const int myDomain
Definition: MSLane.h:101
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:1619
by_connections_to_sorter(const MSEdge *const e)
constructor
Definition: MSLane.cpp:3217
const MSEdge *const myEdge
Definition: MSLane.h:1628
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition: MSLane.cpp:3224
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1674
edge_finder(MSEdge *e)
Definition: MSLane.h:1673
const MSEdge *const myEdge
Definition: MSLane.h:1678
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
Definition: MSLane.h:1638
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
Definition: MSLane.cpp:3258
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Definition: MSLane.cpp:3263
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
Definition: MSLane.h:1656
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
Definition: MSLane.cpp:3336
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Definition: MSLane.cpp:3340
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1599
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:3206
Sorts vehicles by their position (descending)
Definition: MSLane.h:1573
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:3194
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1576
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:45
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:1258
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:2578
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:1811
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:1432
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1467
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1483
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition: MSLane.cpp:1475
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:314
std::set< const MSBaseVehicle * > myParkingVehicles
Definition: MSLane.h:1445
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:4253
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:4079
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:4247
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:2562
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1530
const StopOffset & getLaneStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition: MSLane.cpp:3486
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3381
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:275
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:634
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:1380
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:2311
double myLength
Lane length [m].
Definition: MSLane.h:1448
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.h:929
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition: MSLane.cpp:3103
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2544
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
Definition: MSLane.cpp:3058
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1396
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1544
int getRNGIndex() const
returns the associated RNG index
Definition: MSLane.h:240
double getFrictionCoefficient() const
Returns the lane's friction coefficient.
Definition: MSLane.h:586
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1477
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:411
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:283
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition: MSLane.h:1559
MSLane & operator=(const MSLane &)=delete
invalidated assignment operator
bool hasApproaching() const
Definition: MSLane.cpp:3386
SVCPermissions getChangeRight() const
Returns the vehicle class permissions for changing to the right neighbour lane.
Definition: MSLane.h:615
void addParking(MSBaseVehicle *veh)
add parking vehicle. This should only used during state loading
Definition: MSLane.cpp:3375
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1428
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:557
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1513
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
Definition: MSLane.cpp:2943
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:447
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1565
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1562
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1489
SVCPermissions myChangeLeft
The vClass permissions for changing from this lane.
Definition: MSLane.h:1470
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:3716
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1480
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:486
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:2266
bool hadPermissionChanges() const
Definition: MSLane.cpp:4222
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:2338
double myFrictionCoefficient
Lane-wide friction coefficient [0..1].
Definition: MSLane.h:1464
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2406
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:2492
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:455
static bool myCheckJunctionCollisions
Definition: MSLane.h:1563
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:2257
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:1131
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition: MSLane.cpp:393
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1474
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1459
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1495
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:722
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:910
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:2420
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:2603
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1462
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:3396
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2469
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1532
void setChangeRight(SVCPermissions permissions)
Sets the permissions for changing to the right neighbour lane.
Definition: MSLane.cpp:4234
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1524
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:1435
virtual double getLengthGeometryFactor(bool) const
Definition: MSLane.h:289
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition: MSLane.cpp:4302
void visit(const MSLane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1307
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1518
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1511
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:775
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1280
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition: MSLane.cpp:3473
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:4173
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1393
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:534
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1412
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:579
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition: MSLane.cpp:3916
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:743
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1553
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:2274
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:1291
MSLane * myBidiLane
Definition: MSLane.h:1541
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:4003
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2568
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:2210
SVCPermissions getChangeLeft() const
Returns the vehicle class permissions for changing to the left neighbour lane.
Definition: MSLane.h:608
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:303
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:3983
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:3051
double getDepartPosLat(const MSVehicle &veh)
Definition: MSLane.cpp:608
const std::string & getLaneType() const
return the type of this lane
Definition: MSLane.h:539
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode=MinorLinkMode::FOLLOW_NEVER) const
Definition: MSLane.cpp:4102
int getThreadIndex() const
returns the associated thread index
Definition: MSLane.h:235
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:601
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:3009
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition: MSLane.cpp:2190
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:923
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1329
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:2964
void resetPermissions(long long transientID)
Definition: MSLane.cpp:4207
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2383
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition: MSLane.cpp:4312
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1527
int myRNGIndex
Definition: MSLane.h:1547
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
Definition: MSLane.h:1440
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition: MSLane.cpp:3827
bool needsCollisionCheck() const
short-circut collision check if nothing changed since the last check
Definition: MSLane.h:688
static double myCheckJunctionCollisionMinGap
Definition: MSLane.h:1564
double getLength() const
Returns the lane's length.
Definition: MSLane.h:593
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1492
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:524
void setChangeLeft(SVCPermissions permissions)
Sets the permissions for changing to the left neighbour lane.
Definition: MSLane.cpp:4228
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:4014
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:2216
static int getNumRNGs()
return the number of RNGs
Definition: MSLane.h:250
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:1918
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:2619
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:2481
bool isLinkEnd(std::vector< MSLink * >::iterator &i)
Definition: MSLane.h:840
static std::vector< SumoRNG > myRNGs
Definition: MSLane.h:1555
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:905
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2530
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:2824
StopOffset myLaneStopOffset
Definition: MSLane.h:1456
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:1324
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition: MSLane.cpp:4289
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:3931
MSLane(const std::string &id, double maxSpeed, double friction, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: MSLane.cpp:232
void clearState()
Remove all vehicles before quick-loading state.
Definition: MSLane.cpp:3438
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1486
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition: MSLane.h:1535
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition: MSLane.h:834
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:900
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:340
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:565
void setBidiLane(MSLane *bidyLane)
Adds the (overlapping) reverse direction lane to this lane.
Definition: MSLane.cpp:317
double getRightSideOnEdge() const
Definition: MSLane.h:1167
void checkBufferType()
Definition: MSLane.cpp:291
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:4130
bool hasPedestrians() const
whether the lane has pedestrians on it
Definition: MSLane.cpp:4240
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:3020
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:3893
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:629
void setLaneStopOffset(const StopOffset &stopOffset)
Set vehicle class specific stopOffsets.
Definition: MSLane.cpp:3492
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1498
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:3044
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:2988
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition: MSLane.h:693
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
Definition: MSLane.h:1721
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:4195
const double myWidth
Lane width [m].
Definition: MSLane.h:1451
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:436
virtual void addSecondaryShape(const PositionVector &)
Definition: MSLane.h:287
void changeLanes(const SUMOTime time)
Definition: MSLane.cpp:2204
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:4074
SVCPermissions myChangeRight
Definition: MSLane.h:1471
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1521
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:2051
const std::set< const MSBaseVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition: MSLane.h:1226
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2908
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:3088
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:498
int myIndex
The lane index.
Definition: MSLane.h:1399
double getCenterOnEdge() const
Definition: MSLane.h:1175
bool isNormal() const
Definition: MSLane.cpp:2371
bool isCrossing() const
Definition: MSLane.cpp:2377
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
Definition: MSLane.cpp:3152
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:1483
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:3118
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:2509
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:2234
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition: MSLane.h:1231
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage)
detect whether a vehicle collids with pedestrians on the junction
Definition: MSLane.cpp:1767
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1536
std::vector< MSLink * > myLinks
Definition: MSLane.h:1505
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2392
bool isInternal() const
Definition: MSLane.cpp:2365
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1330
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1424
void sortManeuverReservations()
sorts myManeuverReservations
Definition: MSLane.cpp:2346
MinorLinkMode
determine whether/how getFollowers looks upstream beyond minor links
Definition: MSLane.h:946
@ FOLLOW_ONCOMING
Definition: MSLane.h:949
@ FOLLOW_ALWAYS
Definition: MSLane.h:948
@ FOLLOW_NEVER
Definition: MSLane.h:947
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible)
Definition: MSLane.h:463
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:557
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:492
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition: MSLane.cpp:3030
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:359
SumoRNG * getRNG() const
return the associated RNG
Definition: MSLane.h:245
void setOpposite(MSLane *oppositeLane)
Adds a neighbor to this lane.
Definition: MSLane.cpp:309
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:796
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:480
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:3177
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:2631
static bool myExtrapolateSubstepDepart
Definition: MSLane.h:1567
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
Definition: MSLane.cpp:4062
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:2523
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1508
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:474
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:504
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition: MSLane.cpp:4327
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:545
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition: MSLane.cpp:382
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:4321
static double myCollisionMinGapFactor
Definition: MSLane.h:1566
bool isEmpty() const
Definition: MSLane.h:846
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
Definition: MSLane.cpp:2703
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:529
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1516
MSLane * myOpposite
Definition: MSLane.h:1538
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:293
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
Definition: MSLane.cpp:4068
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1550
double getFractionalVehicleLength(bool brutto) const
return length of fractional vehicles on this lane
Definition: MSLane.cpp:3069
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:745
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:4333
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:1141
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
Definition: MSLane.cpp:2933
int getNumericalID() const
Returns this lane's numerical id.
Definition: MSLane.h:516
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:1157
virtual bool appropriate(const MSVehicle *veh) const
Definition: MSLane.cpp:2290
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:3498
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:622
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:707
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:471
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:330
int getRightmostSublane() const
Definition: MSLane.h:1171
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:3131
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1501
friend class AnyVehicleIterator
Definition: MSLane.h:116
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:3455
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:551
void setFrictionCoefficient(double val)
Sets a new friction coefficient for the lane [to be later (used by TraCI and MSCalibrator)].
Definition: MSLane.cpp:2516
static CollisionAction getCollisionAction()
Definition: MSLane.h:1325
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:144
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!)
Definition: MSQueueExport.h:47
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.
Definition: OutputDevice.h:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
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