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.org/sumo
3// Copyright (C) 2001-2022 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 getAngleOffset() const;
472
474 inline bool alreadyChanged() const {
475 return myAlreadyChanged;
476 }
477
480 myAlreadyChanged = false;
481 }
482
484 bool startLaneChangeManeuver(MSLane* source, MSLane* target, int direction);
485
488 void clearGapsAtLCInit();
489
490 /* @brief continue the lane change maneuver and return whether the midpoint
491 * was passed in this step
492 */
493 bool updateCompletion();
494
495 /* @brief update lane change shadow after the vehicle moved to a new lane */
496 void updateShadowLane();
497
498 /* @brief update lane change reservations after the vehicle moved to a new lane
499 * @note The shadow lane should always be updated before updating the target lane. */
501
502 /* @brief Determines the lane which the vehicle intends to enter during its current action step.
503 * targetDir is set to the offset of the returned lane with respect to the vehicle'a current lane. */
504 MSLane* determineTargetLane(int& targetDir) const;
505
506 /* @brief finish the lane change maneuver
507 */
509
510 /* @brief clean up all references to the shadow vehicle
511 */
512 void cleanupShadowLane();
513
514 /* @brief clean up all references to the vehicle on its target lanes
515 */
516 void cleanupTargetLane();
517
519 virtual bool saveBlockerLength(double /* length */, double /* foeLeftSpace */) {
520 return true;
521 }
522
524 myPartiallyOccupatedByShadow.push_back(lane);
525 }
526
528 myNoPartiallyOccupatedByShadow.push_back(lane);
529 }
530
532 void primaryLaneChanged(MSLane* source, MSLane* target, int direction);
533
535 void laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist = 0);
536
538 virtual bool sublaneChangeCompleted(const double latDist) const {
539 UNUSED_PARAMETER(latDist);
540 throw ProcessError("Method not implemented by model " + toString(myModel));
541 }
542
544 void setShadowApproachingInformation(MSLink* link) const;
546
547 bool isOpposite() const {
548 return myAmOpposite;
549 }
550
553
554 double getCommittedSpeed() const {
555 return myCommittedSpeed;
556 }
557
559 double getSpeedLat() const {
560 return mySpeedLat;
561 }
562
564 double getAccelerationLat() const {
565 return myAccelerationLat;
566 }
567
569 void setSpeedLat(double speedLat);
570
573 virtual double computeSpeedLat(double latDist, double& maneuverDist, bool urgent) const;
574
577 virtual double getAssumedDecelForLaneChangeDuration() const;
578
580 virtual std::string getParameter(const std::string& key) const {
581 throw InvalidArgument("Parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
582 }
583
585 virtual void setParameter(const std::string& key, const std::string& value) {
586 UNUSED_PARAMETER(value);
587 throw InvalidArgument("Setting parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
588 }
589
591 virtual double getExtraReservation(int /*bestLaneOffset*/) const {
592 return 0;
593 }
594
597 void checkTraCICommands();
598
600 double getForwardPos() const;
601
602 bool hasBlueLight() const {
603 return myHaveBlueLight;
604 }
605
606 static const double NO_NEIGHBOR;
607
608protected:
609 virtual bool congested(const MSVehicle* const neighLeader);
610
611 virtual bool predInteraction(const std::pair<MSVehicle*, double>& leader);
612
613 virtual bool avoidOvertakeRight() const;
614
616 bool cancelRequest(int state, int laneOffset);
617
619 double getMaxSpeedLat2() const;
620
621protected:
624
631
632 std::pair<int, int> mySavedStateRight;
633 std::pair<int, int> mySavedStateCenter;
634 std::pair<int, int> mySavedStateLeft;
638
641 std::shared_ptr<MSLeaderDistanceInfo> myLeftFollowers;
642 std::shared_ptr<MSLeaderDistanceInfo> myLeftLeaders;
643 std::shared_ptr<MSLeaderDistanceInfo> myRightFollowers;
644 std::shared_ptr<MSLeaderDistanceInfo> myRightLeaders;
646
649
652
655
658
661
664
667 /* @brief Lanes that are partially (laterally) occupied by the back of the
668 * vehicle (analogue to MSVehicle::myFurtherLanes) */
669 std::vector<MSLane*> myShadowFurtherLanes;
670 std::vector<double> myShadowFurtherLanesPosLat;
671
672
681
682 /* @brief Further upstream lanes that are affected by the vehicle's maneuver (analogue to MSVehicle::myFurtherLanes)
683 * @note If myTargetLane==nullptr, we may assume myFurtherTargetLanes.size()==0, otherwise we have
684 * myFurtherTargetLanes.size() == myVehicle.getFurtherLanes.size()
685 * Here it may occur that an element myFurtherTargetLanes[i]==nullptr if myFurtherLanes[i] has
686 * no parallel lane in the change direction.
687 * */
688 std::vector<MSLane*> myFurtherTargetLanes;
689
691 inline const MSCFModel& getCarFollowModel() const {
693 }
694
697
699 std::vector<MSLane*> myPartiallyOccupatedByShadow;
700
701 /* @brief list of lanes where there is no shadow vehicle partial occupator
702 * (when changing to a lane that has no predecessor) */
703 std::vector<MSLane*> myNoPartiallyOccupatedByShadow;
704
708
722
726
727 // @brief the maximum lateral speed for non-strategic changes when standing
729 // @brief the factor of maximum lateral speed to longitudinal speed for non-strategic changes
731 // @brief the maximum lateral maneuver distance when standing
733 // @brief factor for lane keeping imperfection
734 double mySigma;
735 // allow overtaking right even though it is prohibited
737
740
741 /* @brief to be called by derived classes in their changed() method.
742 * If dir=0 is given, the current value remains unchanged */
743 void initLastLaneChangeOffset(int dir);
744
747
749 static bool myLCOutput;
750 static bool myLCStartedOutput;
751 static bool myLCEndedOutput;
752 static bool myLCXYOutput;
753
754
755private:
756 /* @brief information how long ago the vehicle has performed a lane-change,
757 * sign indicates direction of the last change
758 */
760
762 mutable std::vector<MSLink*> myApproachedByShadow;
763
766
770
773
774
775private:
778};
long long int SUMOTime
Definition: GUI.h:36
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:38
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
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
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.
double myCommittedSpeed
the speed when committing to a change maneuver
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
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...
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 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 during a continuous change maneuver
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...
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:5367
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:966
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