Eclipse SUMO - Simulation of Urban MObility
MSAbstractLaneChangeModel.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 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 // Interface for lane-change models
20 /****************************************************************************/
21 
22 // ===========================================================================
23 // DEBUG
24 // ===========================================================================
25 //#define DEBUG_TARGET_LANE
26 //#define DEBUG_SHADOWLANE
27 //#define DEBUG_OPPOSITE
28 //#define DEBUG_MANEUVER
29 #define DEBUG_COND (myVehicle.isSelected())
30 
31 
32 // ===========================================================================
33 // included modules
34 // ===========================================================================
35 #include <config.h>
36 
39 #include <microsim/MSNet.h>
40 #include <microsim/MSEdge.h>
41 #include <microsim/MSLane.h>
42 #include <microsim/MSDriverState.h>
43 #include <microsim/MSGlobals.h>
44 #include "MSLCM_DK2008.h"
45 #include "MSLCM_LC2013.h"
46 #include "MSLCM_SL2015.h"
47 
48 /* -------------------------------------------------------------------------
49  * static members
50  * ----------------------------------------------------------------------- */
55 const double MSAbstractLaneChangeModel::NO_NEIGHBOR(std::numeric_limits<double>::max());
56 
57 /* -------------------------------------------------------------------------
58  * MSAbstractLaneChangeModel-methods
59  * ----------------------------------------------------------------------- */
60 
61 void
63  myAllowOvertakingRight = oc.getBool("lanechange.overtake-right");
64  myLCOutput = oc.isSet("lanechange-output");
65  myLCStartedOutput = oc.getBool("lanechange-output.started");
66  myLCEndedOutput = oc.getBool("lanechange-output.ended");
67 }
68 
69 
72  if (MSGlobals::gLateralResolution > 0 && lcm != LCM_SL2015 && lcm != LCM_DEFAULT) {
73  throw ProcessError("Lane change model '" + toString(lcm) + "' is not compatible with sublane simulation");
74  }
75  switch (lcm) {
76  case LCM_DK2008:
77  return new MSLCM_DK2008(v);
78  case LCM_LC2013:
79  return new MSLCM_LC2013(v);
80  case LCM_SL2015:
81  return new MSLCM_SL2015(v);
82  case LCM_DEFAULT:
84  return new MSLCM_LC2013(v);
85  } else {
86  return new MSLCM_SL2015(v);
87  }
88  default:
89  throw ProcessError("Lane change model '" + toString(lcm) + "' not implemented");
90  }
91 }
92 
93 
95  myVehicle(v),
96  myOwnState(0),
97  myPreviousState(0),
98  myPreviousState2(0),
99  myCanceledStateRight(LCA_NONE),
100  myCanceledStateCenter(LCA_NONE),
101  myCanceledStateLeft(LCA_NONE),
102  mySpeedLat(0),
103  myCommittedSpeed(0),
104  myLaneChangeCompletion(1.0),
105  myLaneChangeDirection(0),
106  myManeuverDist(0.),
107  myPreviousManeuverDist(0.),
108  myAlreadyChanged(false),
109  myShadowLane(nullptr),
110  myTargetLane(nullptr),
111  myCarFollowModel(v.getCarFollowModel()),
112  myModel(model),
113  myLastLateralGapLeft(0.),
114  myLastLateralGapRight(0.),
115  myLastLeaderGap(0.),
116  myLastFollowerGap(0.),
117  myLastLeaderSecureGap(0.),
118  myLastFollowerSecureGap(0.),
119  myLastOrigLeaderGap(0.),
120  myLastOrigLeaderSecureGap(0.),
121  myLastLeaderSpeed(0),
122  myLastFollowerSpeed(0),
123  myLastOrigLeaderSpeed(0),
124  myDontResetLCGaps(false),
125  myMaxSpeedLatStanding(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING, v.getVehicleType().getMaxSpeedLat())),
126  myMaxSpeedLatFactor(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR, 1)),
127  mySigma(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_SIGMA, 0.0)),
128  myLastLaneChangeOffset(0),
129  myAmOpposite(false) {
133 }
134 
135 
137 }
138 
139 void
142  myOwnState = state;
143  myPreviousState = state; // myOwnState is modified in prepareStep so we make a backup
144 }
145 
146 void
147 MSAbstractLaneChangeModel::updateSafeLatDist(const double travelledLatDist) {
148  UNUSED_PARAMETER(travelledLatDist);
149 }
150 
151 
152 void
154 #ifdef DEBUG_MANEUVER
155  if (DEBUG_COND) {
156  std::cout << SIMTIME
157  << " veh=" << myVehicle.getID()
158  << " setManeuverDist() old=" << myManeuverDist << " new=" << dist
159  << std::endl;
160  }
161 #endif
162  myManeuverDist = fabs(dist) < NUMERICAL_EPS ? 0. : dist;
163  // store value which may be modified by the model during the next step
165 }
166 
167 
168 double
170  return myManeuverDist;
171 }
172 
173 double
175  return myPreviousManeuverDist;
176 }
177 
178 void
180  if (dir == -1) {
181  myLeftFollowers = std::make_shared<MSLeaderDistanceInfo>(followers);
182  myLeftLeaders = std::make_shared<MSLeaderDistanceInfo>(leaders);
183  } else if (dir == 1) {
184  myRightFollowers = std::make_shared<MSLeaderDistanceInfo>(followers);
185  myRightLeaders = std::make_shared<MSLeaderDistanceInfo>(leaders);
186  } else {
187  // dir \in {-1,1} !
188  assert(false);
189  }
190 }
191 
192 
193 void
194 MSAbstractLaneChangeModel::saveNeighbors(const int dir, const std::pair<MSVehicle* const, double>& follower, const std::pair<MSVehicle* const, double>& leader) {
195  if (dir == -1) {
196  myLeftFollowers = std::make_shared<MSLeaderDistanceInfo>(follower, myVehicle.getLane());
197  myLeftLeaders = std::make_shared<MSLeaderDistanceInfo>(leader, myVehicle.getLane());
198  } else if (dir == 1) {
199  myRightFollowers = std::make_shared<MSLeaderDistanceInfo>(follower, myVehicle.getLane());
200  myRightLeaders = std::make_shared<MSLeaderDistanceInfo>(leader, myVehicle.getLane());
201  } else {
202  // dir \in {-1,1} !
203  assert(false);
204  }
205 }
206 
207 
208 void
210  myLeftFollowers = nullptr;
211  myLeftLeaders = nullptr;
212  myRightFollowers = nullptr;
213  myRightLeaders = nullptr;
214 }
215 
216 
217 const std::shared_ptr<MSLeaderDistanceInfo>
219  if (dir == -1) {
220  return myLeftFollowers;
221  } else if (dir == 1) {
222  return myRightFollowers;
223  } else {
224  // dir \in {-1,1} !
225  assert(false);
226  }
227  return nullptr;
228 }
229 
230 const std::shared_ptr<MSLeaderDistanceInfo>
232  if (dir == -1) {
233  return myLeftLeaders;
234  } else if (dir == 1) {
235  return myRightLeaders;
236  } else {
237  // dir \in {-1,1} !
238  assert(false);
239  }
240  return nullptr;
241 }
242 
243 
244 bool
246  if (neighLeader == nullptr) {
247  return false;
248  }
249  // Congested situation are relevant only on highways (maxSpeed > 70km/h)
250  // and congested on German Highways means that the vehicles have speeds
251  // below 60km/h. Overtaking on the right is allowed then.
252  if ((myVehicle.getLane()->getSpeedLimit() <= 70.0 / 3.6) || (neighLeader->getLane()->getSpeedLimit() <= 70.0 / 3.6)) {
253 
254  return false;
255  }
256  if (myVehicle.congested() && neighLeader->congested()) {
257  return true;
258  }
259  return false;
260 }
261 
262 
263 
264 bool
265 MSAbstractLaneChangeModel::predInteraction(const std::pair<MSVehicle*, double>& leader) {
266  if (leader.first == 0) {
267  return false;
268  }
269  // let's check it on highways only
270  if (leader.first->getSpeed() < (80.0 / 3.6)) {
271  return false;
272  }
273  return leader.second < myCarFollowModel.interactionGap(&myVehicle, leader.first->getSpeed());
274 }
275 
276 
277 bool
281  myLaneChangeDirection = direction;
282  setManeuverDist((target->getWidth() + source->getWidth()) * 0.5 * direction);
285  if (myLCOutput) {
287  }
288  return true;
289  } else {
290  primaryLaneChanged(source, target, direction);
291  return false;
292  }
293 }
294 
295 void
297  myDontResetLCGaps = true;
298 }
299 
300 void
302  myDontResetLCGaps = false;
303 }
304 
305 void
307  initLastLaneChangeOffset(direction);
309  source->leftByLaneChange(&myVehicle);
310  laneChangeOutput("change", source, target, direction); // record position on the source edge in case of opposite change
311  if (&source->getEdge() != &target->getEdge()) {
313 #ifdef DEBUG_OPPOSITE
314  if (debugVehicle()) {
315  std::cout << SIMTIME << " veh=" << myVehicle.getID() << " primaryLaneChanged nowOpposite=" << myAmOpposite << "\n";
316  }
317 #endif
320  } else {
322  }
323  target->enteredByLaneChange(&myVehicle);
324  // Assure that the drive items are up to date (even if the following step is no actionstep for the vehicle).
325  // This is necessary because the lane advance uses the target lane from the corresponding drive item.
327  changed();
328 }
329 
330 void
331 MSAbstractLaneChangeModel::laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist) {
332  if (myLCOutput) {
333  OutputDevice& of = OutputDevice::getDeviceByOption("lanechange-output");
334  of.openTag(tag);
337  of.writeAttr(SUMO_ATTR_TIME, time2string(MSNet::getInstance()->getCurrentTimeStep()));
338  of.writeAttr(SUMO_ATTR_FROM, source->getID());
339  of.writeAttr(SUMO_ATTR_TO, target->getID());
340  of.writeAttr(SUMO_ATTR_DIR, direction);
343  of.writeAttr("reason", toString((LaneChangeAction)(myOwnState & ~(
348  of.writeAttr("leaderGap", myLastLeaderGap == NO_NEIGHBOR ? "None" : toString(myLastLeaderGap));
349  of.writeAttr("leaderSecureGap", myLastLeaderSecureGap == NO_NEIGHBOR ? "None" : toString(myLastLeaderSecureGap));
350  of.writeAttr("leaderSpeed", myLastLeaderSpeed == NO_NEIGHBOR ? "None" : toString(myLastLeaderSpeed));
351  of.writeAttr("followerGap", myLastFollowerGap == NO_NEIGHBOR ? "None" : toString(myLastFollowerGap));
352  of.writeAttr("followerSecureGap", myLastFollowerSecureGap == NO_NEIGHBOR ? "None" : toString(myLastFollowerSecureGap));
353  of.writeAttr("followerSpeed", myLastFollowerSpeed == NO_NEIGHBOR ? "None" : toString(myLastFollowerSpeed));
354  of.writeAttr("origLeaderGap", myLastOrigLeaderGap == NO_NEIGHBOR ? "None" : toString(myLastOrigLeaderGap));
355  of.writeAttr("origLeaderSecureGap", myLastOrigLeaderSecureGap == NO_NEIGHBOR ? "None" : toString(myLastOrigLeaderSecureGap));
356  of.writeAttr("origLeaderSpeed", myLastOrigLeaderSpeed == NO_NEIGHBOR ? "None" : toString(myLastOrigLeaderSpeed));
358  const double latGap = direction < 0 ? myLastLateralGapRight : myLastLateralGapLeft;
359  of.writeAttr("latGap", latGap == NO_NEIGHBOR ? "None" : toString(latGap));
360  if (maneuverDist != 0) {
361  of.writeAttr("maneuverDistance", toString(maneuverDist));
362  }
363  }
364  of.closeTag();
367  }
368  }
369 }
370 
371 
372 double
373 MSAbstractLaneChangeModel::computeSpeedLat(double /*latDist*/, double& maneuverDist) {
375  int stepsToChange = (int)ceil(fabs(maneuverDist) / SPEED2DIST(myVehicle.getVehicleType().getMaxSpeedLat()));
376  return DIST2SPEED(maneuverDist / stepsToChange);
377  } else {
378  return maneuverDist / STEPS2TIME(MSGlobals::gLaneChangeDuration);
379  }
380 }
381 
382 
383 double
385  throw ProcessError("Method getAssumedDecelForLaneChangeDuration() not implemented by model " + toString(myModel));
386 }
387 
388 
389 bool
391  const bool pastBefore = pastMidpoint();
392  // maneuverDist is not updated in the context of continuous lane changing but represents the full LC distance
393  double maneuverDist = getManeuverDist();
394  mySpeedLat = computeSpeedLat(0, maneuverDist);
396  return !pastBefore && pastMidpoint();
397 }
398 
399 
400 void
402  UNUSED_PARAMETER(reason);
410  // aborted maneuver
411 #ifdef DEBUG_OPPOSITE
412  if (debugVehicle()) {
413  std::cout << SIMTIME << " veh=" << myVehicle.getID() << " aborted maneuver (no longer opposite)\n";
414  }
415 #endif
417  }
418 }
419 
420 
421 MSLane*
422 MSAbstractLaneChangeModel::getShadowLane(const MSLane* lane, double posLat) const {
424  // initialize shadow lane
425  const double overlap = myVehicle.getLateralOverlap(posLat);
426 #ifdef DEBUG_SHADOWLANE
427  if (debugVehicle()) {
428  std::cout << SIMTIME << " veh=" << myVehicle.getID() << " posLat=" << posLat << " overlap=" << overlap << "\n";
429  }
430 #endif
431  if (myAmOpposite) {
432  // return the neigh-lane in forward direction
433  return lane->getParallelLane(1);
434  } else if (overlap > NUMERICAL_EPS) {
435  const int shadowDirection = posLat < 0 ? -1 : 1;
436  return lane->getParallelLane(shadowDirection);
437  } else if (isChangingLanes() && myLaneChangeCompletion < 0.5) {
438  // "reserve" target lane even when there is no overlap yet
440  } else {
441  return nullptr;
442  }
443  } else {
444  return nullptr;
445  }
446 }
447 
448 
449 MSLane*
452 }
453 
454 
455 void
457  if (myShadowLane != nullptr) {
458  if (debugVehicle()) {
459  std::cout << SIMTIME << " cleanupShadowLane\n";
460  }
462  myShadowLane = nullptr;
463  }
464  for (std::vector<MSLane*>::const_iterator it = myShadowFurtherLanes.begin(); it != myShadowFurtherLanes.end(); ++it) {
465  if (debugVehicle()) {
466  std::cout << SIMTIME << " cleanupShadowLane2\n";
467  }
468  (*it)->resetPartialOccupation(&myVehicle);
469  }
470  myShadowFurtherLanes.clear();
472 }
473 
474 void
476  if (myTargetLane != nullptr) {
477  if (debugVehicle()) {
478  std::cout << SIMTIME << " cleanupTargetLane\n";
479  }
481  myTargetLane = nullptr;
482  }
483  for (std::vector<MSLane*>::const_iterator it = myFurtherTargetLanes.begin(); it != myFurtherTargetLanes.end(); ++it) {
484  if (debugVehicle()) {
485  std::cout << SIMTIME << " cleanupTargetLane\n";
486  }
487  if (*it != nullptr) {
488  (*it)->resetManeuverReservation(&myVehicle);
489  }
490  }
491  myFurtherTargetLanes.clear();
492 // myNoPartiallyOccupatedByShadow.clear();
493 }
494 
495 
496 bool
497 MSAbstractLaneChangeModel::cancelRequest(int state, int laneOffset) {
498  // store request before canceling
499  getCanceledState(laneOffset) |= state;
500  int ret = myVehicle.influenceChangeDecision(state);
501  return ret != state;
502 }
503 
504 
505 void
507  if (dir > 0) {
509  } else if (dir < 0) {
511  }
512 }
513 
514 void
516  if (!haveLateralDynamics()) {
517  // assume each vehicle drives at the center of its lane and act as if it fits
518  return;
519  }
520  if (myShadowLane != nullptr) {
521 #ifdef DEBUG_SHADOWLANE
522  if (debugVehicle()) {
523  std::cout << SIMTIME << " updateShadowLane()\n";
524  }
525 #endif
527  }
529  std::vector<MSLane*> passed;
530  if (myShadowLane != nullptr) {
532  const std::vector<MSLane*>& further = myVehicle.getFurtherLanes();
533  const std::vector<double>& furtherPosLat = myVehicle.getFurtherLanesPosLat();
534  assert(further.size() == furtherPosLat.size());
535  passed.push_back(myShadowLane);
536  for (int i = 0; i < (int)further.size(); ++i) {
537  MSLane* shadowFurther = getShadowLane(further[i], furtherPosLat[i]);
538 #ifdef DEBUG_SHADOWLANE
539  if (debugVehicle()) {
540  std::cout << SIMTIME << " further=" << further[i]->getID() << " (posLat=" << furtherPosLat[i] << ") shadowFurther=" << Named::getIDSecure(shadowFurther) << "\n";
541  }
542 #endif
543  if (shadowFurther != nullptr && MSLinkContHelper::getConnectingLink(*shadowFurther, *passed.back()) != nullptr) {
544  passed.push_back(shadowFurther);
545  }
546  }
547  std::reverse(passed.begin(), passed.end());
548  } else {
550  WRITE_WARNING("Vehicle '" + myVehicle.getID() + "' could not finish continuous lane change (lane disappeared) time=" +
551  time2string(MSNet::getInstance()->getCurrentTimeStep()) + ".");
553  }
554  }
555 #ifdef DEBUG_SHADOWLANE
556  if (debugVehicle()) {
557  std::cout << SIMTIME << " updateShadowLane() veh=" << myVehicle.getID()
558  << " newShadowLane=" << Named::getIDSecure(myShadowLane)
559  << "\n before:" << " myShadowFurtherLanes=" << toString(myShadowFurtherLanes) << " further=" << toString(myVehicle.getFurtherLanes()) << " passed=" << toString(passed);
560  std::cout << std::endl;
561  }
562 #endif
564 #ifdef DEBUG_SHADOWLANE
565  if (debugVehicle()) std::cout
566  << "\n after:" << " myShadowFurtherLanes=" << toString(myShadowFurtherLanes) << "\n";
567 #endif
568 }
569 
570 
571 int
573  if (isChangingLanes()) {
574  if (pastMidpoint()) {
575  return -myLaneChangeDirection;
576  } else {
577  return myLaneChangeDirection;
578  }
579  } else if (myShadowLane == nullptr) {
580  return 0;
581  } else if (myAmOpposite) {
582  // return neigh-lane in forward direction
583  return 1;
584  } else {
585  assert(&myShadowLane->getEdge() == &myVehicle.getLane()->getEdge());
587  }
588 }
589 
590 
591 MSLane*
593 #ifdef DEBUG_TARGET_LANE
594  MSLane* oldTarget = myTargetLane;
595  std::vector<MSLane*> oldFurtherTargets = myFurtherTargetLanes;
596  if (debugVehicle()) {
597  std::cout << SIMTIME << " veh '" << myVehicle.getID() << "' (lane=" << myVehicle.getLane()->getID() << ") updateTargetLane()"
598  << "\n oldTarget: " << (oldTarget == nullptr ? "NULL" : oldTarget->getID())
599  << " oldFurtherTargets: " << toString(oldFurtherTargets);
600  }
601 #endif
602  if (myTargetLane != nullptr) {
604  }
605  // Clear old further target lanes
606  for (MSLane* oldTargetLane : myFurtherTargetLanes) {
607  if (oldTargetLane != nullptr) {
608  oldTargetLane->resetManeuverReservation(&myVehicle);
609  }
610  }
611  myFurtherTargetLanes.clear();
612 
613  // Get new target lanes and issue a maneuver reservation.
614  int targetDir;
615  myTargetLane = determineTargetLane(targetDir);
616  if (myTargetLane != nullptr) {
618  // further targets are just the target lanes corresponding to the vehicle's further lanes
619  // @note In a neglectable amount of situations we might add a reservation for a shadow further lane.
620  for (MSLane* furtherLane : myVehicle.getFurtherLanes()) {
621  MSLane* furtherTargetLane = furtherLane->getParallelLane(targetDir);
622  myFurtherTargetLanes.push_back(furtherTargetLane);
623  if (furtherTargetLane != nullptr) {
624  furtherTargetLane->setManeuverReservation(&myVehicle);
625  }
626  }
627  }
628 #ifdef DEBUG_TARGET_LANE
629  if (debugVehicle()) {
630  std::cout << "\n newTarget (offset=" << targetDir << "): " << (myTargetLane == nullptr ? "NULL" : myTargetLane->getID())
631  << " newFurtherTargets: " << toString(myFurtherTargetLanes)
632  << std::endl;
633  }
634 #endif
635  return myTargetLane;
636 }
637 
638 
639 MSLane*
641  targetDir = 0;
642  if (myManeuverDist == 0) {
643  return nullptr;
644  }
645  // Current lateral boundaries of the vehicle
646  const double vehRight = myVehicle.getLateralPositionOnLane() - 0.5 * myVehicle.getWidth();
647  const double vehLeft = myVehicle.getLateralPositionOnLane() + 0.5 * myVehicle.getWidth();
648  const double halfLaneWidth = 0.5 * myVehicle.getLane()->getWidth();
649 
650  if (vehRight + myManeuverDist < -halfLaneWidth) {
651  // Vehicle intends to traverse the right lane boundary
652  targetDir = -1;
653  } else if (vehLeft + myManeuverDist > halfLaneWidth) {
654  // Vehicle intends to traverse the left lane boundary
655  targetDir = 1;
656  }
657  if (targetDir == 0) {
658  // Presently, no maneuvering into another lane is begun.
659  return nullptr;
660  }
661  MSLane* target = myVehicle.getLane()->getParallelLane(targetDir);
662  if (target == nullptr || target == myShadowLane) {
663  return nullptr;
664  } else {
665  return target;
666  }
667 }
668 
669 
670 
671 double
674  return myLaneChangeDirection * angleOffset;
675 }
676 
677 
678 double
679 MSAbstractLaneChangeModel::estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel) const {
680 
682  if (lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING) == lcParams.end() && lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR) == lcParams.end()) {
684  // no dependency of lateral speed on longitudinal speed. (Only called prior to LC initialization to determine whether it could be completed)
686  } else {
687  return remainingManeuverDist / myVehicle.getVehicleType().getMaxSpeedLat();
688  }
689  }
690 
691  if (remainingManeuverDist == 0) {
692  return 0;
693  }
694 
695  // Check argument assumptions
696  assert(speed >= 0);
697  assert(remainingManeuverDist >= 0);
698  assert(decel > 0);
699  assert(myVehicle.getVehicleType().getMaxSpeedLat() > 0);
701  assert(myMaxSpeedLatStanding >= 0);
702 
703  // for brevity
704  const double v0 = speed;
705  const double D = remainingManeuverDist;
706  const double b = decel;
707  const double wmin = myMaxSpeedLatStanding;
708  const double f = myMaxSpeedLatFactor;
709  const double wmax = myVehicle.getVehicleType().getMaxSpeedLat();
710 
711  /* Here's the approach for the calculation of the required time for the LC:
712  * To obtain the maximal LC-duration, for v(t) we assume that v(t)=max(0, v0-b*t),
713  * Where v(t)=0 <=> t >= ts:=v0/b
714  * For the lateral speed w(t) this gives:
715  * w(t) = min(wmax, wmin + f*v(t))
716  * The lateral distance covered until t is
717  * d(t) = int_0^t w(s) ds
718  * We distinguish three possibilities for the solution d(T)=D, where T is the time of the LC completion.
719  * 1) w(T) = wmax, i.e. v(T)>(wmax-wmin)/f
720  * 2) wmin < w(T) < wmax, i.e. (wmax-wmin)/f > v(T) > 0
721  * 3) w(T) = wmin, i.e., v(T)=0
722  */
723  const double vm = (wmax - wmin) / f;
724  double distSoFar = 0.;
725  double timeSoFar = 0.;
726  double v = v0;
727  if (v > vm) {
728  const double wmaxTime = (v0 - vm) / b;
729  const double d1 = wmax * wmaxTime;
730  if (d1 >= D) {
731  return D / wmax;
732  } else {
733  distSoFar += d1;
734  timeSoFar += wmaxTime;
735  v = vm;
736  }
737  }
738  if (v > 0) {
739  /* Here, w(t1+t) = wmin + f*v(t1+t) = wmin + f*(v - b*t)
740  * Thus, the additional lateral distance covered after time t is:
741  * d2 = (wmin + f*v)*t - 0.5*f*b*t^2
742  * and the additional lateral distance covered until v=0 at t=v/b is:
743  * d2 = (wmin + 0.5*f*v)*t
744  */
745  const double t = v / b; // stop time
746  const double d2 = (wmin + 0.5 * f * v) * t; // lateral distance covered until stop
747  assert(d2 > 0);
748  if (distSoFar + d2 >= D) {
749  // LC is completed during this phase
750  const double x = 0.5 * f * b;
751  const double y = wmin + f * v;
752  /* Solve D - distSoFar = y*t - x*t^2.
753  * 0 = x*t^2 - y*t/x + (D - distSoFar)/x
754  */
755  const double p = 0.5 * y / x;
756  const double q = (D - distSoFar) / x;
757  assert(p * p - q > 0);
758  const double t2 = p + sqrt(p * p - q);
759  return timeSoFar + t2;
760  } else {
761  distSoFar += d2;
762  timeSoFar += t;
763  //v = 0;
764  }
765  }
766  // If we didn't return yet this means the LC was not completed until the vehicle stops (if braking with rate b)
767  if (wmin == 0) {
768  // LC won't be completed if vehicle stands
769  return -1;
770  } else {
771  // complete LC with lateral speed wmin
772  return timeSoFar + (D - distSoFar) / wmin;
773  }
774 }
775 
776 SUMOTime
778  assert(isChangingLanes()); // Only to be called during ongoing lane change
780  if (lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING) == lcParams.end() && lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR) == lcParams.end()) {
783  } else {
785  }
786  }
787  // Using maxSpeedLat(Factor/Standing)
789 }
790 
791 
792 void
794  //std::cout << SIMTIME << " veh=" << myVehicle.getID() << " @=" << &myVehicle << " set shadow approaching=" << link->getViaLaneOrLane()->getID() << "\n";
795  myApproachedByShadow.push_back(link);
796 }
797 
798 void
800  for (std::vector<MSLink*>::iterator it = myApproachedByShadow.begin(); it != myApproachedByShadow.end(); ++it) {
801  //std::cout << SIMTIME << " veh=" << myVehicle.getID() << " @=" << &myVehicle << " remove shadow approaching=" << (*it)->getViaLaneOrLane()->getID() << "\n";
802  (*it)->removeApproaching(&myVehicle);
803  }
804  myApproachedByShadow.clear();
805 }
806 
807 
808 
809 void
812  int oldstate = myVehicle.getLaneChangeModel().getOwnState();
813  if (myOwnState != newstate) {
815  // Calculate and set the lateral maneuver distance corresponding to the change request
816  // to induce a corresponding sublane change.
817  const int dir = (newstate & LCA_RIGHT) != 0 ? -1 : ((newstate & LCA_LEFT) != 0 ? 1 : 0);
818  // minimum distance to move the vehicle fully onto the lane at offset dir
819  const double latLaneDist = myVehicle.lateralDistanceToLane(dir);
820  if ((newstate & LCA_TRACI) != 0) {
821  if ((newstate & LCA_STAY) != 0) {
822  setManeuverDist(0.);
823  } else if (((newstate & LCA_RIGHT) != 0 && dir < 0)
824  || ((newstate & LCA_LEFT) != 0 && dir > 0)) {
825  setManeuverDist(latLaneDist);
826  }
827  }
828  if (myVehicle.hasInfluencer()) {
829  // lane change requests override sublane change requests
831  }
832 
833  }
834  setOwnState(newstate);
835  } else {
836  // Check for sublane change requests
838  const double maneuverDist = myVehicle.getInfluencer().getLatDist();
841  newstate |= LCA_TRACI;
842  if (myOwnState != newstate) {
843  setOwnState(newstate);
844  }
845  if (gDebugFlag2) {
846  std::cout << " traci influenced maneuverDist=" << maneuverDist << "\n";
847  }
848  }
849  }
850  if (gDebugFlag2) {
851  std::cout << SIMTIME << " veh=" << myVehicle.getID() << " stateAfterTraCI=" << toString((LaneChangeAction)newstate) << " original=" << toString((LaneChangeAction)oldstate) << "\n";
852  }
853 }
854 
855 void
858  myAlreadyChanged = true;
859 }
860 
861 void
863  if (follower.first != 0) {
864  myLastFollowerGap = follower.second + follower.first->getVehicleType().getMinGap();
865  myLastFollowerSecureGap = secGap;
866  myLastFollowerSpeed = follower.first->getSpeed();
867  }
868 }
869 
870 void
872  if (leader.first != 0) {
873  myLastLeaderGap = leader.second + myVehicle.getVehicleType().getMinGap();
874  myLastLeaderSecureGap = secGap;
875  myLastLeaderSpeed = leader.first->getSpeed();
876  }
877 }
878 
879 void
881  if (leader.first != 0) {
883  myLastOrigLeaderSecureGap = secGap;
884  myLastOrigLeaderSpeed = leader.first->getSpeed();
885  }
886 }
887 
888 void
898  if (!myDontResetLCGaps) {
908  }
909  myCommittedSpeed = 0;
910 }
911 
912 void
914  int rightmost;
915  int leftmost;
916  vehicles.getSubLanes(&myVehicle, 0, rightmost, leftmost);
917  for (int i = rightmost; i <= leftmost; ++i) {
918  CLeaderDist vehDist = vehicles[i];
919  if (vehDist.first != 0) {
920  const MSVehicle* leader = &myVehicle;
921  const MSVehicle* follower = vehDist.first;
922  const double netGap = vehDist.second + follower->getVehicleType().getMinGap();
923  if (netGap < myLastFollowerGap && netGap >= 0) {
924  myLastFollowerGap = netGap;
925  myLastFollowerSecureGap = follower->getCarFollowModel().getSecureGap(follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel());
926  myLastFollowerSpeed = follower->getSpeed();
927  }
928  }
929  }
930 }
931 
932 void
934  int rightmost;
935  int leftmost;
936  vehicles.getSubLanes(&myVehicle, 0, rightmost, leftmost);
937  for (int i = rightmost; i <= leftmost; ++i) {
938  CLeaderDist vehDist = vehicles[i];
939  if (vehDist.first != 0) {
940  const MSVehicle* leader = vehDist.first;
941  const MSVehicle* follower = &myVehicle;
942  const double netGap = vehDist.second + follower->getVehicleType().getMinGap();
943  if (netGap < myLastLeaderGap && netGap >= 0) {
944  myLastLeaderGap = netGap;
945  myLastLeaderSecureGap = follower->getCarFollowModel().getSecureGap(follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel());
946  myLastLeaderSpeed = leader->getSpeed();
947  }
948  }
949  }
950 }
951 
952 void
954  int rightmost;
955  int leftmost;
956  vehicles.getSubLanes(&myVehicle, 0, rightmost, leftmost);
957  for (int i = rightmost; i <= leftmost; ++i) {
958  CLeaderDist vehDist = vehicles[i];
959  if (vehDist.first != 0) {
960  const MSVehicle* leader = vehDist.first;
961  const MSVehicle* follower = &myVehicle;
962  const double netGap = vehDist.second + follower->getVehicleType().getMinGap();
963  if (netGap < myLastOrigLeaderGap && netGap >= 0) {
964  myLastOrigLeaderGap = netGap;
965  myLastOrigLeaderSecureGap = follower->getCarFollowModel().getSecureGap(follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel());
966  myLastOrigLeaderSpeed = leader->getSpeed();
967  }
968  }
969  }
970 }
971 
972 
973 bool
975  const int stateRight = mySavedStateRight.second;
976  if (
977  (stateRight & LCA_STRATEGIC) != 0
978  && (stateRight & LCA_RIGHT) != 0
979  && (stateRight & LCA_BLOCKED) != 0) {
980  return true;
981  }
982  const int stateLeft = mySavedStateLeft.second;
983  if (
984  (stateLeft & LCA_STRATEGIC) != 0
985  && (stateLeft & LCA_LEFT) != 0
986  && (stateLeft & LCA_BLOCKED) != 0) {
987  return true;
988  }
989  return false;
990 }
SUMOVTypeParameter::SubParams
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
Definition: SUMOVTypeParameter.h:190
MSAbstractLaneChangeModel::myTargetLane
MSLane * myTargetLane
The target lane for the vehicle's current maneuver.
Definition: MSAbstractLaneChangeModel.h:650
MSAbstractLaneChangeModel::myShadowLane
MSLane * myShadowLane
A lane that is partially occupied by the front of the vehicle but that is not the primary lane.
Definition: MSAbstractLaneChangeModel.h:636
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:135
SUMO_ATTR_TYPE
@ SUMO_ATTR_TYPE
Definition: SUMOXMLDefinitions.h:381
MSMoveReminder::NOTIFICATION_LANE_CHANGE
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
Definition: MSMoveReminder.h:99
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
MSAbstractLaneChangeModel::mySavedStateLeft
std::pair< int, int > mySavedStateLeft
Definition: MSAbstractLaneChangeModel.h:600
MSVehicle::VEH_SIGNAL_BLINKER_LEFT
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
Definition: MSVehicle.h:1185
LCA_MLEFT
@ LCA_MLEFT
Definition: SUMOXMLDefinitions.h:1289
SPEED2DIST
#define SPEED2DIST(x)
Definition: SUMOTime.h:46
MSAbstractLaneChangeModel::myAmOpposite
bool myAmOpposite
whether the vehicle is driving in the opposite direction
Definition: MSAbstractLaneChangeModel.h:725
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:93
MSAbstractLaneChangeModel::myPreviousManeuverDist
double myPreviousManeuverDist
Maneuver distance from the previous simulation step.
Definition: MSAbstractLaneChangeModel.h:630
MSCFModel::getMaxDecel
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:217
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
DIST2SPEED
#define DIST2SPEED(x)
Definition: SUMOTime.h:48
MSAbstractLaneChangeModel::~MSAbstractLaneChangeModel
virtual ~MSAbstractLaneChangeModel()
Destructor.
Definition: MSAbstractLaneChangeModel.cpp:136
MSNet.h
MSAbstractLaneChangeModel::myLastFollowerSpeed
double myLastFollowerSpeed
Definition: MSAbstractLaneChangeModel.h:688
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSAbstractLaneChangeModel::updateCompletion
bool updateCompletion()
Definition: MSAbstractLaneChangeModel.cpp:390
MSAbstractLaneChangeModel::myLastOrigLeaderSpeed
double myLastOrigLeaderSpeed
Definition: MSAbstractLaneChangeModel.h:689
LCA_LEFT
@ LCA_LEFT
Wants go to the left.
Definition: SUMOXMLDefinitions.h:1226
MSAbstractLaneChangeModel::cancelRequest
bool cancelRequest(int state, int laneOffset)
whether the influencer cancels the given request
Definition: MSAbstractLaneChangeModel.cpp:497
MSLeaderDistanceInfo
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:132
MSLane::resetPartialOccupation
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:284
MSAbstractLaneChangeModel::myAllowOvertakingRight
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
Definition: MSAbstractLaneChangeModel.h:707
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSVehicle::VEH_SIGNAL_BLINKER_RIGHT
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
Definition: MSVehicle.h:1183
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
MSVehicle::influenceChangeDecision
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
Definition: MSVehicle.cpp:5924
MSVehicle::setTentativeLaneAndPosition
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
Definition: MSVehicle.cpp:5311
MSVehicle::hasInfluencer
bool hasInfluencer() const
Definition: MSVehicle.h:1777
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:148
MSAbstractLaneChangeModel::myLCStartedOutput
static bool myLCStartedOutput
Definition: MSAbstractLaneChangeModel.h:711
MSAbstractLaneChangeModel::setOrigLeaderGaps
void setOrigLeaderGaps(CLeaderDist, double secGap)
Definition: MSAbstractLaneChangeModel.cpp:880
OptionsCont.h
MSAbstractLaneChangeModel::myLastLeaderSpeed
double myLastLeaderSpeed
speeds of surrounding vehicles at the time of lane change
Definition: MSAbstractLaneChangeModel.h:687
LCM_DEFAULT
@ LCM_DEFAULT
Definition: SUMOXMLDefinitions.h:1307
LaneChangeModel
LaneChangeModel
Definition: SUMOXMLDefinitions.h:1303
MSAbstractLaneChangeModel::myLCOutput
static bool myLCOutput
whether to record lane-changing
Definition: MSAbstractLaneChangeModel.h:710
MSAbstractLaneChangeModel::setManeuverDist
void setManeuverDist(const double dist)
Updates the remaining distance for the current maneuver while it is continued within non-action steps...
Definition: MSAbstractLaneChangeModel.cpp:153
MSCFModel::getSecureGap
virtual double getSecureGap(const MSVehicle *const, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
Definition: MSCFModel.h:329
LCA_AMBLOCKINGLEADER
@ LCA_AMBLOCKINGLEADER
Definition: SUMOXMLDefinitions.h:1286
MSVehicleType::getMaxSpeedLat
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
Definition: MSVehicleType.h:313
MSAbstractLaneChangeModel::myManeuverDist
double myManeuverDist
The complete lateral distance the vehicle wants to travel to finish its maneuver Only used by sublane...
Definition: MSAbstractLaneChangeModel.h:627
MSAbstractLaneChangeModel::myShadowFurtherLanes
std::vector< MSLane * > myShadowFurtherLanes
Definition: MSAbstractLaneChangeModel.h:639
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSAbstractLaneChangeModel::myLastLeaderSecureGap
double myLastLeaderSecureGap
the minimum longitudinal distances to vehicles on the target lane that would be necessary for stringe...
Definition: MSAbstractLaneChangeModel.h:681
MSAbstractLaneChangeModel::setOwnState
virtual void setOwnState(const int state)
Definition: MSAbstractLaneChangeModel.cpp:140
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:222
MSAbstractLaneChangeModel::myAlreadyChanged
bool myAlreadyChanged
whether the vehicle has already moved this step
Definition: MSAbstractLaneChangeModel.h:633
MSAbstractLaneChangeModel::setLeaderGaps
void setLeaderGaps(CLeaderDist, double secGap)
Definition: MSAbstractLaneChangeModel.cpp:871
SUMO_ATTR_SPEED
@ SUMO_ATTR_SPEED
Definition: SUMOXMLDefinitions.h:384
MSAbstractLaneChangeModel::initLastLaneChangeOffset
void initLastLaneChangeOffset(int dir)
Definition: MSAbstractLaneChangeModel.cpp:506
SUMO_ATTR_ID
@ SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
MSEdge.h
MSAbstractLaneChangeModel::myLastLaneChangeOffset
SUMOTime myLastLaneChangeOffset
Definition: MSAbstractLaneChangeModel.h:719
MSAbstractLaneChangeModel::getLeaders
const std::shared_ptr< MSLeaderDistanceInfo > getLeaders(const int dir)
Returns the neighboring, lc-relevant leaders for the last step in the requested direction.
Definition: MSAbstractLaneChangeModel.cpp:231
MSAbstractLaneChangeModel::myFurtherTargetLanes
std::vector< MSLane * > myFurtherTargetLanes
Definition: MSAbstractLaneChangeModel.h:658
MSLane::forceVehicleInsertion
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1024
SUMO_ATTR_LCA_MAXSPEEDLATFACTOR
@ SUMO_ATTR_LCA_MAXSPEEDLATFACTOR
Definition: SUMOXMLDefinitions.h:603
MSAbstractLaneChangeModel::myLastLateralGapLeft
double myLastLateralGapLeft
the minimum lateral gaps to other vehicles that were found when last changing to the left and right
Definition: MSAbstractLaneChangeModel.h:674
MSAbstractLaneChangeModel::myNoPartiallyOccupatedByShadow
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
Definition: MSAbstractLaneChangeModel.h:671
MSVehicle::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:893
MSAbstractLaneChangeModel::myLaneChangeCompletion
double myLaneChangeCompletion
progress of the lane change maneuver 0:started, 1:complete
Definition: MSAbstractLaneChangeModel.h:620
SUMO_ATTR_DIR
@ SUMO_ATTR_DIR
The abstract direction of a link.
Definition: SUMOXMLDefinitions.h:706
MSAbstractLaneChangeModel::myLastOrigLeaderGap
double myLastOrigLeaderGap
acutal and secure distance to closest leader vehicle on the original when performing lane change
Definition: MSAbstractLaneChangeModel.h:684
MSAbstractLaneChangeModel::updateTargetLane
MSLane * updateTargetLane()
Definition: MSAbstractLaneChangeModel.cpp:592
MSAbstractLaneChangeModel::isChangingLanes
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
Definition: MSAbstractLaneChangeModel.h:441
SUMOVTypeParameter::getLCParams
const SubParams & getLCParams() const
Returns the LC parameter.
Definition: SUMOVTypeParameter.cpp:498
MSAbstractLaneChangeModel::myApproachedByShadow
std::vector< MSLink * > myApproachedByShadow
links which are approached by the shadow vehicle
Definition: MSAbstractLaneChangeModel.h:722
MSGlobals::gLateralResolution
static double gLateralResolution
Definition: MSGlobals.h:84
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
MSAbstractLaneChangeModel::myLastLeaderGap
double myLastLeaderGap
the actual minimum longitudinal distances to vehicles on the target lane
Definition: MSAbstractLaneChangeModel.h:678
MSAbstractLaneChangeModel::startLaneChangeManeuver
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
Definition: MSAbstractLaneChangeModel.cpp:278
MSCFModel::interactionGap
virtual double interactionGap(const MSVehicle *const veh, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
Definition: MSCFModel.cpp:223
MSAbstractLaneChangeModel::getAngleOffset
double getAngleOffset() const
return the angle offset during a continuous change maneuver
Definition: MSAbstractLaneChangeModel.cpp:672
MSVehicle::getLateralPositionOnLane
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:429
SUMO_ATTR_TO
@ SUMO_ATTR_TO
Definition: SUMOXMLDefinitions.h:640
SUMO_ATTR_LCA_MAXSPEEDLATSTANDING
@ SUMO_ATTR_LCA_MAXSPEEDLATSTANDING
Definition: SUMOXMLDefinitions.h:602
MSAbstractLaneChangeModel::removeShadowApproachingInformation
void removeShadowApproachingInformation() const
Definition: MSAbstractLaneChangeModel.cpp:799
MSVehicle::switchOffSignal
void switchOffSignal(int signal)
Switches the given signal off.
Definition: MSVehicle.h:1244
MSVehicle::fixPosition
void fixPosition()
repair errors in vehicle position after changing between internal edges
Definition: MSVehicle.cpp:5105
MSVehicle::switchOnSignal
void switchOnSignal(int signal)
Switches the given signal on.
Definition: MSVehicle.h:1236
VTYPEPARS_MAXSPEED_LAT_SET
const int VTYPEPARS_MAXSPEED_LAT_SET
Definition: SUMOVTypeParameter.h:65
MSAbstractLaneChangeModel::mySavedStateRight
std::pair< int, int > mySavedStateRight
Definition: MSAbstractLaneChangeModel.h:598
MSAbstractLaneChangeModel::memorizeGapsAtLCInit
void memorizeGapsAtLCInit()
Control for resetting the memorized values for LC relevant gaps until the LC output is triggered in t...
Definition: MSAbstractLaneChangeModel.cpp:296
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
MSLeaderInfo::getSubLanes
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
Definition: MSLeaderInfo.cpp:105
MSAbstractLaneChangeModel::myLastLateralGapRight
double myLastLateralGapRight
Definition: MSAbstractLaneChangeModel.h:675
MSVehicle::leaveLane
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
Definition: MSVehicle.cpp:4627
SIMTIME
#define SIMTIME
Definition: SUMOTime.h:63
MSAbstractLaneChangeModel::myLaneChangeDirection
int myLaneChangeDirection
direction of the lane change maneuver -1 means right, 1 means left
Definition: MSAbstractLaneChangeModel.h:623
MSLCM_LC2013.h
MSAbstractLaneChangeModel::saveNeighbors
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...
Definition: MSAbstractLaneChangeModel.cpp:179
LCA_STRATEGIC
@ LCA_STRATEGIC
The action is needed to follow the route (navigational lc)
Definition: SUMOXMLDefinitions.h:1230
MSAbstractLaneChangeModel::clearGapsAtLCInit
void clearGapsAtLCInit()
Definition: MSAbstractLaneChangeModel.cpp:301
MSAbstractLaneChangeModel::myLeftLeaders
std::shared_ptr< MSLeaderDistanceInfo > myLeftLeaders
Definition: MSAbstractLaneChangeModel.h:608
MSVehicle::getPositionOnLane
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:392
MSAbstractLaneChangeModel::getCanceledState
int & getCanceledState(const int dir)
Definition: MSAbstractLaneChangeModel.h:232
MSAbstractLaneChangeModel::myLastFollowerSecureGap
double myLastFollowerSecureGap
Definition: MSAbstractLaneChangeModel.h:682
MSAbstractLaneChangeModel::myRightLeaders
std::shared_ptr< MSLeaderDistanceInfo > myRightLeaders
Definition: MSAbstractLaneChangeModel.h:610
LaneChangeAction
LaneChangeAction
The state of a vehicle's lane-change behavior.
Definition: SUMOXMLDefinitions.h:1218
MSAbstractLaneChangeModel::MSAbstractLaneChangeModel
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
Definition: MSAbstractLaneChangeModel.cpp:94
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:58
MSAbstractLaneChangeModel::myMaxSpeedLatFactor
double myMaxSpeedLatFactor
Definition: MSAbstractLaneChangeModel.h:698
MSAbstractLaneChangeModel::getShadowLane
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
Definition: MSAbstractLaneChangeModel.h:380
MSAbstractLaneChangeModel::prepareStep
virtual void prepareStep()
Definition: MSAbstractLaneChangeModel.cpp:889
MSAbstractLaneChangeModel::myModel
const LaneChangeModel myModel
the type of this model
Definition: MSAbstractLaneChangeModel.h:664
MSAbstractLaneChangeModel::updateShadowLane
void updateShadowLane()
Definition: MSAbstractLaneChangeModel.cpp:515
MSLane::leftByLaneChange
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2652
MSAbstractLaneChangeModel::build
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
Definition: MSAbstractLaneChangeModel.cpp:71
MSVehicle::Influencer::resetLatDist
void resetLatDist()
Definition: MSVehicle.h:1690
MSAbstractLaneChangeModel::myPreviousState2
int myPreviousState2
lane changing state from step before the previous simulation step
Definition: MSAbstractLaneChangeModel.h:596
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
MSAbstractLaneChangeModel::congested
virtual bool congested(const MSVehicle *const neighLeader)
Definition: MSAbstractLaneChangeModel.cpp:245
MSAbstractLaneChangeModel::cleanupShadowLane
void cleanupShadowLane()
Definition: MSAbstractLaneChangeModel.cpp:456
MSVehicle::updateDriveItems
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
Definition: MSVehicle.cpp:3344
MSLane::getOppositePos
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:3527
ProcessError
Definition: UtilExceptions.h:39
MSVehicle::getLaneChangeModel
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:4680
MSAbstractLaneChangeModel::setShadowApproachingInformation
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
Definition: MSAbstractLaneChangeModel.cpp:793
MSAbstractLaneChangeModel::mySpeedLat
double mySpeedLat
the current lateral speed
Definition: MSAbstractLaneChangeModel.h:614
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
MSGlobals.h
MSVehicleType::getMinGap
double getMinGap() const
Get the free space in front of vehicles of this class.
Definition: MSVehicleType.h:125
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSAbstractLaneChangeModel::myLastFollowerGap
double myLastFollowerGap
Definition: MSAbstractLaneChangeModel.h:679
MSAbstractLaneChangeModel::getPreviousManeuverDist
double getPreviousManeuverDist() const
Definition: MSAbstractLaneChangeModel.cpp:174
MSLCM_SL2015
A lane change model developed by J. Erdmann.
Definition: MSLCM_SL2015.h:37
MSVehicle::getFurtherLanesPosLat
const std::vector< double > & getFurtherLanesPosLat() const
Definition: MSVehicle.h:795
MSLane::resetManeuverReservation
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition: MSLane.cpp:317
MSBaseVehicle::getVehicleType
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Definition: MSBaseVehicle.h:123
MSAbstractLaneChangeModel::getManeuverDist
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
Definition: MSAbstractLaneChangeModel.cpp:169
MSLane::setManeuverReservation
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition: MSLane.cpp:306
MSAbstractLaneChangeModel::myCommittedSpeed
double myCommittedSpeed
the speed when committing to a change maneuver
Definition: MSAbstractLaneChangeModel.h:617
SUMO_ATTR_TIME
@ SUMO_ATTR_TIME
trigger: the time of the step
Definition: SUMOXMLDefinitions.h:676
MSAbstractLaneChangeModel::haveLateralDynamics
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
Definition: MSAbstractLaneChangeModel.h:141
MSAbstractLaneChangeModel::remainingTime
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
Definition: MSAbstractLaneChangeModel.cpp:777
SUMO_ATTR_POSITION
@ SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:660
MSAbstractLaneChangeModel::checkTraCICommands
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
Definition: MSAbstractLaneChangeModel.cpp:810
SUMO_ATTR_FROM
@ SUMO_ATTR_FROM
Definition: SUMOXMLDefinitions.h:639
MSAbstractLaneChangeModel::myShadowFurtherLanesPosLat
std::vector< double > myShadowFurtherLanesPosLat
Definition: MSAbstractLaneChangeModel.h:640
MSVehicle::getLane
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:560
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
MSAbstractLaneChangeModel::pastMidpoint
bool pastMidpoint() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver
Definition: MSAbstractLaneChangeModel.h:420
DEBUG_COND
#define DEBUG_COND
Definition: MSAbstractLaneChangeModel.cpp:29
MSAbstractLaneChangeModel::clearNeighbors
void clearNeighbors()
Clear info on neighboring vehicle from previous step.
Definition: MSAbstractLaneChangeModel.cpp:209
MSAbstractLaneChangeModel::changed
virtual void changed()=0
MSVehicle::getInfluencer
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:5900
MSAbstractLaneChangeModel::setFollowerGaps
void setFollowerGaps(CLeaderDist follower, double secGap)
Definition: MSAbstractLaneChangeModel.cpp:862
MSAbstractLaneChangeModel::debugVehicle
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
Definition: MSAbstractLaneChangeModel.h:362
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
MSLCM_SL2015.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
MSAbstractLaneChangeModel::myMaxSpeedLatStanding
double myMaxSpeedLatStanding
Definition: MSAbstractLaneChangeModel.h:696
LCA_RIGHT
@ LCA_RIGHT
Wants go to the right.
Definition: SUMOXMLDefinitions.h:1228
MSDriverState.h
MSVehicle::congested
bool congested() const
Definition: MSVehicle.h:717
MSVehicle::getFurtherLanes
const std::vector< MSLane * > & getFurtherLanes() const
Definition: MSVehicle.h:791
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSAbstractLaneChangeModel::myCarFollowModel
const MSCFModel & myCarFollowModel
The vehicle's car following model.
Definition: MSAbstractLaneChangeModel.h:661
LCA_STAY
@ LCA_STAY
Needs to stay on the current lane.
Definition: SUMOXMLDefinitions.h:1224
MSAbstractLaneChangeModel::estimateLCDuration
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...
Definition: MSAbstractLaneChangeModel.cpp:679
LCA_AMBACKBLOCKER_STANDING
@ LCA_AMBACKBLOCKER_STANDING
Definition: SUMOXMLDefinitions.h:1297
MSAbstractLaneChangeModel::myLCEndedOutput
static bool myLCEndedOutput
Definition: MSAbstractLaneChangeModel.h:712
MSAbstractLaneChangeModel::endLaneChangeManeuver
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
Definition: MSAbstractLaneChangeModel.cpp:401
MSVehicle::lateralDistanceToLane
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
Definition: MSVehicle.cpp:5443
MSAbstractLaneChangeModel::updateSafeLatDist
virtual void updateSafeLatDist(const double travelledLatDist)
Updates the value of safe lateral distances (in SL2015) during maneuver continuation in non-action st...
Definition: MSAbstractLaneChangeModel.cpp:147
MSVehicleType::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:82
MSAbstractLaneChangeModel::predInteraction
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
Definition: MSAbstractLaneChangeModel.cpp:265
MSAbstractLaneChangeModel::myOwnState
int myOwnState
The current state of the vehicle.
Definition: MSAbstractLaneChangeModel.h:592
MSAbstractLaneChangeModel::NO_NEIGHBOR
static const double NO_NEIGHBOR
Definition: MSAbstractLaneChangeModel.h:576
MSAbstractLaneChangeModel::laneChangeOutput
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)
Definition: MSAbstractLaneChangeModel.cpp:331
MSAbstractLaneChangeModel::saveLCState
void saveLCState(const int dir, const int stateWithoutTraCI, const int state)
Definition: MSAbstractLaneChangeModel.h:204
gDebugFlag2
bool gDebugFlag2
Definition: StdDefs.cpp:33
MSVehicleType::getParameter
const SUMOVTypeParameter & getParameter() const
Definition: MSVehicleType.h:560
MSBaseVehicle::getID
const std::string & getID() const
Returns the name of the vehicle.
Definition: MSBaseVehicle.cpp:138
MSLane::getParallelLane
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition: MSLane.cpp:2198
MSAbstractLaneChangeModel::isStrategicBlocked
bool isStrategicBlocked() const
Definition: MSAbstractLaneChangeModel.cpp:974
MSLCM_DK2008.h
MSLane::getWidth
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:556
MSBaseVehicle::getWidth
double getWidth() const
Returns the vehicle's width.
Definition: MSBaseVehicle.h:418
MSAbstractLaneChangeModel::getOwnState
int getOwnState() const
Definition: MSAbstractLaneChangeModel.h:174
MSAbstractLaneChangeModel::getShadowDirection
int getShadowDirection() const
return the direction in which the current shadow lane lies
Definition: MSAbstractLaneChangeModel.cpp:572
config.h
Named::getIDSecure
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:69
MSAbstractLaneChangeModel
Interface for lane-change models.
Definition: MSAbstractLaneChangeModel.h:45
MSVehicle::Influencer::getLatDist
double getLatDist() const
Definition: MSVehicle.h:1686
MSVehicle::updateFurtherLanes
double updateFurtherLanes(std::vector< MSLane * > &furtherLanes, std::vector< double > &furtherLanesPosLat, const std::vector< MSLane * > &passedLanes)
update a vector of further lanes and return the new backPos
Definition: MSVehicle.cpp:3986
MSVehicle::getSpeed
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:476
MSAbstractLaneChangeModel::myVehicle
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
Definition: MSAbstractLaneChangeModel.h:589
MSAbstractLaneChangeModel::cleanupTargetLane
void cleanupTargetLane()
Definition: MSAbstractLaneChangeModel.cpp:475
LCA_NONE
@ LCA_NONE
Definition: SUMOXMLDefinitions.h:1222
MSAbstractLaneChangeModel::myDontResetLCGaps
bool myDontResetLCGaps
Flag to prevent resetting the memorized values for LC relevant gaps until the LC output is triggered ...
Definition: MSAbstractLaneChangeModel.h:693
MSVehicle::getLateralOverlap
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane
Definition: MSVehicle.cpp:5493
MSGlobals::gLaneChangeDuration
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:81
MSLCM_LC2013
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013.
Definition: MSLCM_LC2013.h:47
MSLane.h
MSAbstractLaneChangeModel::computeSpeedLat
virtual double computeSpeedLat(double latDist, double &maneuverDist)
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
Definition: MSAbstractLaneChangeModel.cpp:373
MSAbstractLaneChangeModel::determineTargetLane
MSLane * determineTargetLane(int &targetDir) const
Definition: MSAbstractLaneChangeModel.cpp:640
CLeaderDist
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:34
LCA_AMBACKBLOCKER
@ LCA_AMBACKBLOCKER
Definition: SUMOXMLDefinitions.h:1296
MSLane::getSpeedLimit
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:532
LCA_MRIGHT
@ LCA_MRIGHT
Definition: SUMOXMLDefinitions.h:1288
MSLane::setPartialOccupation
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:267
MSAbstractLaneChangeModel::changedToOpposite
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
Definition: MSAbstractLaneChangeModel.cpp:856
MSAbstractLaneChangeModel::myPreviousState
int myPreviousState
lane changing state from the previous simulation step
Definition: MSAbstractLaneChangeModel.h:594
MSAbstractLaneChangeModel::myLastOrigLeaderSecureGap
double myLastOrigLeaderSecureGap
Definition: MSAbstractLaneChangeModel.h:685
MSVehicle::enterLaneAtLaneChange
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
Definition: MSVehicle.cpp:4516
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSAbstractLaneChangeModel::getFollowers
const std::shared_ptr< MSLeaderDistanceInfo > getFollowers(const int dir)
Returns the neighboring, lc-relevant followers for the last step in the requested direction.
Definition: MSAbstractLaneChangeModel.cpp:218
SUMO_ATTR_LCA_SIGMA
@ SUMO_ATTR_LCA_SIGMA
Definition: SUMOXMLDefinitions.h:607
MSAbstractLaneChangeModel::initGlobalOptions
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
Definition: MSAbstractLaneChangeModel.cpp:62
OutputDevice::getDeviceByOption
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
Definition: OutputDevice.cpp:116
MSLane::getIndex
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:563
LCA_UNKNOWN
@ LCA_UNKNOWN
The action has not been determined.
Definition: SUMOXMLDefinitions.h:1242
MSAbstractLaneChangeModel::primaryLaneChanged
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
Definition: MSAbstractLaneChangeModel.cpp:306
LCM_DK2008
@ LCM_DK2008
Definition: SUMOXMLDefinitions.h:1304
MSLCM_DK2008
A lane change model developed by D. Krajzewicz between 2004 and 2010.
Definition: MSLCM_DK2008.h:39
LCA_AMBLOCKINGFOLLOWER
@ LCA_AMBLOCKINGFOLLOWER
Definition: SUMOXMLDefinitions.h:1287
LCA_TRACI
@ LCA_TRACI
The action is due to a TraCI request.
Definition: SUMOXMLDefinitions.h:1238
MSLane::enteredByLaneChange
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2659
LCM_LC2013
@ LCM_LC2013
Definition: SUMOXMLDefinitions.h:1305
MSAbstractLaneChangeModel::getAssumedDecelForLaneChangeDuration
virtual double getAssumedDecelForLaneChangeDuration() const
Returns a deceleration value which is used for the estimation of the duration of a lane change.
Definition: MSAbstractLaneChangeModel.cpp:384
LCA_BLOCKED
@ LCA_BLOCKED
blocked in all directions
Definition: SUMOXMLDefinitions.h:1276
MSAbstractLaneChangeModel.h
MSAbstractLaneChangeModel::myRightFollowers
std::shared_ptr< MSLeaderDistanceInfo > myRightFollowers
Definition: MSAbstractLaneChangeModel.h:609
MSAbstractLaneChangeModel::myLeftFollowers
std::shared_ptr< MSLeaderDistanceInfo > myLeftFollowers
Cached info on lc-relevant neighboring vehicles.
Definition: MSAbstractLaneChangeModel.h:607
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
LCM_SL2015
@ LCM_SL2015
Definition: SUMOXMLDefinitions.h:1306