SUMO - Simulation of Urban MObility
MSLCM_LC2013.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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
19 // A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013
20 /****************************************************************************/
21 #ifndef MSLCM_LC2013_h
22 #define MSLCM_LC2013_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
31 #include <vector>
32 
33 // INVALID_SPEED should be used when the construction of upper bound for the speed
34 // leads to no restrictions, e.g. during LC-messaging to followers or leaders.
35 // Currently either std::numeric_limits<...>.max() or -1 is used for this purpose in many places.
36 // TODO: implement this everywhere and remove workarounds for ballistic update in cases of possible '-1'-returns. Refs. #2577
37 #define INVALID_SPEED 299792458 + 1 // nothing can go faster than the speed of light!
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
49 public:
50 
52 
53  virtual ~MSLCM_LC2013();
54 
57  return LCM_LC2013;
58  }
59 
61  void initDerivedParameters();
62 
63  bool debugVehicle() const;
64 
73  int wantsChange(
74  int laneOffset,
75  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
76  const std::pair<MSVehicle*, double>& leader,
77  const std::pair<MSVehicle*, double>& neighLead,
78  const std::pair<MSVehicle*, double>& neighFollow,
79  const MSLane& neighLane,
80  const std::vector<MSVehicle::LaneQ>& preb,
81  MSVehicle** lastBlocked,
82  MSVehicle** firstBlocked);
83 
84  void* inform(void* info, MSVehicle* sender);
85 
96  double patchSpeed(const double min, const double wanted, const double max,
97  const MSCFModel& cfModel);
99  double _patchSpeed(const double min, const double wanted, const double max,
100  const MSCFModel& cfModel);
101 
102  void changed();
103 
104  double getSafetyFactor() const;
105 
106  void prepareStep();
107 
109  std::string getParameter(const std::string& key) const;
110 
112  void setParameter(const std::string& key, const std::string& value);
113 
115  double computeSpeedLat(double latDist, double& maneuverDist);
116 
120 
121 protected:
122 
124  int _wantsChange(
125  int laneOffset,
126  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
127  const std::pair<MSVehicle*, double>& leader,
128  const std::pair<MSVehicle*, double>& neighLead,
129  const std::pair<MSVehicle*, double>& neighFollow,
130  const MSLane& neighLane,
131  const std::vector<MSVehicle::LaneQ>& preb,
132  MSVehicle** lastBlocked,
133  MSVehicle** firstBlocked);
134 
135  /* @brief decide whether we will overtake or follow a blocking leader
136  * and inform it accordingly
137  * If we decide to follow, myVSafes will be extended
138  * returns the planned speed if following or -1 if overtaking */
140  int blocked, int dir,
141  const std::pair<MSVehicle*, double>& neighLead,
142  double remainingSeconds);
143 
146  int blocked, int dir,
147  const std::pair<MSVehicle*, double>& neighFollow,
148  double remainingSeconds,
149  double plannedSpeed);
150 
151 
152  /* @brief compute the distance to cover until a safe gap to the vehicle v in front is reached
153  * assuming constant velocities
154  * @param[in] follower the vehicle which overtakes
155  * @param[in] leader the vehicle to be overtaken
156  * @param[in] gap initial distance between front of follower and back of leader
157  * @param[in] leaderSpeed an assumed speed for the leader (default uses the current speed)
158  * @param[in] followerSpeed an assumed speed for the follower (default uses the current speed)
159  * @return the distance that the relative positions would have to change.
160  */
161  static double overtakeDistance(const MSVehicle* follower, const MSVehicle* leader, const double gap, double followerSpeed = INVALID_SPEED, double leaderSpeed = INVALID_SPEED);
162 
164  int slowDownForBlocked(MSVehicle** blocked, int state);
165 
166 
167  // XXX: consider relocation of the roundabout functions (perhaps to MSVehicle or the abstract LC Model...) (Leo)
177  static void
178  getRoundaboutAheadInfo(const MSLCM_LC2013* lcm, const MSVehicle::LaneQ& curr, const MSVehicle::LaneQ& neigh,
179  double& roundaboutDistanceAhead, double& roundaboutDistanceAheadNeigh, int& roundaboutEdgesAhead, int& roundaboutEdgesAheadNeigh);
180 
187  double
188  roundaboutDistBonus(double roundaboutDistAhead, int roundaboutEdgesAhead) const;
189 
195  static double
196  distanceAlongNextRoundabout(double position, const MSLane* initialLane, const std::vector<MSLane*>& continuationLanes);
197 
199  void saveBlockerLength(MSVehicle* blocker, int lcaCounter);
200 
202  void adaptSpeedToPedestrians(const MSLane* lane, double& v);
203 
205  inline void saveBlockerLength(double length) {
207  };
208 
209  inline bool amBlockingLeader() {
210  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
211  }
212  inline bool amBlockingFollower() {
213  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
214  }
215  inline bool amBlockingFollowerNB() {
217  }
218  inline bool amBlockingFollowerPlusNB() {
220  }
221  inline bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist) {
222  return dist / (abs(laneOffset)) < lookForwardDist;
223  }
224  inline bool currentDistAllows(double dist, int laneOffset, double lookForwardDist) {
225  return dist / abs(laneOffset) > lookForwardDist;
226  }
227 
234  void addLCSpeedAdvice(const double vSafe);
235 
236 protected:
237 
239  typedef std::pair<double, int> Info;
240 
243  /* @brief a value for tracking the probability of following the/"Rechtsfahrgebot"
244  * A larger negative value indicates higher probability for moving to the
245  * right (as in mySpeedGainProbability) */
247 
249  double myLeftSpace;
250 
251  /*@brief the speed to use when computing the look-ahead distance for
252  * determining urgency of strategic lane changes */
254 
257  std::vector<double> myLCAccelerationAdvices;
258 
259  bool myDontBrake; // XXX: myDontBrake is initialized as false and seems not to be changed anywhere... What's its purpose???
260 
262 
264  double myCooperativeParam; // in [0,1]
267 
268  // @brief the factor by which the lookahead distance to the left differs from the lookahead to the right
270  // @brief the factor by which the speedGain-threshold for the leftdiffers from the threshold for the right
272 
273  // @brief willingness to undercut longitudinal safe gaps
274  double myAssertive;
275 
276  const double myExperimentalParam1; // for feature testing
278 
280 
281  // @brief willingness to encroach on other vehicles laterally (pushing them around)
285 };
286 
287 
288 #endif
289 
290 /****************************************************************************/
291 
double myLeadingBlockerLength
Definition: MSLCM_LC2013.h:248
double patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)
Called to adapt the speed in order to allow a lane change. It uses information on LC-related desired ...
double getAssumedDecelForLaneChangeDuration() const
Returns a deceleration value which is used for the estimation of the duration of a lane change...
void saveBlockerLength(MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
MSLCM_LC2013(MSVehicle &v)
double getSafetyFactor() const
return factor for modifying the safety constraints of the car-following model
bool amBlockingFollower()
Definition: MSLCM_LC2013.h:212
bool amBlockingFollowerNB()
Definition: MSLCM_LC2013.h:215
double myKeepRightProbability
Definition: MSLCM_LC2013.h:246
The car-following model abstraction.
Definition: MSCFModel.h:57
void addLCSpeedAdvice(const double vSafe)
Takes a vSafe (speed advice for speed in the next simulation step), converts it into an acceleration ...
double myChangeProbThresholdLeft
Definition: MSLCM_LC2013.h:283
double myLookAheadSpeed
Definition: MSLCM_LC2013.h:253
double myAssertive
Definition: MSLCM_LC2013.h:274
double myStrategicParam
Definition: MSLCM_LC2013.h:263
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)
helper function for doing the actual work
double myKeepRightParam
Definition: MSLCM_LC2013.h:266
void initDerivedParameters()
init cached parameters derived directly from model parameters
T MAX2(T a, T b)
Definition: StdDefs.h:76
double _patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)
std::pair< double, int > Info
information regarding save velocity (unused) and state flags of the ego vehicle
Definition: MSLCM_LC2013.h:239
double computeSpeedLat(double latDist, double &maneuverDist)
decides the next lateral speed (for continuous lane changing)
LaneChangeModel getModelID() const
Returns the model&#39;s id.
Definition: MSLCM_LC2013.h:56
bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist)
Definition: MSLCM_LC2013.h:221
static double distanceAlongNextRoundabout(double position, const MSLane *initialLane, const std::vector< MSLane *> &continuationLanes)
compute the distance on the next upcoming roundabout along a given sequence of lanes.
bool debugVehicle() const
whether the current vehicles shall be debugged
A class responsible for exchanging messages between cars involved in lane-change interaction.
LaneChangeModel
static double overtakeDistance(const MSVehicle *follower, const MSVehicle *leader, const double gap, double followerSpeed=INVALID_SPEED, double leaderSpeed=INVALID_SPEED)
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013...
Definition: MSLCM_LC2013.h:48
double mySpeedGainParam
Definition: MSLCM_LC2013.h:265
double mySpeedGainProbability
a value for tracking the probability that a change to the offset with the same sign is beneficial ...
Definition: MSLCM_LC2013.h:242
void informFollower(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, double > &neighFollow, double remainingSeconds, double plannedSpeed)
decide whether we will try cut in before the follower or allow to be overtaken
double mySpeedGainRight
Definition: MSLCM_LC2013.h:271
bool currentDistAllows(double dist, int laneOffset, double lookForwardDist)
Definition: MSLCM_LC2013.h:224
const double myExperimentalParam1
Definition: MSLCM_LC2013.h:276
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
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...
A structure representing the best lanes for continuing the current route starting at &#39;lane&#39;...
Definition: MSVehicle.h:804
int myOwnState
The current state of the vehicle.
std::vector< double > myLCAccelerationAdvices
vector of LC-related acceleration recommendations Filled in wantsChange() and applied in patchSpeed()...
Definition: MSLCM_LC2013.h:257
double myLeftSpace
Definition: MSLCM_LC2013.h:249
double myLookaheadLeft
Definition: MSLCM_LC2013.h:269
double myChangeProbThresholdRight
Definition: MSLCM_LC2013.h:282
static void getRoundaboutAheadInfo(const MSLCM_LC2013 *lcm, const MSVehicle::LaneQ &curr, const MSVehicle::LaneQ &neigh, double &roundaboutDistanceAhead, double &roundaboutDistanceAheadNeigh, int &roundaboutEdgesAhead, int &roundaboutEdgesAheadNeigh)
computes the distance and number of edges in the next upcoming roundabout along the lane continuation...
void adaptSpeedToPedestrians(const MSLane *lane, double &v)
react to pedestrians on the given lane
void saveBlockerLength(double length)
reserve space at the end of the lane to avoid dead locks
Definition: MSLCM_LC2013.h:205
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 myCooperativeParam
Definition: MSLCM_LC2013.h:264
virtual ~MSLCM_LC2013()
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
bool amBlockingFollowerPlusNB()
Definition: MSLCM_LC2013.h:218
double informLeader(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, double > &neighLead, double remainingSeconds)
void * inform(void *info, MSVehicle *sender)
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
#define INVALID_SPEED
Definition: MSLCM_LC2013.h:37
Interface for lane-change models.
bool amBlockingLeader()
Definition: MSLCM_LC2013.h:209
double roundaboutDistBonus(double roundaboutDistAhead, int roundaboutEdgesAhead) const
Computes the artificial bonus distance for roundabout lanes this additional distance reduces the sens...