Eclipse SUMO - Simulation of Urban MObility
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-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/****************************************************************************/
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
150 virtual void saveState(OutputDevice& out) const;
151
155 virtual void loadState(const SUMOSAXAttributes& attrs);
156
158 static bool haveLCOutput() {
159 return myLCOutput;
160 }
161
163 static bool outputLCStarted() {
164 return myLCStartedOutput;
165 }
166
168 static bool outputLCEnded() {
169 return myLCEndedOutput;
170 }
171
177
180
181 inline int getOwnState() const {
182 return myOwnState;
183 }
184
185 inline int getPrevState() const {
187 return myPreviousState2;
188 }
189
190 virtual void setOwnState(const int state);
191
193 void setManeuverDist(const double dist);
195 double getManeuverDist() const;
196 double getPreviousManeuverDist() const;
197
199 virtual void updateSafeLatDist(const double travelledLatDist);
200
201 const std::pair<int, int>& getSavedState(const int dir) const {
202 if (dir == -1) {
203 return mySavedStateRight;
204 } else if (dir == 0) {
205 return mySavedStateCenter;
206 } else {
207 return mySavedStateLeft;
208 }
209 }
210
211 void saveLCState(const int dir, int stateWithoutTraCI, const int state) {
212 int canceledStrategic = getCanceledState(dir);
213 // avoid conflicting directions
214 if ((canceledStrategic & LCA_WANTS_LANECHANGE_OR_STAY) != 0) {
215 stateWithoutTraCI = canceledStrategic;
216 }
217 const auto pair = std::make_pair(stateWithoutTraCI, state);
218 if (dir == -1) {
219 mySavedStateRight = pair;
220 } else if (dir == 0) {
221 mySavedStateCenter = pair;
222 } else {
223 mySavedStateLeft = pair;
224 }
225 }
226
229 void saveNeighbors(const int dir, const MSLeaderDistanceInfo& followers, const MSLeaderDistanceInfo& leaders);
230
233 void saveNeighbors(const int dir, const std::pair<MSVehicle* const, double>& follower, const std::pair<MSVehicle* const, double>& leader);
234
236 void clearNeighbors();
237
239 const std::shared_ptr<MSLeaderDistanceInfo> getFollowers(const int dir);
240
242 const std::shared_ptr<MSLeaderDistanceInfo> getLeaders(const int dir);
243
244 int& getCanceledState(const int dir) {
245 if (dir == -1) {
247 } else if (dir == 0) {
249 } else {
250 return myCanceledStateLeft;
251 }
252 }
253
255 bool isStrategicBlocked() const;
256
257 void setFollowerGaps(CLeaderDist follower, double secGap);
258 void setLeaderGaps(CLeaderDist, double secGap);
259 void setOrigLeaderGaps(CLeaderDist, double secGap);
260 void setFollowerGaps(const MSLeaderDistanceInfo& vehicles);
261 void setLeaderGaps(const MSLeaderDistanceInfo& vehicles);
262 void setOrigLeaderGaps(const MSLeaderDistanceInfo& vehicles);
263
264 virtual void prepareStep();
265
270 virtual int wantsChange(
271 int laneOffset,
272 MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
273 const std::pair<MSVehicle*, double>& leader,
274 const std::pair<MSVehicle*, double>& follower,
275 const std::pair<MSVehicle*, double>& neighLead,
276 const std::pair<MSVehicle*, double>& neighFollow,
277 const MSLane& neighLane,
278 const std::vector<MSVehicle::LaneQ>& preb,
279 MSVehicle** lastBlocked,
280 MSVehicle** firstBlocked) {
281 UNUSED_PARAMETER(laneOffset);
282 UNUSED_PARAMETER(&msgPass);
283 UNUSED_PARAMETER(blocked);
284 UNUSED_PARAMETER(&leader);
285 UNUSED_PARAMETER(&follower);
286 UNUSED_PARAMETER(&neighLead);
287 UNUSED_PARAMETER(&neighFollow);
288 UNUSED_PARAMETER(&neighLane);
289 UNUSED_PARAMETER(&preb);
290 UNUSED_PARAMETER(lastBlocked);
291 UNUSED_PARAMETER(firstBlocked);
292 throw ProcessError("Method not implemented by model " + toString(myModel));
293 };
294
296 int laneOffset,
297 LaneChangeAction alternatives,
298 const MSLeaderDistanceInfo& leaders,
299 const MSLeaderDistanceInfo& followers,
300 const MSLeaderDistanceInfo& blockers,
301 const MSLeaderDistanceInfo& neighLeaders,
302 const MSLeaderDistanceInfo& neighFollowers,
303 const MSLeaderDistanceInfo& neighBlockers,
304 const MSLane& neighLane,
305 const std::vector<MSVehicle::LaneQ>& preb,
306 MSVehicle** lastBlocked,
307 MSVehicle** firstBlocked,
308 double& latDist, double& targetDistLat, int& blocked) {
309 UNUSED_PARAMETER(laneOffset);
310 UNUSED_PARAMETER(alternatives);
311 UNUSED_PARAMETER(&leaders);
312 UNUSED_PARAMETER(&followers);
313 UNUSED_PARAMETER(&blockers);
314 UNUSED_PARAMETER(&neighLeaders);
315 UNUSED_PARAMETER(&neighFollowers);
316 UNUSED_PARAMETER(&neighBlockers);
317 UNUSED_PARAMETER(&neighLane);
318 UNUSED_PARAMETER(&preb);
319 UNUSED_PARAMETER(lastBlocked);
320 UNUSED_PARAMETER(firstBlocked);
321 UNUSED_PARAMETER(latDist);
322 UNUSED_PARAMETER(targetDistLat);
323 UNUSED_PARAMETER(blocked);
324 throw ProcessError("Method not implemented by model " + toString(myModel));
325 }
326
328 virtual void updateExpectedSublaneSpeeds(const MSLeaderDistanceInfo& ahead, int sublaneOffset, int laneIndex) {
329 UNUSED_PARAMETER(&ahead);
330 UNUSED_PARAMETER(sublaneOffset);
331 UNUSED_PARAMETER(laneIndex);
332 throw ProcessError("Method not implemented by model " + toString(myModel));
333 }
334
337 UNUSED_PARAMETER(sd1);
338 UNUSED_PARAMETER(sd2);
339 throw ProcessError("Method not implemented by model " + toString(myModel));
340 }
341
342 virtual void* inform(void* info, MSVehicle* sender) = 0;
343
357 virtual double patchSpeed(const double min, const double wanted, const double max,
358 const MSCFModel& cfModel) = 0;
359
360 /* @brief called once when the primary lane of the vehicle changes (updates
361 * the custom variables of each child implementation */
362 virtual void changed() = 0;
363
364 /* @brief called once when the vehicle moves to a new lane in an "irregular" way (i.e. by teleporting)
365 * resets custom variables of each child implementation */
366 virtual void resetState() {};
367
369 virtual double getSafetyFactor() const {
370 return 1.0;
371 }
372
374 virtual double getOppositeSafetyFactor() const {
375 return 1.0;
376 }
377
379 virtual bool debugVehicle() const {
380 return false;
381 }
382
384 void changedToOpposite();
385
386 void unchanged() {
387 if (myLastLaneChangeOffset > 0) {
389 } else if (myLastLaneChangeOffset < 0) {
391 }
392 }
393
398 return myShadowLane;
399 }
400
402 MSLane* getShadowLane(const MSLane* lane) const;
403
405 MSLane* getShadowLane(const MSLane* lane, double posLat) const;
406
407 const std::vector<MSLane*>& getShadowFurtherLanes() const {
409 }
410
411 const std::vector<double>& getShadowFurtherLanesPosLat() const {
413 }
414
419 return myTargetLane;
420 }
421
422 const std::vector<MSLane*>& getFurtherTargetLanes() const {
424 }
425
428 }
429
430
432 inline bool pastMidpoint() const {
433 return myLaneChangeCompletion >= 0.5;
434 }
435
437 SUMOTime remainingTime() const;
438
450 virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel, bool urgent) const;
451
453 inline bool isChangingLanes() const {
454 return myLaneChangeCompletion < (1 - NUMERICAL_EPS);
455 }
456
458 inline double getLaneChangeCompletion() const {
460 }
461
463 inline int getLaneChangeDirection() const {
465 }
466
468 int getShadowDirection() const;
469
471 double calcAngleOffset();
472
474 inline double getAngleOffset() const {
475 return myAngleOffset;
476 }
477
479 inline void setAngleOffset(const double angleOffset) {
480 myAngleOffset = angleOffset;
481 }
482
484 inline void setPreviousAngleOffset(const double angleOffset) {
485 myPreviousAngleOffset = angleOffset;
486 }
487
489 inline bool alreadyChanged() const {
490 return myAlreadyChanged;
491 }
492
495 myAlreadyChanged = false;
496 }
497
499 bool startLaneChangeManeuver(MSLane* source, MSLane* target, int direction);
500
503 void clearGapsAtLCInit();
504
505 /* @brief continue the lane change maneuver and return whether the midpoint
506 * was passed in this step
507 */
508 bool updateCompletion();
509
510 /* @brief update lane change shadow after the vehicle moved to a new lane */
511 void updateShadowLane();
512
513 /* @brief update lane change reservations after the vehicle moved to a new lane
514 * @note The shadow lane should always be updated before updating the target lane. */
516
517 /* @brief Determines the lane which the vehicle intends to enter during its current action step.
518 * targetDir is set to the offset of the returned lane with respect to the vehicle'a current lane. */
519 MSLane* determineTargetLane(int& targetDir) const;
520
521 /* @brief finish the lane change maneuver
522 */
524
525 /* @brief clean up all references to the shadow vehicle
526 */
527 void cleanupShadowLane();
528
529 /* @brief clean up all references to the vehicle on its target lanes
530 */
531 void cleanupTargetLane();
532
534 virtual bool saveBlockerLength(double /* length */, double /* foeLeftSpace */) {
535 return true;
536 }
537
539 myPartiallyOccupatedByShadow.push_back(lane);
540 }
541
543 myNoPartiallyOccupatedByShadow.push_back(lane);
544 }
545
547 void primaryLaneChanged(MSLane* source, MSLane* target, int direction);
548
550 void laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist = 0);
551
553 virtual bool sublaneChangeCompleted(const double latDist) const {
554 UNUSED_PARAMETER(latDist);
555 throw ProcessError("Method not implemented by model " + toString(myModel));
556 }
557
559 void setShadowApproachingInformation(MSLink* link) const;
561
562 bool isOpposite() const {
563 return myAmOpposite;
564 }
565
568
569 double getCommittedSpeed() const {
570 return myCommittedSpeed;
571 }
572
574 double getSpeedLat() const {
575 return mySpeedLat;
576 }
577
578 /* @brief reset the angle (in case no lane changing happens in this step
579 * and the maneuver was finished in the previous step) */
580 virtual void resetSpeedLat();
581
583 double getAccelerationLat() const {
584 return myAccelerationLat;
585 }
586
588 void setSpeedLat(double speedLat);
589
592 virtual double computeSpeedLat(double latDist, double& maneuverDist, bool urgent) const;
593
596 virtual double getAssumedDecelForLaneChangeDuration() const;
597
599 virtual std::string getParameter(const std::string& key) const {
600 throw InvalidArgument("Parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
601 }
602
604 virtual void setParameter(const std::string& key, const std::string& value) {
605 UNUSED_PARAMETER(value);
606 throw InvalidArgument("Setting parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
607 }
608
610 virtual double getExtraReservation(int /*bestLaneOffset*/) const {
611 return 0;
612 }
613
616 void checkTraCICommands();
617
619 double getForwardPos() const;
620
621 bool hasBlueLight() const {
622 return myHaveBlueLight;
623 }
624
627 }
628
629 static const double NO_NEIGHBOR;
630
631protected:
632 virtual bool congested(const MSVehicle* const neighLeader);
633
634 virtual bool predInteraction(const std::pair<MSVehicle*, double>& leader);
635
636 virtual bool avoidOvertakeRight() const;
637
639 bool cancelRequest(int state, int laneOffset);
640
642 double getMaxSpeedLat2() const;
643
650 void addLCSpeedAdvice(const double vSafe, bool ownAdvice = true);
651
652
653protected:
656
663
664 std::pair<int, int> mySavedStateRight;
665 std::pair<int, int> mySavedStateCenter;
666 std::pair<int, int> mySavedStateLeft;
670
673 std::shared_ptr<MSLeaderDistanceInfo> myLeftFollowers;
674 std::shared_ptr<MSLeaderDistanceInfo> myLeftLeaders;
675 std::shared_ptr<MSLeaderDistanceInfo> myRightFollowers;
676 std::shared_ptr<MSLeaderDistanceInfo> myRightLeaders;
678
681
684
687
690
693
696
699
702
705 /* @brief Lanes that are partially (laterally) occupied by the back of the
706 * vehicle (analogue to MSVehicle::myFurtherLanes) */
707 std::vector<MSLane*> myShadowFurtherLanes;
708 std::vector<double> myShadowFurtherLanesPosLat;
709
710
719
720 /* @brief Further upstream lanes that are affected by the vehicle's maneuver (analogue to MSVehicle::myFurtherLanes)
721 * @note If myTargetLane==nullptr, we may assume myFurtherTargetLanes.size()==0, otherwise we have
722 * myFurtherTargetLanes.size() == myVehicle.getFurtherLanes.size()
723 * Here it may occur that an element myFurtherTargetLanes[i]==nullptr if myFurtherLanes[i] has
724 * no parallel lane in the change direction.
725 * */
726 std::vector<MSLane*> myFurtherTargetLanes;
727
729 inline const MSCFModel& getCarFollowModel() const {
731 }
732
735
737 std::vector<MSLane*> myPartiallyOccupatedByShadow;
738
739 /* @brief list of lanes where there is no shadow vehicle partial occupator
740 * (when changing to a lane that has no predecessor) */
741 std::vector<MSLane*> myNoPartiallyOccupatedByShadow;
742
746
760
764
765 // @brief the maximum lateral speed for non-strategic changes when standing
767 // @brief the factor of maximum lateral speed to longitudinal speed for non-strategic changes
769 // @brief the maximum lateral maneuver distance when standing
771 // @brief factor for lane keeping imperfection
772 double mySigma;
773 // allow overtaking right even though it is prohibited
775
778
779 /* @brief to be called by derived classes in their changed() method.
780 * If dir=0 is given, the current value remains unchanged */
781 void initLastLaneChangeOffset(int dir);
782
783 /* @brief vector of LC-related acceleration recommendations combined with a
784 * boolean to indicate whether the advice is from ego or someone else.
785 * Filled in wantsChange() and applied in patchSpeed() */
786 std::vector<std::pair<double, bool> > myLCAccelerationAdvices;
787
790
792 static bool myLCOutput;
793 static bool myLCStartedOutput;
794 static bool myLCEndedOutput;
795 static bool myLCXYOutput;
796
797
798private:
799 /* @brief information how long ago the vehicle has performed a lane-change,
800 * sign indicates direction of the last change
801 */
803
805 mutable std::vector<MSLink*> myApproachedByShadow;
806
809
813
816
817
818private:
821};
long long int SUMOTime
Definition: GUI.h:36
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:38
SUMOTime DELTA_T
Definition: SUMOTime.cpp:38
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
LaneChangeModel
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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
void setShadowPartialOccupator(MSLane *lane)
double myAccelerationLat
the current lateral acceleration
void setFollowerGaps(CLeaderDist follower, double secGap)
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
std::shared_ptr< MSLeaderDistanceInfo > myRightFollowers
std::pair< int, int > mySavedStateCenter
std::shared_ptr< MSLeaderDistanceInfo > myRightLeaders
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...
std::shared_ptr< MSLeaderDistanceInfo > myLeftLeaders
int myPreviousState
lane changing state from the previous simulation step
static bool outputLCEnded()
whether start of maneuvers shall be recorede
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.
const std::shared_ptr< MSLeaderDistanceInfo > getFollowers(const int dir)
Returns the neighboring, lc-relevant followers for the last step in the requested direction.
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
std::pair< int, int > mySavedStateLeft
std::shared_ptr< MSLeaderDistanceInfo > myLeftFollowers
Cached info on lc-relevant neighboring vehicles.
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 double getExtraReservation(int) const
reserve extra space for unseen blockers when more tnan one lane change is required
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
void addLCSpeedAdvice(const double vSafe, bool ownAdvice=true)
Takes a vSafe (speed advice for speed in the next simulation step), converts it into an acceleration ...
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)
const std::shared_ptr< MSLeaderDistanceInfo > getLeaders(const int dir)
Returns the neighboring, lc-relevant leaders for the last step in the requested direction.
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
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...
std::vector< std::pair< double, bool > > myLCAccelerationAdvices
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
int getNormalizedLaneIndex()
brief return lane index that treats opposite lanes like normal lanes to the left of the forward lanes
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.
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.
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
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 * 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
static bool outputLCStarted()
whether start of maneuvers shall be recorede
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)
void clearNeighbors()
Clear info on neighboring vehicle from previous step.
void saveNeighbors(const int dir, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &leaders)
Saves the lane change relevant vehicles, which are currently on neighboring lanes in the given direct...
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
The car-following model abstraction.
Definition: MSCFModel.h:55
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:144
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()
Definition: MSVehicle.cpp:5620
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:978
const LatAlignmentDefinition & getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment procedure.
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
Encapsulated SAX-Attributes.
StateAndDist(int _state, double _latDist, double _targetDist, int _dir)
bool sameDirection(const StateAndDist &other) const