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-2020 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/MSVehicle.h>
30 
31 class MSLane;
32 
33 // ===========================================================================
34 // used enumeration
35 // ===========================================================================
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 public:
46 
50  class MSLCMessager {
51  public:
57  MSLCMessager(MSVehicle* leader, MSVehicle* neighLead, MSVehicle* neighFollow)
58  : myLeader(leader), myNeighLeader(neighLead),
59  myNeighFollower(neighFollow) { }
60 
61 
64 
65 
71  void* informLeader(void* info, MSVehicle* sender) {
72  assert(myLeader != 0);
73  return myLeader->getLaneChangeModel().inform(info, sender);
74  }
75 
76 
82  void* informNeighLeader(void* info, MSVehicle* sender) {
83  assert(myNeighLeader != 0);
84  return myNeighLeader->getLaneChangeModel().inform(info, sender);
85  }
86 
87 
93  void* informNeighFollower(void* info, MSVehicle* sender) {
94  assert(myNeighFollower != 0);
95  return myNeighFollower->getLaneChangeModel().inform(info, sender);
96  }
97 
98 
99  private:
106 
107  };
108 
109  struct StateAndDist {
110  // @brief LaneChangeAction flags
111  int state;
112  // @brief Lateral distance to be completed in the next step
113  double latDist;
114  // @brief Full lateral distance required for the completion of the envisioned maneuver
115  double maneuverDist;
116  // @brief direction that was checked
117  int dir;
118 
119  StateAndDist(int _state, double _latDist, double _targetDist, int _dir) :
120  state(_state),
121  latDist(_latDist),
122  maneuverDist(_targetDist),
123  dir(_dir) {}
124 
125  bool sameDirection(const StateAndDist& other) const {
126  return latDist * other.latDist > 0;
127  }
128  };
129 
131  void static initGlobalOptions(const OptionsCont& oc);
132 
138 
140  inline static bool haveLateralDynamics() {
142  }
143 
147  virtual LaneChangeModel getModelID() const = 0;
148 
150  static bool haveLCOutput() {
151  return myLCOutput;
152  }
153 
155  static bool outputLCStarted() {
156  return myLCStartedOutput;
157  }
158 
160  static bool outputLCEnded() {
161  return myLCEndedOutput;
162  }
163 
169 
171  virtual ~MSAbstractLaneChangeModel();
172 
173  inline int getOwnState() const {
174  return myOwnState;
175  }
176 
177  inline int getPrevState() const {
179  return myPreviousState2;
180  }
181 
182  virtual void setOwnState(const int state);
183 
185  void setManeuverDist(const double dist);
187  double getManeuverDist() const;
188  double getPreviousManeuverDist() const;
189 
191  virtual void updateSafeLatDist(const double travelledLatDist);
192 
193  const std::pair<int, int>& getSavedState(const int dir) const {
194  if (dir == -1) {
195  return mySavedStateRight;
196  } else if (dir == 0) {
197  return mySavedStateCenter;
198  } else {
199  return mySavedStateLeft;
200  }
201  }
202 
203  void saveLCState(const int dir, const int stateWithoutTraCI, const int state) {
204  const auto pair = std::make_pair(stateWithoutTraCI | getCanceledState(dir), state);
205  if (dir == -1) {
206  mySavedStateRight = pair;
207  } else if (dir == 0) {
208  mySavedStateCenter = pair;
209  } else {
210  mySavedStateLeft = pair;
211  }
212  }
213 
216  void saveNeighbors(const int dir, const MSLeaderDistanceInfo& followers, const MSLeaderDistanceInfo& leaders);
217 
220  void saveNeighbors(const int dir, const std::pair<MSVehicle* const, double>& follower, const std::pair<MSVehicle* const, double>& leader);
221 
223  void clearNeighbors();
224 
226  const std::shared_ptr<MSLeaderDistanceInfo> getFollowers(const int dir);
227 
229  const std::shared_ptr<MSLeaderDistanceInfo> getLeaders(const int dir);
230 
231  int& getCanceledState(const int dir) {
232  if (dir == -1) {
233  return myCanceledStateRight;
234  } else if (dir == 0) {
235  return myCanceledStateCenter;
236  } else {
237  return myCanceledStateLeft;
238  }
239  }
240 
242  bool isStrategicBlocked() const;
243 
244  void setFollowerGaps(CLeaderDist follower, double secGap);
245  void setLeaderGaps(CLeaderDist, double secGap);
246  void setOrigLeaderGaps(CLeaderDist, double secGap);
247  void setFollowerGaps(const MSLeaderDistanceInfo& vehicles);
248  void setLeaderGaps(const MSLeaderDistanceInfo& vehicles);
249  void setOrigLeaderGaps(const MSLeaderDistanceInfo& vehicles);
250 
251  virtual void prepareStep();
252 
257  virtual int wantsChange(
258  int laneOffset,
259  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
260  const std::pair<MSVehicle*, double>& leader,
261  const std::pair<MSVehicle*, double>& neighLead,
262  const std::pair<MSVehicle*, double>& neighFollow,
263  const MSLane& neighLane,
264  const std::vector<MSVehicle::LaneQ>& preb,
265  MSVehicle** lastBlocked,
266  MSVehicle** firstBlocked) {
267  UNUSED_PARAMETER(laneOffset);
268  UNUSED_PARAMETER(&msgPass);
269  UNUSED_PARAMETER(blocked);
270  UNUSED_PARAMETER(&leader);
271  UNUSED_PARAMETER(&neighLead);
272  UNUSED_PARAMETER(&neighFollow);
273  UNUSED_PARAMETER(&neighLane);
274  UNUSED_PARAMETER(&preb);
275  UNUSED_PARAMETER(lastBlocked);
276  UNUSED_PARAMETER(firstBlocked);
277  throw ProcessError("Method not implemented by model " + toString(myModel));
278  };
279 
280  virtual int wantsChangeSublane(
281  int laneOffset,
282  LaneChangeAction alternatives,
283  const MSLeaderDistanceInfo& leaders,
284  const MSLeaderDistanceInfo& followers,
285  const MSLeaderDistanceInfo& blockers,
286  const MSLeaderDistanceInfo& neighLeaders,
287  const MSLeaderDistanceInfo& neighFollowers,
288  const MSLeaderDistanceInfo& neighBlockers,
289  const MSLane& neighLane,
290  const std::vector<MSVehicle::LaneQ>& preb,
291  MSVehicle** lastBlocked,
292  MSVehicle** firstBlocked,
293  double& latDist, double& targetDistLat, int& blocked) {
294  UNUSED_PARAMETER(laneOffset);
295  UNUSED_PARAMETER(alternatives);
296  UNUSED_PARAMETER(&leaders);
297  UNUSED_PARAMETER(&followers);
298  UNUSED_PARAMETER(&blockers);
299  UNUSED_PARAMETER(&neighLeaders);
300  UNUSED_PARAMETER(&neighFollowers);
301  UNUSED_PARAMETER(&neighBlockers);
302  UNUSED_PARAMETER(&neighLane);
303  UNUSED_PARAMETER(&preb);
304  UNUSED_PARAMETER(lastBlocked);
305  UNUSED_PARAMETER(firstBlocked);
306  UNUSED_PARAMETER(latDist);
307  UNUSED_PARAMETER(targetDistLat);
308  UNUSED_PARAMETER(blocked);
309  throw ProcessError("Method not implemented by model " + toString(myModel));
310  }
311 
313  virtual void updateExpectedSublaneSpeeds(const MSLeaderDistanceInfo& ahead, int sublaneOffset, int laneIndex) {
314  UNUSED_PARAMETER(&ahead);
315  UNUSED_PARAMETER(sublaneOffset);
316  UNUSED_PARAMETER(laneIndex);
317  throw ProcessError("Method not implemented by model " + toString(myModel));
318  }
319 
322  UNUSED_PARAMETER(sd1);
323  UNUSED_PARAMETER(sd2);
324  throw ProcessError("Method not implemented by model " + toString(myModel));
325  }
326 
327  virtual void* inform(void* info, MSVehicle* sender) = 0;
328 
342  virtual double patchSpeed(const double min, const double wanted, const double max,
343  const MSCFModel& cfModel) = 0;
344 
345  /* @brief called once when the primary lane of the vehicle changes (updates
346  * the custom variables of each child implementation */
347  virtual void changed() = 0;
348 
349 
351  virtual double getSafetyFactor() const {
352  return 1.0;
353  }
354 
356  virtual double getOppositeSafetyFactor() const {
357  return 1.0;
358  }
359 
361  virtual bool debugVehicle() const {
362  return false;
363  }
364 
366  void changedToOpposite();
367 
368  void unchanged() {
369  if (myLastLaneChangeOffset > 0) {
371  } else if (myLastLaneChangeOffset < 0) {
373  }
374  }
375 
380  return myShadowLane;
381  }
382 
384  MSLane* getShadowLane(const MSLane* lane) const;
385 
387  MSLane* getShadowLane(const MSLane* lane, double posLat) const;
388 
390  void setShadowLane(MSLane* lane) {
391  myShadowLane = lane;
392  }
393 
394  const std::vector<MSLane*>& getShadowFurtherLanes() const {
395  return myShadowFurtherLanes;
396  }
397 
398  const std::vector<double>& getShadowFurtherLanesPosLat() const {
400  }
401 
406  return myTargetLane;
407  }
408 
409  const std::vector<MSLane*>& getFurtherTargetLanes() const {
410  return myFurtherTargetLanes;
411  }
412 
414  return myLastLaneChangeOffset;
415  }
416 
417 
419  inline bool pastMidpoint() const {
420  return myLaneChangeCompletion >= 0.5;
421  }
422 
424  SUMOTime remainingTime() const;
425 
437  virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel) const;
438 
440  inline bool isChangingLanes() const {
441  return myLaneChangeCompletion < (1 - NUMERICAL_EPS);
442  }
443 
445  inline double getLaneChangeCompletion() const {
446  return myLaneChangeCompletion;
447  }
448 
450  inline int getLaneChangeDirection() const {
451  return myLaneChangeDirection;
452  }
453 
455  int getShadowDirection() const;
456 
458  double getAngleOffset() const;
459 
461  inline bool alreadyChanged() const {
462  return myAlreadyChanged;
463  }
464 
466  void resetChanged() {
467  myAlreadyChanged = false;
468  }
469 
471  bool startLaneChangeManeuver(MSLane* source, MSLane* target, int direction);
472 
474  void memorizeGapsAtLCInit();
475  void clearGapsAtLCInit();
476 
477  /* @brief continue the lane change maneuver and return whether the midpoint
478  * was passed in this step
479  */
480  bool updateCompletion();
481 
482  /* @brief update lane change shadow after the vehicle moved to a new lane */
483  void updateShadowLane();
484 
485  /* @brief update lane change reservations after the vehicle moved to a new lane
486  * @note The shadow lane should always be updated before updating the target lane. */
488 
489  /* @brief Determines the lane which the vehicle intends to enter during its current action step.
490  * targetDir is set to the offset of the returned lane with respect to the vehicle'a current lane. */
491  MSLane* determineTargetLane(int& targetDir) const;
492 
493  /* @brief finish the lane change maneuver
494  */
496 
497  /* @brief clean up all references to the shadow vehicle
498  */
499  void cleanupShadowLane();
500 
501  /* @brief clean up all references to the vehicle on its target lanes
502  */
503  void cleanupTargetLane();
504 
506  virtual void saveBlockerLength(double length) {
507  UNUSED_PARAMETER(length);
508  }
509 
511  myPartiallyOccupatedByShadow.push_back(lane);
512  }
513 
515  myNoPartiallyOccupatedByShadow.push_back(lane);
516  }
517 
519  void primaryLaneChanged(MSLane* source, MSLane* target, int direction);
520 
522  void laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist = 0);
523 
525  virtual bool sublaneChangeCompleted(const double latDist) const {
526  UNUSED_PARAMETER(latDist);
527  throw ProcessError("Method not implemented by model " + toString(myModel));
528  }
529 
531  void setShadowApproachingInformation(MSLink* link) const;
533 
534  bool isOpposite() const {
535  return myAmOpposite;
536  }
537 
538  double getCommittedSpeed() const {
539  return myCommittedSpeed;
540  }
541 
543  double getSpeedLat() const {
544  return mySpeedLat;
545  }
546 
548  double getAccelerationLat() const {
549  return myAccelerationLat;
550  }
551 
553  void setSpeedLat(double speedLat);
554 
557  virtual double computeSpeedLat(double latDist, double& maneuverDist) const;
558 
561  virtual double getAssumedDecelForLaneChangeDuration() const;
562 
564  virtual std::string getParameter(const std::string& key) const {
565  throw InvalidArgument("Parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
566  }
567 
569  virtual void setParameter(const std::string& key, const std::string& value) {
570  UNUSED_PARAMETER(value);
571  throw InvalidArgument("Setting parameter '" + key + "' is not supported for laneChangeModel of type '" + toString(myModel) + "'");
572  }
573 
574 
577  void checkTraCICommands();
578 
579  static const double NO_NEIGHBOR;
580 
581 protected:
582  virtual bool congested(const MSVehicle* const neighLeader);
583 
584  virtual bool predInteraction(const std::pair<MSVehicle*, double>& leader);
585 
587  bool cancelRequest(int state, int laneOffset);
588 
589 
590 protected:
593 
600 
601  std::pair<int, int> mySavedStateRight;
602  std::pair<int, int> mySavedStateCenter;
603  std::pair<int, int> mySavedStateLeft;
607 
610  std::shared_ptr<MSLeaderDistanceInfo> myLeftFollowers;
611  std::shared_ptr<MSLeaderDistanceInfo> myLeftLeaders;
612  std::shared_ptr<MSLeaderDistanceInfo> myRightFollowers;
613  std::shared_ptr<MSLeaderDistanceInfo> myRightLeaders;
615 
617  double mySpeedLat;
618 
621 
624 
627 
630 
633 
636  /* @brief Lanes that are partially (laterally) occupied by the back of the
637  * vehicle (analogue to MSVehicle::myFurtherLanes) */
638  std::vector<MSLane*> myShadowFurtherLanes;
639  std::vector<double> myShadowFurtherLanesPosLat;
640 
641 
650 
651  /* @brief Further upstream lanes that are affected by the vehicle's maneuver (analogue to MSVehicle::myFurtherLanes)
652  * @note If myTargetLane==nullptr, we may assume myFurtherTargetLanes.size()==0, otherwise we have
653  * myFurtherTargetLanes.size() == myVehicle.getFurtherLanes.size()
654  * Here it may occur that an element myFurtherTargetLanes[i]==nullptr if myFurtherLanes[i] has
655  * no parallel lane in the change direction.
656  * */
657  std::vector<MSLane*> myFurtherTargetLanes;
658 
661 
664 
666  std::vector<MSLane*> myPartiallyOccupatedByShadow;
667 
668  /* @brief list of lanes where there is no shadow vehicle partial occupator
669  * (when changing to a lane that has no predecessor) */
670  std::vector<MSLane*> myNoPartiallyOccupatedByShadow;
671 
675 
689 
693 
694  // @brief the maximum lateral speed when standing
696  // @brief the factor of maximum lateral speed to longitudinal speed
698  // @brief factor for lane keeping imperfection
699  double mySigma;
700 
701  /* @brief to be called by derived classes in their changed() method.
702  * If dir=0 is given, the current value remains unchanged */
703  void initLastLaneChangeOffset(int dir);
704 
707 
709  static bool myLCOutput;
710  static bool myLCStartedOutput;
711  static bool myLCEndedOutput;
712  static bool myLCXYOutput;
713 
714 
715 private:
716  /* @brief information how long ago the vehicle has performed a lane-change,
717  * sign indicates direction of the last change
718  */
720 
722  mutable std::vector<MSLink*> myApproachedByShadow;
723 
726 
730 
733 
734 
735 private:
738 };
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:32
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
long long int SUMOTime
Definition: SUMOTime.h:31
LaneChangeAction
The state of a vehicle's lane-change behavior.
LaneChangeModel
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
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.
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)
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.
std::shared_ptr< MSLeaderDistanceInfo > myLeftLeaders
int myPreviousState
lane changing state from the previous simulation step
virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel) const
Calculates the maximal time needed to complete a lane change maneuver if lcMaxSpeedLatFactor and lcMa...
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
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
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
virtual int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, 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...
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
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 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 double computeSpeedLat(double latDist, double &maneuverDist) const
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
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
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.
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...
const MSCFModel & myCarFollowModel
The vehicle's car following model.
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 setShadowLane(MSLane *lane)
set the shadow lane
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
static double gLateralResolution
Definition: MSGlobals.h:82
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:79
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:130
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:4699
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