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>
29 #include <microsim/MSLeaderInfo.h>
30 #include <microsim/MSVehicle.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSLane;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
47 public:
48 
52  class MSLCMessager {
53  public:
59  MSLCMessager(MSVehicle* leader, MSVehicle* neighLead, MSVehicle* neighFollow)
60  : myLeader(leader), myNeighLeader(neighLead),
61  myNeighFollower(neighFollow) { }
62 
63 
66 
67 
73  void* informLeader(void* info, MSVehicle* sender) {
74  assert(myLeader != 0);
75  return myLeader->getLaneChangeModel().inform(info, sender);
76  }
77 
78 
84  void* informNeighLeader(void* info, MSVehicle* sender) {
85  assert(myNeighLeader != 0);
86  return myNeighLeader->getLaneChangeModel().inform(info, sender);
87  }
88 
89 
95  void* informNeighFollower(void* info, MSVehicle* sender) {
96  assert(myNeighFollower != 0);
97  return myNeighFollower->getLaneChangeModel().inform(info, sender);
98  }
99 
100 
101  private:
108 
109  };
110 
111  struct StateAndDist {
112  // @brief LaneChangeAction flags
113  int state;
114  // @brief Lateral distance to be completed in the next step
115  double latDist;
116  // @brief Full lateral distance required for the completion of the envisioned maneuver
117  double maneuverDist;
118  // @brief direction that was checked
119  int dir;
120 
121  StateAndDist(int _state, double _latDist, double _targetDist, int _dir) :
122  state(_state),
123  latDist(_latDist),
124  maneuverDist(_targetDist),
125  dir(_dir) {}
126 
127  bool sameDirection(const StateAndDist& other) const {
128  return latDist * other.latDist > 0;
129  }
130  };
131 
133  void static initGlobalOptions(const OptionsCont& oc);
134 
140 
144  virtual LaneChangeModel getModelID() const = 0;
145 
147  static bool haveLCOutput() {
148  return myLCOutput;
149  }
150 
152  static bool outputLCStarted() {
153  return myLCStartedOutput;
154  }
155 
157  static bool outputLCEnded() {
158  return myLCEndedOutput;
159  }
160 
166 
168  virtual ~MSAbstractLaneChangeModel();
169 
170  inline int getOwnState() const {
171  return myOwnState;
172  }
173 
174  inline int getPrevState() const {
176  return myPreviousState2;
177  }
178 
179  virtual void setOwnState(const int state);
180 
182  void setManeuverDist(const double dist);
184  double getManeuverDist() const;
185  double getPreviousManeuverDist() const;
186 
188  virtual void updateSafeLatDist(const double travelledLatDist);
189 
190  const std::pair<int, int>& getSavedState(const int dir) const {
191  if (dir == -1) {
192  return mySavedStateRight;
193  } else if (dir == 0) {
194  return mySavedStateCenter;
195  } else {
196  return mySavedStateLeft;
197  }
198  }
199 
200  void saveLCState(const int dir, const int stateWithoutTraCI, const int state) {
201  const auto pair = std::make_pair(stateWithoutTraCI | getCanceledState(dir), state);
202  if (dir == -1) {
203  mySavedStateRight = pair;
204  } else if (dir == 0) {
205  mySavedStateCenter = pair;
206  } else {
207  mySavedStateLeft = pair;
208  }
209  }
210 
213  void saveNeighbors(const int dir, const MSLeaderDistanceInfo& followers, const MSLeaderDistanceInfo& leaders);
214 
217  void saveNeighbors(const int dir, const std::pair<MSVehicle* const, double>& follower, const std::pair<MSVehicle* const, double>& leader);
218 
220  void clearNeighbors();
221 
223  const std::shared_ptr<MSLeaderDistanceInfo> getFollowers(const int dir);
224 
226  const std::shared_ptr<MSLeaderDistanceInfo> getLeaders(const int dir);
227 
228  int& getCanceledState(const int dir) {
229  if (dir == -1) {
230  return myCanceledStateRight;
231  } else if (dir == 0) {
232  return myCanceledStateCenter;
233  } else {
234  return myCanceledStateLeft;
235  }
236  }
237 
239  bool isStrategicBlocked() const;
240 
241  void setFollowerGaps(CLeaderDist follower, double secGap);
242  void setLeaderGaps(CLeaderDist, double secGap);
243  void setOrigLeaderGaps(CLeaderDist, double secGap);
244  void setFollowerGaps(const MSLeaderDistanceInfo& vehicles);
245  void setLeaderGaps(const MSLeaderDistanceInfo& vehicles);
246  void setOrigLeaderGaps(const MSLeaderDistanceInfo& vehicles);
247 
248  virtual void prepareStep();
249 
254  virtual int wantsChange(
255  int laneOffset,
256  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
257  const std::pair<MSVehicle*, double>& leader,
258  const std::pair<MSVehicle*, double>& follower,
259  const std::pair<MSVehicle*, double>& neighLead,
260  const std::pair<MSVehicle*, double>& neighFollow,
261  const MSLane& neighLane,
262  const std::vector<MSVehicle::LaneQ>& preb,
263  MSVehicle** lastBlocked,
264  MSVehicle** firstBlocked) {
265  UNUSED_PARAMETER(laneOffset);
266  UNUSED_PARAMETER(&msgPass);
267  UNUSED_PARAMETER(blocked);
268  UNUSED_PARAMETER(&leader);
269  UNUSED_PARAMETER(&follower);
270  UNUSED_PARAMETER(&neighLead);
271  UNUSED_PARAMETER(&neighFollow);
272  UNUSED_PARAMETER(&neighLane);
273  UNUSED_PARAMETER(&preb);
274  UNUSED_PARAMETER(lastBlocked);
275  UNUSED_PARAMETER(firstBlocked);
276  throw ProcessError("Method not implemented by model " + toString(myModel));
277  };
278 
279  virtual int wantsChangeSublane(
280  int laneOffset,
281  LaneChangeAction alternatives,
282  const MSLeaderDistanceInfo& leaders,
283  const MSLeaderDistanceInfo& followers,
284  const MSLeaderDistanceInfo& blockers,
285  const MSLeaderDistanceInfo& neighLeaders,
286  const MSLeaderDistanceInfo& neighFollowers,
287  const MSLeaderDistanceInfo& neighBlockers,
288  const MSLane& neighLane,
289  const std::vector<MSVehicle::LaneQ>& preb,
290  MSVehicle** lastBlocked,
291  MSVehicle** firstBlocked,
292  double& latDist, double& targetDistLat, int& blocked) {
293  UNUSED_PARAMETER(laneOffset);
294  UNUSED_PARAMETER(alternatives);
295  UNUSED_PARAMETER(&leaders);
296  UNUSED_PARAMETER(&followers);
297  UNUSED_PARAMETER(&blockers);
298  UNUSED_PARAMETER(&neighLeaders);
299  UNUSED_PARAMETER(&neighFollowers);
300  UNUSED_PARAMETER(&neighBlockers);
301  UNUSED_PARAMETER(&neighLane);
302  UNUSED_PARAMETER(&preb);
303  UNUSED_PARAMETER(lastBlocked);
304  UNUSED_PARAMETER(firstBlocked);
305  UNUSED_PARAMETER(latDist);
306  UNUSED_PARAMETER(targetDistLat);
307  UNUSED_PARAMETER(blocked);
308  throw ProcessError("Method not implemented by model " + toString(myModel));
309  }
310 
312  virtual void updateExpectedSublaneSpeeds(const MSLeaderDistanceInfo& ahead, int sublaneOffset, int laneIndex) {
313  UNUSED_PARAMETER(&ahead);
314  UNUSED_PARAMETER(sublaneOffset);
315  UNUSED_PARAMETER(laneIndex);
316  throw ProcessError("Method not implemented by model " + toString(myModel));
317  }
318 
321  UNUSED_PARAMETER(sd1);
322  UNUSED_PARAMETER(sd2);
323  throw ProcessError("Method not implemented by model " + toString(myModel));
324  }
325 
326  virtual void* inform(void* info, MSVehicle* sender) = 0;
327 
341  virtual double patchSpeed(const double min, const double wanted, const double max,
342  const MSCFModel& cfModel) = 0;
343 
344  /* @brief called once when the primary lane of the vehicle changes (updates
345  * the custom variables of each child implementation */
346  virtual void changed() = 0;
347 
348 
350  virtual double getSafetyFactor() const {
351  return 1.0;
352  }
353 
355  virtual double getOppositeSafetyFactor() const {
356  return 1.0;
357  }
358 
360  virtual bool debugVehicle() const {
361  return false;
362  }
363 
365  void changedToOpposite();
366 
367  void unchanged() {
368  if (myLastLaneChangeOffset > 0) {
370  } else if (myLastLaneChangeOffset < 0) {
372  }
373  }
374 
379  return myShadowLane;
380  }
381 
383  MSLane* getShadowLane(const MSLane* lane) const;
384 
386  MSLane* getShadowLane(const MSLane* lane, double posLat) const;
387 
388  const std::vector<MSLane*>& getShadowFurtherLanes() const {
389  return myShadowFurtherLanes;
390  }
391 
392  const std::vector<double>& getShadowFurtherLanesPosLat() const {
394  }
395 
400  return myTargetLane;
401  }
402 
403  const std::vector<MSLane*>& getFurtherTargetLanes() const {
404  return myFurtherTargetLanes;
405  }
406 
408  return myLastLaneChangeOffset;
409  }
410 
411 
413  inline bool pastMidpoint() const {
414  return myLaneChangeCompletion >= 0.5;
415  }
416 
418  SUMOTime remainingTime() const;
419 
431  virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel, bool urgent) const;
432 
434  inline bool isChangingLanes() const {
435  return myLaneChangeCompletion < (1 - NUMERICAL_EPS);
436  }
437 
439  inline double getLaneChangeCompletion() const {
440  return myLaneChangeCompletion;
441  }
442 
444  inline int getLaneChangeDirection() const {
445  return myLaneChangeDirection;
446  }
447 
449  int getShadowDirection() const;
450 
452  double getAngleOffset() const;
453 
455  inline bool alreadyChanged() const {
456  return myAlreadyChanged;
457  }
458 
460  void resetChanged() {
461  myAlreadyChanged = false;
462  }
463 
465  bool startLaneChangeManeuver(MSLane* source, MSLane* target, int direction);
466 
468  void memorizeGapsAtLCInit();
469  void clearGapsAtLCInit();
470 
471  /* @brief continue the lane change maneuver and return whether the midpoint
472  * was passed in this step
473  */
474  bool updateCompletion();
475 
476  /* @brief update lane change shadow after the vehicle moved to a new lane */
477  void updateShadowLane();
478 
479  /* @brief update lane change reservations after the vehicle moved to a new lane
480  * @note The shadow lane should always be updated before updating the target lane. */
482 
483  /* @brief Determines the lane which the vehicle intends to enter during its current action step.
484  * targetDir is set to the offset of the returned lane with respect to the vehicle'a current lane. */
485  MSLane* determineTargetLane(int& targetDir) const;
486 
487  /* @brief finish the lane change maneuver
488  */
490 
491  /* @brief clean up all references to the shadow vehicle
492  */
493  void cleanupShadowLane();
494 
495  /* @brief clean up all references to the vehicle on its target lanes
496  */
497  void cleanupTargetLane();
498 
500  virtual void saveBlockerLength(double length) {
501  UNUSED_PARAMETER(length);
502  }
503 
505  myPartiallyOccupatedByShadow.push_back(lane);
506  }
507 
509  myNoPartiallyOccupatedByShadow.push_back(lane);
510  }
511 
513  void primaryLaneChanged(MSLane* source, MSLane* target, int direction);
514 
516  void laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist = 0);
517 
519  virtual bool sublaneChangeCompleted(const double latDist) const {
520  UNUSED_PARAMETER(latDist);
521  throw ProcessError("Method not implemented by model " + toString(myModel));
522  }
523 
525  void setShadowApproachingInformation(MSLink* link) const;
527 
528  bool isOpposite() const {
529  return myAmOpposite;
530  }
531 
534 
535  double getCommittedSpeed() const {
536  return myCommittedSpeed;
537  }
538 
540  double getSpeedLat() const {
541  return mySpeedLat;
542  }
543 
545  double getAccelerationLat() const {
546  return myAccelerationLat;
547  }
548 
550  void setSpeedLat(double speedLat);
551 
554  virtual double computeSpeedLat(double latDist, double& maneuverDist, bool urgent) const;
555 
558  virtual double getAssumedDecelForLaneChangeDuration() const;
559 
561  virtual std::string getParameter(const std::string& key) const {
562  throw InvalidArgument("Parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
563  }
564 
566  virtual void setParameter(const std::string& key, const std::string& value) {
567  UNUSED_PARAMETER(value);
568  throw InvalidArgument("Setting parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
569  }
570 
571 
574  void checkTraCICommands();
575 
577  double getForwardPos() const;
578 
579  bool hasBlueLight() const {
580  return myHaveBlueLight;
581  }
582 
583  static const double NO_NEIGHBOR;
584 
585 protected:
586  virtual bool congested(const MSVehicle* const neighLeader);
587 
588  virtual bool predInteraction(const std::pair<MSVehicle*, double>& leader);
589 
591  bool cancelRequest(int state, int laneOffset);
592 
594  double getMaxSpeedLat2() const;
595 
596 protected:
599 
606 
607  std::pair<int, int> mySavedStateRight;
608  std::pair<int, int> mySavedStateCenter;
609  std::pair<int, int> mySavedStateLeft;
613 
616  std::shared_ptr<MSLeaderDistanceInfo> myLeftFollowers;
617  std::shared_ptr<MSLeaderDistanceInfo> myLeftLeaders;
618  std::shared_ptr<MSLeaderDistanceInfo> myRightFollowers;
619  std::shared_ptr<MSLeaderDistanceInfo> myRightLeaders;
621 
623  double mySpeedLat;
624 
627 
630 
633 
636 
639 
642  /* @brief Lanes that are partially (laterally) occupied by the back of the
643  * vehicle (analogue to MSVehicle::myFurtherLanes) */
644  std::vector<MSLane*> myShadowFurtherLanes;
645  std::vector<double> myShadowFurtherLanesPosLat;
646 
647 
656 
657  /* @brief Further upstream lanes that are affected by the vehicle's maneuver (analogue to MSVehicle::myFurtherLanes)
658  * @note If myTargetLane==nullptr, we may assume myFurtherTargetLanes.size()==0, otherwise we have
659  * myFurtherTargetLanes.size() == myVehicle.getFurtherLanes.size()
660  * Here it may occur that an element myFurtherTargetLanes[i]==nullptr if myFurtherLanes[i] has
661  * no parallel lane in the change direction.
662  * */
663  std::vector<MSLane*> myFurtherTargetLanes;
664 
666  inline const MSCFModel& getCarFollowModel() const {
667  return myVehicle.getCarFollowModel();
668  }
669 
672 
674  std::vector<MSLane*> myPartiallyOccupatedByShadow;
675 
676  /* @brief list of lanes where there is no shadow vehicle partial occupator
677  * (when changing to a lane that has no predecessor) */
678  std::vector<MSLane*> myNoPartiallyOccupatedByShadow;
679 
683 
697 
701 
702  // @brief the maximum lateral speed for non-strategic changes when standing
704  // @brief the factor of maximum lateral speed to longitudinal speed for non-strategic changes
706  // @brief the maximum lateral maneuver distance when standing
708  // @brief factor for lane keeping imperfection
709  double mySigma;
710 
713 
714  /* @brief to be called by derived classes in their changed() method.
715  * If dir=0 is given, the current value remains unchanged */
716  void initLastLaneChangeOffset(int dir);
717 
720 
722  static bool myLCOutput;
723  static bool myLCStartedOutput;
724  static bool myLCEndedOutput;
725  static bool myLCXYOutput;
726 
727 
728 private:
729  /* @brief information how long ago the vehicle has performed a lane-change,
730  * sign indicates direction of the last change
731  */
733 
735  mutable std::vector<MSLink*> myApproachedByShadow;
736 
739 
743 
746 
747 
748 private:
751 };
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:32
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
long long int SUMOTime
Definition: SUMOTime.h:32
LaneChangeAction
The state of a vehicle's lane-change behavior.
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.
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
void * informLeader(void *info, MSVehicle *sender)
Informs the leader on the same lane.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
MSLCMessager(MSVehicle *leader, MSVehicle *neighLead, MSVehicle *neighFollow)
Constructor.
MSVehicle * myNeighLeader
The leader on the lane the vehicle want to change to.
MSVehicle * myLeader
The leader on the informed vehicle's 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)
void saveLCState(const int dir, const int stateWithoutTraCI, const int state)
double myAccelerationLat
the current lateral acceleration
void setFollowerGaps(CLeaderDist follower, double secGap)
const MSCFModel & getCarFollowModel() const
The vehicle's car following model.
std::vector< MSLane * > myFurtherTargetLanes
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
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
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
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
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
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
bool myHaveBlueLight
whether this vehicle is driving with special permissions and behavior
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 void * inform(void *info, MSVehicle *sender)=0
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
MSAbstractLaneChangeModel & operator=(const MSAbstractLaneChangeModel &s)
Invalidated assignment operator.
const std::vector< MSLane * > & getShadowFurtherLanes() const
const std::pair< int, int > & getSavedState(const int dir) const
void setNoShadowPartialOccupator(MSLane *lane)
const LaneChangeModel myModel
the type of this model
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
const std::vector< MSLane * > & getFurtherTargetLanes() const
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
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 saveBlockerLength(double length)
reserve space at the end of the lane to avoid dead locks
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
MSLane * getTargetLane() const
Returns the lane the vehicle has committed to enter during a sublane lane change.
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
void memorizeGapsAtLCInit()
Control for resetting the memorized values for LC relevant gaps until the LC output is triggered in t...
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:82
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:133
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:75
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5051
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:917
A storage for options typed value containers)
Definition: OptionsCont.h:89
StateAndDist(int _state, double _latDist, double _targetDist, int _dir)
bool sameDirection(const StateAndDist &other) const