Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSAbstractLaneChangeModel.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/****************************************************************************/
23// Interface for lane-change models
24/****************************************************************************/
25#pragma once
26#include <config.h>
27
28#include <microsim/MSGlobals.h>
30#include <microsim/MSVehicle.h>
31
32
33// ===========================================================================
34// class declarations
35// ===========================================================================
36class MSLane;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
48public:
49
54 public:
60 MSLCMessager(MSVehicle* leader, MSVehicle* neighLead, MSVehicle* neighFollow)
61 : myLeader(leader), myNeighLeader(neighLead),
62 myNeighFollower(neighFollow) { }
63
64
67
68
74 void* informLeader(void* info, MSVehicle* sender) {
75 assert(myLeader != 0);
76 return myLeader->getLaneChangeModel().inform(info, sender);
77 }
78
79
85 void* informNeighLeader(void* info, MSVehicle* sender) {
86 assert(myNeighLeader != 0);
87 return myNeighLeader->getLaneChangeModel().inform(info, sender);
88 }
89
90
96 void* informNeighFollower(void* info, MSVehicle* sender) {
97 assert(myNeighFollower != 0);
98 return myNeighFollower->getLaneChangeModel().inform(info, sender);
99 }
100
101
102 private:
109
110 };
111
113 // @brief LaneChangeAction flags
114 int state;
115 // @brief Lateral distance to be completed in the next step
116 double latDist;
117 // @brief Full lateral distance required for the completion of the envisioned maneuver
119 // @brief direction that was checked
120 int dir;
121
122 StateAndDist(int _state, double _latDist, double _targetDist, int _dir) :
123 state(_state),
124 latDist(_latDist),
125 maneuverDist(_targetDist),
126 dir(_dir) {}
127
128 bool sameDirection(const StateAndDist& other) const {
129 return latDist * other.latDist > 0;
130 }
131 };
132
134 void static initGlobalOptions(const OptionsCont& oc);
135
141
145 virtual LaneChangeModel getModelID() const = 0;
146
155 virtual int checkChangeBeforeCommitting(const MSVehicle* veh, int state) const {
156 UNUSED_PARAMETER(veh);
157 UNUSED_PARAMETER(state);
158 return 0;
159 }
160
164 virtual void saveState(OutputDevice& out) const;
165
169 virtual void loadState(const SUMOSAXAttributes& attrs);
170
172 static bool haveLCOutput() {
173 return myLCOutput;
174 }
175
178 return myLCStartedOutput;
179 }
180
182 static bool enabledOutputLCEnded() {
183 return myLCEndedOutput;
184 }
185
191
194
195 inline int getOwnState() const {
196 return myOwnState;
197 }
198
199 inline int getPrevState() const {
201 return myPreviousState2;
202 }
203
204 virtual void setOwnState(const int state);
205
207 void setManeuverDist(const double dist);
209 double getManeuverDist() const;
210 double getPreviousManeuverDist() const;
211
213 virtual void updateSafeLatDist(const double travelledLatDist);
214
215 const std::pair<int, int>& getSavedState(const int dir) const {
216 if (dir == -1) {
217 return mySavedStateRight;
218 } else if (dir == 0) {
219 return mySavedStateCenter;
220 } else {
221 return mySavedStateLeft;
222 }
223 }
224
225 void saveLCState(const int dir, int stateWithoutTraCI, const int state) {
226 int canceledStrategic = getCanceledState(dir);
227 // avoid conflicting directions
228 if ((canceledStrategic & LCA_WANTS_LANECHANGE_OR_STAY) != 0) {
229 stateWithoutTraCI = canceledStrategic;
230 }
231 const auto pair = std::make_pair(stateWithoutTraCI, state);
232 if (dir == -1) {
233 mySavedStateRight = pair;
234 } else if (dir == 0) {
235 mySavedStateCenter = pair;
236 } else {
237 mySavedStateLeft = pair;
238 }
239 }
240
241 int& getCanceledState(const int dir) {
242 if (dir == -1) {
244 } else if (dir == 0) {
246 } else {
247 return myCanceledStateLeft;
248 }
249 }
250
252 bool isStrategicBlocked() const;
253
254 void setFollowerGaps(CLeaderDist follower, double secGap);
255 void setLeaderGaps(CLeaderDist, double secGap);
256 void setOrigLeaderGaps(CLeaderDist, double secGap);
257 void setFollowerGaps(const MSLeaderDistanceInfo& vehicles);
258 void setLeaderGaps(const MSLeaderDistanceInfo& vehicles);
259 void setOrigLeaderGaps(const MSLeaderDistanceInfo& vehicles);
260
262 virtual void prepareStep(SumoRNG* rng);
263
268 virtual int wantsChange(
269 int laneOffset,
270 MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
271 const std::pair<MSVehicle*, double>& leader,
272 const std::pair<MSVehicle*, double>& follower,
273 const std::pair<MSVehicle*, double>& neighLead,
274 const std::pair<MSVehicle*, double>& neighFollow,
275 const MSLane& neighLane,
276 const std::vector<MSVehicle::LaneQ>& preb,
277 MSVehicle** lastBlocked,
278 MSVehicle** firstBlocked) {
279 UNUSED_PARAMETER(laneOffset);
280 UNUSED_PARAMETER(&msgPass);
281 UNUSED_PARAMETER(blocked);
282 UNUSED_PARAMETER(&leader);
283 UNUSED_PARAMETER(&follower);
284 UNUSED_PARAMETER(&neighLead);
285 UNUSED_PARAMETER(&neighFollow);
286 UNUSED_PARAMETER(&neighLane);
287 UNUSED_PARAMETER(&preb);
288 UNUSED_PARAMETER(lastBlocked);
289 UNUSED_PARAMETER(firstBlocked);
290 throw ProcessError("Method not implemented by model " + toString(myModel));
291 };
292
294 int laneOffset,
295 LaneChangeAction alternatives,
296 const MSLeaderDistanceInfo& leaders,
297 const MSLeaderDistanceInfo& followers,
298 const MSLeaderDistanceInfo& blockers,
299 const MSLeaderDistanceInfo& neighLeaders,
300 const MSLeaderDistanceInfo& neighFollowers,
301 const MSLeaderDistanceInfo& neighBlockers,
302 const MSLane& neighLane,
303 const std::vector<MSVehicle::LaneQ>& preb,
304 MSVehicle** lastBlocked,
305 MSVehicle** firstBlocked,
306 double& latDist, double& targetDistLat, int& blocked) {
307 UNUSED_PARAMETER(laneOffset);
308 UNUSED_PARAMETER(alternatives);
309 UNUSED_PARAMETER(&leaders);
310 UNUSED_PARAMETER(&followers);
311 UNUSED_PARAMETER(&blockers);
312 UNUSED_PARAMETER(&neighLeaders);
313 UNUSED_PARAMETER(&neighFollowers);
314 UNUSED_PARAMETER(&neighBlockers);
315 UNUSED_PARAMETER(&neighLane);
316 UNUSED_PARAMETER(&preb);
317 UNUSED_PARAMETER(lastBlocked);
318 UNUSED_PARAMETER(firstBlocked);
319 UNUSED_PARAMETER(latDist);
320 UNUSED_PARAMETER(targetDistLat);
321 UNUSED_PARAMETER(blocked);
322 throw ProcessError("Method not implemented by model " + toString(myModel));
323 }
324
326 virtual void updateExpectedSublaneSpeeds(const MSLeaderDistanceInfo& ahead, int sublaneOffset, int laneIndex) {
327 UNUSED_PARAMETER(&ahead);
328 UNUSED_PARAMETER(sublaneOffset);
329 UNUSED_PARAMETER(laneIndex);
330 throw ProcessError("Method not implemented by model " + toString(myModel));
331 }
332
335 UNUSED_PARAMETER(sd1);
336 UNUSED_PARAMETER(sd2);
337 throw ProcessError("Method not implemented by model " + toString(myModel));
338 }
339
340 virtual void* inform(void* info, MSVehicle* sender) = 0;
341
355 virtual double patchSpeed(const double min, const double wanted, const double max,
356 const MSCFModel& cfModel) = 0;
357
358 /* @brief called once when the primary lane of the vehicle changes (updates
359 * the custom variables of each child implementation */
360 virtual void changed() = 0;
361
362 /* @brief called once when the vehicle moves to a new lane in an "irregular" way (i.e. by teleporting)
363 * resets custom variables of each child implementation */
364 virtual void resetState() {};
365
367 virtual double getSafetyFactor() const {
368 return 1.0;
369 }
370
372 virtual double getOppositeSafetyFactor() const {
373 return 1.0;
374 }
375
377 virtual bool debugVehicle() const {
378 return false;
379 }
380
382 void changedToOpposite();
383
384 void unchanged() {
385 if (myLastLaneChangeOffset > 0) {
387 } else if (myLastLaneChangeOffset < 0) {
389 }
390 }
391
396 return myShadowLane;
397 }
398
400 MSLane* getShadowLane(const MSLane* lane) const;
401
403 MSLane* getShadowLane(const MSLane* lane, double posLat) const;
404
405 const std::vector<MSLane*>& getShadowFurtherLanes() const {
407 }
408
409 const std::vector<double>& getShadowFurtherLanesPosLat() const {
411 }
412
417 return myTargetLane;
418 }
419
420 const std::vector<MSLane*>& getFurtherTargetLanes() const {
422 }
423
426 }
427
428
430 inline bool pastMidpoint() const {
431 return myLaneChangeCompletion >= 0.5;
432 }
433
435 SUMOTime remainingTime() const;
436
448 virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel, bool urgent) const;
449
451 inline bool isChangingLanes() const {
452 return myLaneChangeCompletion < (1 - NUMERICAL_EPS);
453 }
454
456 inline double getLaneChangeCompletion() const {
458 }
459
461 inline int getLaneChangeDirection() const {
463 }
464
466 int getShadowDirection() const;
467
469 double calcAngleOffset();
470
472 inline double getAngleOffset() const {
473 return myAngleOffset;
474 }
475
477 inline void setAngleOffset(const double angleOffset) {
478 myAngleOffset = angleOffset;
479 }
480
482 inline void setPreviousAngleOffset(const double angleOffset) {
483 myPreviousAngleOffset = angleOffset;
484 }
485
487 inline bool alreadyChanged() const {
488 return myAlreadyChanged;
489 }
490
493 myAlreadyChanged = false;
494 }
495
497 bool startLaneChangeManeuver(MSLane* source, MSLane* target, int direction);
498
501 void clearGapsAtLCInit();
502
503 /* @brief continue the lane change maneuver and return whether the midpoint
504 * was passed in this step
505 */
506 bool updateCompletion();
507
508 /* @brief update lane change shadow after the vehicle moved to a new lane */
509 void updateShadowLane();
510
511 /* @brief update lane change reservations after the vehicle moved to a new lane
512 * @note The shadow lane should always be updated before updating the target lane. */
514
515 /* @brief Determines the lane which the vehicle intends to enter during its current action step.
516 * targetDir is set to the offset of the returned lane with respect to the vehicle'a current lane. */
517 MSLane* determineTargetLane(int& targetDir) const;
518
519 /* @brief finish the lane change maneuver
520 */
522
523 /* @brief clean up all references to the shadow vehicle
524 */
525 void cleanupShadowLane();
526
527 /* @brief clean up all references to the vehicle on its target lanes
528 */
529 void cleanupTargetLane();
530
532 virtual bool saveBlockerLength(double /* length */, double /* foeLeftSpace */) {
533 return true;
534 }
535
537 myPartiallyOccupatedByShadow.push_back(lane);
538 }
539
541 myNoPartiallyOccupatedByShadow.push_back(lane);
542 }
543
545 void primaryLaneChanged(MSLane* source, MSLane* target, int direction);
546
548 void laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist = 0);
549
551 virtual bool sublaneChangeCompleted(const double latDist) const {
552 UNUSED_PARAMETER(latDist);
553 throw ProcessError("Method not implemented by model " + toString(myModel));
554 }
555
557 void setShadowApproachingInformation(MSLink* link) const;
559
560 bool isOpposite() const {
561 return myAmOpposite;
562 }
563
566
567 double getCommittedSpeed() const {
568 return myCommittedSpeed;
569 }
570
572 double getSpeedLat() const {
573 return mySpeedLat;
574 }
575
576 /* @brief reset the angle (in case no lane changing happens in this step
577 * and the maneuver was finished in the previous step) */
578 virtual void resetSpeedLat();
579
581 double getAccelerationLat() const {
582 return myAccelerationLat;
583 }
584
585 double getStrategicLookahead() const {
587 }
588
590 void setSpeedLat(double speedLat);
591
594 virtual double computeSpeedLat(double latDist, double& maneuverDist, bool urgent) const;
595
598 virtual double getAssumedDecelForLaneChangeDuration() const;
599
601 virtual std::string getParameter(const std::string& key) const {
602 throw InvalidArgument("Parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
603 }
604
606 virtual void setParameter(const std::string& key, const std::string& value) {
607 UNUSED_PARAMETER(value);
608 throw InvalidArgument("Setting parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
609 }
610
611 /* @brief reserve extra space for unseen blockers when more than one lane change is required
612 * @param[in] bestLaneOffset The offset to the best lane
613 * @param[in] neighExtraDist the additional distance that can be driven on the neighboring lane (after a single lane change)
614 */
615 virtual double getExtraReservation(int bestLaneOffset, double neighExtraDist = 0) const;
616
619 void checkTraCICommands();
620
622 double getForwardPos() const;
623
624 bool hasBlueLight() const {
625 return myHaveBlueLight;
626 }
627
631
633 double getCooperativeHelpSpeed(const MSLane* lane, double distToLaneEnd) const;
634
640 }
641 double getCooperativeMinSpeed() const {
643 }
644
645 static const double NO_NEIGHBOR;
646 static const double UNDEFINED_LOOKAHEAD;
647
648 virtual bool avoidOvertakeRight(const MSVehicle* const neighLeader, const bool allowProb=false) const;
649
650protected:
651 virtual bool congested(const MSVehicle* const neighLeader);
652
653 virtual bool predInteraction(const std::pair<MSVehicle*, double>& leader);
654
656 bool cancelRequest(int state, int laneOffset);
657
659 double getMaxSpeedLat2() const;
660
667 void addLCSpeedAdvice(const double vSafe, int flag);
668
669 bool canOvertakeRight(const MSVehicle* const nv, const double dist, const double maxSpeedDiff, const double helpOvertakeSpeed, double& vSafe, double& deltaV) const;
670
671protected:
674
681
682 std::pair<int, int> mySavedStateRight;
683 std::pair<int, int> mySavedStateCenter;
684 std::pair<int, int> mySavedStateLeft;
688
691
694
697
700
703
706
709
712
715 /* @brief Lanes that are partially (laterally) occupied by the back of the
716 * vehicle (analogue to MSVehicle::myFurtherLanes) */
717 std::vector<MSLane*> myShadowFurtherLanes;
718 std::vector<double> myShadowFurtherLanesPosLat;
719
720
729
730 /* @brief Further upstream lanes that are affected by the vehicle's maneuver (analogue to MSVehicle::myFurtherLanes)
731 * @note If myTargetLane==nullptr, we may assume myFurtherTargetLanes.size()==0, otherwise we have
732 * myFurtherTargetLanes.size() == myVehicle.getFurtherLanes.size()
733 * Here it may occur that an element myFurtherTargetLanes[i]==nullptr if myFurtherLanes[i] has
734 * no parallel lane in the change direction.
735 * */
736 std::vector<MSLane*> myFurtherTargetLanes;
737
739 inline const MSCFModel& getCarFollowModel() const {
741 }
742
745
747 std::vector<MSLane*> myPartiallyOccupatedByShadow;
748
749 /* @brief list of lanes where there is no shadow vehicle partial occupator
750 * (when changing to a lane that has no predecessor) */
751 std::vector<MSLane*> myNoPartiallyOccupatedByShadow;
752
756
770
774
776 // @brief the maximum lateral speed for non-strategic changes when standing
778 // @brief the factor of maximum lateral speed to longitudinal speed for non-strategic changes
780 // @brief the maximum lateral maneuver distance when standing
782 // @brief factor for lane keeping imperfection
783 double mySigma;
784 // allow overtaking right even though it is prohibited
786 // @brief willingness to undercut longitudinal safe gaps
788 // @brief brake for blocked vehicles after they have been waiting for the given time
790 // @brief adjust speed cooperatively for vehicles that are not much slower and that are not currently blocked longer than myCooperativeHelpTime
792 // @brief adjust speed cooperatively unless the ego speed would drop below the given relative speed
794
797
798 /* @brief to be called by derived classes in their changed() method.
799 * If dir=0 is given, the current value remains unchanged */
800 void initLastLaneChangeOffset(int dir);
801
802 /* @brief vector of LC-related acceleration recommendations combined with a
803 * bitset to indicate who the advice came from and to which direction it applies
804 * Filled in wantsChange() and applied in patchSpeed() */
805 std::vector<std::pair<double, int> > myLCAccelerationAdvices;
806
809
811 static bool myLCOutput;
812 static bool myLCStartedOutput;
813 static bool myLCEndedOutput;
814 static bool myLCXYOutput;
815
816
817private:
818 /* @brief information how long ago the vehicle has performed a lane-change,
819 * sign indicates direction of the last change
820 */
822
824 mutable std::vector<MSLink*> myApproachedByShadow;
825
828
832
835
836
837private:
840};
long long int SUMOTime
Definition GUI.h:36
std::pair< const MSVehicle *, double > CLeaderDist
SUMOTime DELTA_T
Definition SUMOTime.cpp:39
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
LaneChangeAction
The state of a vehicle's lane-change behavior.
@ LCA_WANTS_LANECHANGE_OR_STAY
lane can change or stay
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
A class responsible for exchanging messages between cars involved in lane-change interaction.
MSVehicle * myNeighFollower
The follower on the lane the vehicle want to change to.
MSLCMessager(MSVehicle *leader, MSVehicle *neighLead, MSVehicle *neighFollow)
Constructor.
MSVehicle * myNeighLeader
The leader on the lane the vehicle want to change to.
void * informLeader(void *info, MSVehicle *sender)
Informs the leader on the same lane.
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
MSVehicle * myLeader
The leader on the informed vehicle's lane.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
Interface for lane-change models.
double getLaneChangeCompletion() const
Get the current lane change completion ratio.
double getForwardPos() const
get vehicle position relative to the forward direction lane
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key
double myAccelerationLat
the current lateral acceleration
void setFollowerGaps(CLeaderDist follower, double secGap)
virtual double getExtraReservation(int bestLaneOffset, double neighExtraDist=0) const
std::vector< MSLane * > myFurtherTargetLanes
MSAbstractLaneChangeModel & operator=(const MSAbstractLaneChangeModel &s)
Invalidated assignment operator.
bool myAlreadyChanged
whether the vehicle has already moved this step
bool myAmOpposite
whether the vehicle is driving in the opposite direction
void addLCSpeedAdvice(const double vSafe, int flag)
Takes a vSafe (speed advice for speed in the next simulation step), converts it into an acceleration ...
std::pair< int, int > mySavedStateCenter
std::vector< std::pair< double, int > > myLCAccelerationAdvices
virtual void setOwnState(const int state)
bool pastMidpoint() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver
const std::vector< double > & getShadowFurtherLanesPosLat() const
double myPreviousAngleOffset
the angle offset of the previous time step resulting from lane change and sigma
virtual double getAssumedDecelForLaneChangeDuration() const
Returns a deceleration value which is used for the estimation of the duration of a lane change.
virtual double computeSpeedLat(double latDist, double &maneuverDist, bool urgent) const
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel, bool urgent) const
Calculates the maximal time needed to complete a lane change maneuver if lcMaxSpeedLatFactor and lcMa...
int myPreviousState
lane changing state from the previous simulation step
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
int getLaneChangeDirection() const
return the direction of the current lane change maneuver
int myOwnState
The current state of the vehicle.
double myLastOrigLeaderGap
acutal and secure distance to closest leader vehicle on the original when performing lane change
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
void laneChangeOutput(const std::string &tag, MSLane *source, MSLane *target, int direction, double maneuverDist=0)
called once the vehicle ends a lane change manoeuvre (non-instant)
bool myDontResetLCGaps
Flag to prevent resetting the memorized values for LC relevant gaps until the LC output is triggered ...
void resetChanged()
reset the flag whether a vehicle already moved to false
int myPreviousState2
lane changing state from step before the previous simulation step
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
void setAngleOffset(const double angleOffset)
set the angle offset resulting from lane change and sigma
double myCommittedSpeed
the speed when committing to a change maneuver
virtual LatAlignmentDefinition getDesiredAlignment() const
static bool myLCOutput
whether to record lane-changing
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
virtual void saveState(OutputDevice &out) const
Save the state of the laneChangeModel.
std::pair< int, int > mySavedStateRight
std::vector< MSLane * > myPartiallyOccupatedByShadow
list of lanes where the shadow vehicle is partial occupator
double myLastLeaderSecureGap
the minimum longitudinal distances to vehicles on the target lane that would be necessary for stringe...
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
virtual double getSafetyFactor() const
return factor for modifying the safety constraints of the car-following model
void saveLCState(const int dir, int stateWithoutTraCI, const int state)
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
bool myHaveBlueLight
whether this vehicle is driving with special permissions and behavior
virtual bool saveBlockerLength(double, double)
reserve space at the end of the lane to avoid dead locks
std::vector< MSLink * > myApproachedByShadow
links which are approached by the shadow vehicle
static bool haveLCOutput()
whether lanechange-output is active
virtual void updateExpectedSublaneSpeeds(const MSLeaderDistanceInfo &ahead, int sublaneOffset, int laneIndex)
update expected speeds for each sublane of the current edge
bool canOvertakeRight(const MSVehicle *const nv, const double dist, const double maxSpeedDiff, const double helpOvertakeSpeed, double &vSafe, double &deltaV) const
virtual int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, const std::pair< MSVehicle *, double > &follower, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &neighFollow, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked)
Called to examine whether the vehicle wants to change using the given laneOffset. This method gets th...
virtual double getOppositeSafetyFactor() const
return factor for modifying the safety constraints for opposite-diretction overtaking of the car-foll...
void setLeaderGaps(CLeaderDist, double secGap)
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
static bool enabledOutputLCStarted()
whether start of maneuvers shall be recorede
const std::pair< int, int > & getSavedState(const int dir) const
void setNoShadowPartialOccupator(MSLane *lane)
const LaneChangeModel myModel
the type of this model
MSLane * getTargetLane() const
Returns the lane the vehicle has committed to enter during a sublane lane change.
bool cancelRequest(int state, int laneOffset)
whether the influencer cancels the given request
double myLastLeaderGap
the actual minimum longitudinal distances to vehicles on the target lane
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
virtual LaneChangeModel getModelID() const =0
Returns the model's ID;.
double getAccelerationLat() const
return the lateral speed of the current lane change maneuver
void setOrigLeaderGaps(CLeaderDist, double secGap)
virtual int wantsChangeSublane(int laneOffset, LaneChangeAction alternatives, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked, double &latDist, double &targetDistLat, int &blocked)
void setManeuverDist(const double dist)
Updates the remaining distance for the current maneuver while it is continued within non-action steps...
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
double getCooperativeHelpSpeed(const MSLane *lane, double distToLaneEnd) const
return speed for helping a vehicle that is blocked from changing
virtual bool avoidOvertakeRight(const MSVehicle *const neighLeader, const bool allowProb=false) const
int getNormalizedLaneIndex()
brief return lane index that treats opposite lanes like normal lanes to the left of the forward lanes
virtual int checkChangeBeforeCommitting(const MSVehicle *veh, int state) const
Informs the vehicle that it is about to be moved on an adjacent lane. The method can be used to re-ev...
virtual double patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)=0
Called to adapt the speed in order to allow a lane change. It uses information on LC-related desired ...
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
void setSpeedLat(double speedLat)
set the lateral speed and update lateral acceleraton
MSLane * myTargetLane
The target lane for the vehicle's current maneuver.
MSLane * determineTargetLane(int &targetDir) const
double myPreviousManeuverDist
Maneuver distance from the previous simulation step.
double getMaxSpeedLat2() const
return the max of maxSpeedLat and lcMaxSpeedLatStanding
std::vector< double > myShadowFurtherLanesPosLat
const MSCFModel & getCarFollowModel() const
The vehicle's car following model.
static bool enabledOutputLCEnded()
whether start of maneuvers shall be recorede
MSLane * myShadowLane
A lane that is partially occupied by the front of the vehicle but that is not the primary lane.
double mySpeedLat
the current lateral speed
virtual void updateSafeLatDist(const double travelledLatDist)
Updates the value of safe lateral distances (in SL2015) during maneuver continuation in non-action st...
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
double myManeuverDist
The complete lateral distance the vehicle wants to travel to finish its maneuver Only used by sublane...
int myLaneChangeDirection
direction of the lane change maneuver -1 means right, 1 means left
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
int getShadowDirection() const
return the direction in which the current shadow lane lies
double myLastLeaderSpeed
speeds of surrounding vehicles at the time of lane change
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the laneChangeModel from the given attributes.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
double calcAngleOffset()
return the angle offset during a continuous change maneuver
void setPreviousAngleOffset(const double angleOffset)
set the angle offset of the previous time step
double myAngleOffset
the current angle offset resulting from lane change and sigma
double myLastLateralGapLeft
the minimum lateral gaps to other vehicles that were found when last changing to the left and right
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
const std::vector< MSLane * > & getFurtherTargetLanes() const
virtual ~MSAbstractLaneChangeModel()
Destructor.
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
virtual bool sublaneChangeCompleted(const double latDist) const
whether the current change completes the manoeuvre
bool alreadyChanged() const
reset the flag whether a vehicle already moved to false
virtual StateAndDist decideDirection(StateAndDist sd1, StateAndDist sd2) const
decide in which direction to move in case both directions are desirable
double getAngleOffset() const
return the angle offset resulting from lane change and sigma
virtual void prepareStep(SumoRNG *rng)
rng belongs to the lane that moves the vehicle (not the lane it just entered)
virtual void * inform(void *info, MSVehicle *sender)=0
void memorizeGapsAtLCInit()
Control for resetting the memorized values for LC relevant gaps until the LC output is triggered in t...
const std::vector< MSLane * > & getShadowFurtherLanes() const
double myLaneChangeCompletion
progress of the lane change maneuver 0:started, 1:complete
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
virtual void changed()=0
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
std::vector< MSLane * > myShadowFurtherLanes
virtual bool congested(const MSVehicle *const neighLeader)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
The car-following model abstraction.
Definition MSCFModel.h:59
Representation of a lane in the micro simulation.
Definition MSLane.h:84
saves leader/follower vehicles and their distances relative to an ego vehicle
Notification
Definition of a vehicle state.
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
MSAbstractLaneChangeModel & getLaneChangeModel()
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition MSVehicle.h:973
const LatAlignmentDefinition & getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment procedure.
A storage for options typed value containers)
Definition OptionsCont.h:92
Static storage of an output device and its base (abstract) implementation.
Encapsulated SAX-Attributes.
#define UNUSED_PARAMETER(x)
StateAndDist(int _state, double _latDist, double _targetDist, int _dir)
bool sameDirection(const StateAndDist &other) const