SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSLaneChanger.cpp
Go to the documentation of this file.
1 /****************************************************************************/
12 // Performs lane changing of vehicles
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include "MSLaneChanger.h"
36 #include "MSNet.h"
37 #include "MSVehicle.h"
38 #include "MSVehicleType.h"
39 #include "MSVehicleTransfer.h"
40 #include "MSGlobals.h"
41 #include <cassert>
42 #include <iterator>
43 #include <cstdlib>
44 #include <cmath>
47 
48 #ifdef CHECK_MEMORY_LEAKS
49 #include <foreign/nvwa/debug_new.h>
50 #endif // CHECK_MEMORY_LEAKS
51 
52 //#define DEBUG_VEHICLE_GUI_SELECTION 1
53 #ifdef DEBUG_VEHICLE_GUI_SELECTION
55 #include <guisim/GUIVehicle.h>
56 #include <guisim/GUILane.h>
57 #endif
58 
59 
60 // ===========================================================================
61 // member method definitions
62 // ===========================================================================
63 MSLaneChanger::MSLaneChanger(const std::vector<MSLane*>* lanes, bool allowSwap)
64  : myAllowsSwap(allowSwap) {
65  assert(lanes->size() > 1);
66 
67  // Fill the changer with the lane-data.
68  myChanger.reserve(lanes->size());
69  for (std::vector<MSLane*>::const_iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
70  ChangeElem ce;
71  ce.follow = 0;
72  ce.lead = 0;
73  ce.lane = *lane;
74  ce.veh = (*lane)->myVehicles.rbegin();
75  ce.hoppedVeh = 0;
76  ce.lastBlocked = 0;
77  ce.firstBlocked = 0;
78  myChanger.push_back(ce);
79  }
80 }
81 
82 
84 
85 
86 void
88  // This is what happens in one timestep. After initialization of the
89  // changer, each vehicle will try to change. After that the changer
90  // nedds an update to prevent multiple changes of one vehicle.
91  // Finally, the change-result has to be given back to the lanes.
92  initChanger();
93  while (vehInChanger()) {
94  bool haveChanged = change();
95  updateChanger(haveChanged);
96  }
97  updateLanes(t);
98 }
99 
100 
101 void
103  // Prepare myChanger with a safe state.
104  for (ChangerIt ce = myChanger.begin(); ce != myChanger.end(); ++ce) {
105  ce->lead = 0;
106  ce->hoppedVeh = 0;
107  ce->lastBlocked = 0;
108  ce->firstBlocked = 0;
109  ce->dens = 0;
110 
111  MSLane::VehCont& vehicles = ce->lane->myVehicles;
112  if (vehicles.empty()) {
113  ce->veh = vehicles.rend();
114  ce->follow = 0;
115  continue;
116  }
117  ce->veh = vehicles.rbegin();
118  if (vehicles.size() == 1) {
119  ce->follow = 0;
120  continue;
121  }
122  ce->follow = *(vehicles.rbegin() + 1);
123  }
124 }
125 
126 
127 bool
129  // Find change-candidate. If it is on an allowed lane, try to change
130  // to the right (there is a rule in Germany that you have to change
131  // to the right, unless you are overtaking). If change to the right
132  // isn't possible, check if there is a possibility to overtake (on the
133  // left.
134  // If candidate isn't on an allowed lane, changing to an allowed has
135  // priority.
137  MSVehicle* vehicle = veh(myCandi);
138 #ifdef DEBUG_VEHICLE_GUI_SELECTION
139  if (gSelected.isSelected(GLO_VEHICLE, static_cast<const GUIVehicle*>(vehicle)->getGlID())) {
140  int bla = 0;
141  }
142 #endif
143  if (vehicle->getLane() != (*myCandi).lane || vehicle->getLaneChangeModel().isChangingLanes()) {
144  // vehicles shadows and changing vehicles are not eligible
145  registerUnchanged(vehicle);
146  return false;
147  }
148 #ifndef NO_TRACI
149  if (vehicle->hasInfluencer() && vehicle->getInfluencer().isVTDControlled()) {
150  return false; // !!! temporary; just because it broke, here
151  }
152 #endif
153  vehicle->updateBestLanes(); // needed?
154  for (int i = 0; i < (int) myChanger.size(); ++i) {
155  vehicle->adaptBestLanesOccupation(i, myChanger[i].dens);
156  }
157  const std::vector<MSVehicle::LaneQ>& preb = vehicle->getBestLanes();
158  std::pair<MSVehicle* const, SUMOReal> leader = getRealThisLeader(myCandi);
159  // check whether the vehicle wants and is able to change to right lane
160  int state1 = 0;
161  if (myCandi != myChanger.begin() && (myCandi - 1)->lane->allowsVehicleClass(veh(myCandi)->getVehicleType().getVehicleClass())) {
162  state1 = checkChange(-1, leader, preb);
163  bool changingAllowed1 = (state1 & LCA_BLOCKED) == 0;
164  // change if the vehicle wants to and is allowed to change
165  if ((state1 & LCA_RIGHT) != 0 && changingAllowed1) {
166  startChange(vehicle, myCandi, -1);
167  return true;
168  }
169  if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
170  (myCandi - 1)->lastBlocked = vehicle;
171  if ((myCandi - 1)->firstBlocked == 0) {
172  (myCandi - 1)->firstBlocked = vehicle;
173  }
174  }
175  }
176 
177 
178 
179  // check whether the vehicle wants and is able to change to left lane
180  int state2 = 0;
181  if ((myCandi + 1) != myChanger.end() && (myCandi + 1)->lane->allowsVehicleClass(veh(myCandi)->getVehicleType().getVehicleClass())) {
182  state2 = checkChange(1, leader, preb);
183  bool changingAllowed2 = (state2 & LCA_BLOCKED) == 0;
184  // change if the vehicle wants to and is allowed to change
185  if ((state2 & LCA_LEFT) != 0 && changingAllowed2) {
186  startChange(vehicle, myCandi, 1);
187  return true;
188  }
189  if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
190  (myCandi + 1)->lastBlocked = vehicle;
191  if ((myCandi + 1)->firstBlocked == 0) {
192  (myCandi + 1)->firstBlocked = vehicle;
193  }
194  }
195  }
196 
197  if ((state1 & (LCA_URGENT)) != 0 && (state2 & (LCA_URGENT)) != 0) {
198  // ... wants to go to the left AND to the right
199  // just let them go to the right lane...
200  state2 = 0;
201  }
202  vehicle->getLaneChangeModel().setOwnState(state2 | state1);
203 
204  // check whether the vehicles should be swapped
205  if (myAllowsSwap && ((state1 & (LCA_URGENT)) != 0 || (state2 & (LCA_URGENT)) != 0)) {
206  // get the direction ...
207  ChangerIt target;
208  int direction = 0;
209  if ((state1 & (LCA_URGENT)) != 0) {
210  // ... wants to go right
211  target = myCandi - 1;
212  direction = -1;
213  }
214  if ((state2 & (LCA_URGENT)) != 0) {
215  // ... wants to go left
216  target = myCandi + 1;
217  direction = 1;
218  }
219  MSVehicle* prohibitor = target->lead;
220  if (target->hoppedVeh != 0) {
221  SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
222  if (prohibitor == 0 || (hoppedPos > vehicle->getPositionOnLane() && prohibitor->getPositionOnLane() > hoppedPos)) {
223  prohibitor = 0;// !!! vehicles should not jump over more than one lanetarget->hoppedVeh;
224  }
225  }
226  if (prohibitor != 0
227  &&
228  ((prohibitor->getLaneChangeModel().getOwnState() & (LCA_URGENT/*|LCA_SPEEDGAIN*/)) != 0
229  &&
230  (prohibitor->getLaneChangeModel().getOwnState() & (LCA_LEFT | LCA_RIGHT))
231  !=
232  (vehicle->getLaneChangeModel().getOwnState() & (LCA_LEFT | LCA_RIGHT))
233  )
234  ) {
235 
236  // check for position and speed
237  if (prohibitor->getVehicleType().getLengthWithGap() - vehicle->getVehicleType().getLengthWithGap() == 0) {
238  // ok, may be swapped
239  // remove vehicle to swap with
240  MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
241  if (i != target->lane->myTmpVehicles.end()) {
242  assert(*i == prohibitor);
243  target->lane->myTmpVehicles.erase(i);
244  // set this vehicle
245  target->hoppedVeh = vehicle;
246  target->lane->myTmpVehicles.insert(target->lane->myTmpVehicles.begin(), vehicle);
247  myCandi->hoppedVeh = prohibitor;
248  myCandi->lane->myTmpVehicles.insert(myCandi->lane->myTmpVehicles.begin(), prohibitor);
249 
250  // leave lane and detectors
253  // patch position and speed
254  SUMOReal p1 = vehicle->getPositionOnLane();
255  vehicle->myState.myPos = prohibitor->myState.myPos;
256  prohibitor->myState.myPos = p1;
257  p1 = vehicle->getSpeed();
258  vehicle->myState.mySpeed = prohibitor->myState.mySpeed;
259  prohibitor->myState.mySpeed = p1;
260  // enter lane and detectors
261  vehicle->enterLaneAtLaneChange(target->lane);
262  prohibitor->enterLaneAtLaneChange(myCandi->lane);
263  // mark lane change
264  vehicle->getLaneChangeModel().changed(direction);
265  prohibitor->getLaneChangeModel().changed(-direction);
266  (myCandi)->dens += prohibitor->getVehicleType().getLengthWithGap();
267  (target)->dens += vehicle->getVehicleType().getLengthWithGap();
268  return true;
269  }
270  }
271  }
272  }
273  registerUnchanged(vehicle);
274  return false;
275 }
276 
277 
278 void
280  myCandi->lane->myTmpVehicles.insert(myCandi->lane->myTmpVehicles.begin(), veh(myCandi));
281  vehicle->getLaneChangeModel().unchanged();
282  (myCandi)->dens += vehicle->getVehicleType().getLengthWithGap();
283 }
284 
285 
286 void
287 MSLaneChanger::startChange(MSVehicle* vehicle, ChangerIt& from, int direction) {
288  ChangerIt to = from + direction;
289  to->hoppedVeh = vehicle;
290  // @todo delay entering the target lane until the vehicle intersects it
291  // physically (considering lane width and vehicle width)
292  to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
293  const bool continuous = vehicle->getLaneChangeModel().startLaneChangeManeuver(from->lane, to->lane, direction);
294  if (continuous) {
295  from->lane->myTmpVehicles.insert(from->lane->myTmpVehicles.begin(), vehicle);
296  from->dens += vehicle->getVehicleType().getLengthWithGap();
297  }
298  to->dens += to->hoppedVeh->getVehicleType().getLengthWithGap();
299 }
300 
301 
302 std::pair<MSVehicle* const, SUMOReal>
304  // get the leading vehicle on the lane to change to
305  MSVehicle* leader = target->lead;
306  if (leader == 0) {
307  MSLane* targetLane = target->lane;
308  MSVehicle* predP = targetLane->getPartialOccupator();
309  if (predP != 0) {
310  return std::pair<MSVehicle*, SUMOReal>(predP, targetLane->getPartialOccupatorEnd() - veh(myCandi)->getPositionOnLane());
311  }
312  const std::vector<MSLane*>& bestLaneConts = veh(myCandi)->getBestLanesContinuation();
313  MSLinkCont::const_iterator link = MSLane::succLinkSec(*veh(myCandi), 1, *targetLane, bestLaneConts);
314  if (targetLane->isLinkEnd(link)) {
315  return std::pair<MSVehicle*, SUMOReal>(static_cast<MSVehicle*>(0), -1);
316  }
317  MSLane* nextLane = (*link)->getLane();
318  if (nextLane == 0) {
319  return std::pair<MSVehicle*, SUMOReal>(static_cast<MSVehicle*>(0), -1);
320  }
321  leader = nextLane->getLastVehicle();
322  if (leader == 0) {
323  return std::pair<MSVehicle*, SUMOReal>(static_cast<MSVehicle*>(0), -1);
324  }
325  SUMOReal gap =
326  leader->getPositionOnLane() - leader->getVehicleType().getLength()
327  +
328  (myCandi->lane->getLength() - veh(myCandi)->getPositionOnLane() - veh(myCandi)->getVehicleType().getMinGap()); // !!! recheck
329  return std::pair<MSVehicle* const, SUMOReal>(leader, MAX2((SUMOReal) 0, gap));
330  } else {
331  MSVehicle* candi = veh(myCandi);
332  SUMOReal gap = leader->getPositionOnLane() - leader->getVehicleType().getLength() - candi->getPositionOnLane() - candi->getVehicleType().getMinGap();
333  return std::pair<MSVehicle* const, SUMOReal>(leader, MAX2((SUMOReal) 0, gap));
334  }
335 }
336 
337 
338 std::pair<MSVehicle* const, SUMOReal>
340  // get the leading vehicle on the lane to change to
341  MSVehicle* neighLead = target->lead;
342  // check whether the hopped vehicle became the leader
343  if (target->hoppedVeh != 0) {
344  SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
345  if (hoppedPos > veh(myCandi)->getPositionOnLane() && (neighLead == 0 || neighLead->getPositionOnLane() > hoppedPos)) {
346  neighLead = target->hoppedVeh;
347  }
348  }
349  if (neighLead == 0) {
350  MSLane* targetLane = target->lane;
351  MSVehicle* predP = targetLane->getPartialOccupator();
352  if (predP != 0) {
353  return std::pair<MSVehicle*, SUMOReal>(predP, targetLane->getPartialOccupatorEnd() - veh(myCandi)->getPositionOnLane() - veh(myCandi)->getVehicleType().getMinGap());
354  }
355  SUMOReal seen = myCandi->lane->getLength() - veh(myCandi)->getPositionOnLane();
356  SUMOReal speed = veh(myCandi)->getSpeed();
358  if (seen > dist) {
359  return std::pair<MSVehicle* const, SUMOReal>(static_cast<MSVehicle*>(0), -1);
360  }
361  const std::vector<MSLane*>& bestLaneConts = veh(myCandi)->getBestLanesContinuation(targetLane);
362  return target->lane->getLeaderOnConsecutive(dist, seen, speed, *veh(myCandi), bestLaneConts);
363  } else {
364  MSVehicle* candi = veh(myCandi);
365  return std::pair<MSVehicle* const, SUMOReal>(neighLead, neighLead->getPositionOnLane() - neighLead->getVehicleType().getLength() - candi->getPositionOnLane() - candi->getVehicleType().getMinGap());
366  }
367 }
368 
369 
370 std::pair<MSVehicle* const, SUMOReal>
372  MSVehicle* neighFollow = veh(target);
373  // check whether the hopped vehicle became the follower
374  if (target->hoppedVeh != 0) {
375  SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
376  if (hoppedPos <= veh(myCandi)->getPositionOnLane() && (neighFollow == 0 || neighFollow->getPositionOnLane() < hoppedPos)) {
377  neighFollow = target->hoppedVeh;
378  }
379  }
380  if (neighFollow == 0) {
381  MSVehicle* candi = veh(myCandi);
382  // in order to look back, we'd need the minimum braking ability of vehicles in the net...
383  // we'll assume it to be 4m/s^2
384  // !!!revisit
385  SUMOReal speed = target->lane->getSpeedLimit();
386  SUMOReal dist = speed * speed / (2.*4.) + SPEED2DIST(speed) + candi->getVehicleType().getLength();
387  dist = MIN2(dist, (SUMOReal) 500.);
388  return target->lane->getFollowerOnConsecutive(
389  dist, candi->getPositionOnLane() - candi->getVehicleType().getLength(),
390  candi->getSpeed(), candi->getCarFollowModel().getMaxDecel());
391  } else {
392  MSVehicle* candi = veh(myCandi);
393  return std::pair<MSVehicle* const, SUMOReal>(neighFollow,
394  candi->getPositionOnLane() - candi->getVehicleType().getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
395  }
396 }
397 
398 
399 
400 
401 void
402 MSLaneChanger::updateChanger(bool vehHasChanged) {
403  assert(myCandi->veh != myCandi->lane->myVehicles.rend());
404 
405  // "Push" the vehicles to the back, i.e. follower becomes vehicle,
406  // vehicle becomes leader, and leader becomes predecessor of vehicle,
407  // if it exists.
408  if (!vehHasChanged) {
409  myCandi->lead = veh(myCandi);
410  }
411  myCandi->veh = myCandi->veh + 1;
412 
413  if (veh(myCandi) == 0) {
414  assert(myCandi->follow == 0);
415  // leader already 0.
416  return;
417  }
418  if (myCandi->veh + 1 == myCandi->lane->myVehicles.rend()) {
419  myCandi->follow = 0;
420  } else {
421  myCandi->follow = *(myCandi->veh + 1);
422  }
423  return;
424 }
425 
426 
427 void
429 
430  // Update the lane's vehicle-container.
431  // First: it is bad style to change other classes members, but for
432  // this release, other attempts were too time-consuming. In a next
433  // release we will change from this lane-centered design to a vehicle-
434  // centered. This will solve many problems.
435  // Second: this swap would be faster if vehicle-containers would have
436  // been pointers, but then I had to change too much of the MSLane code.
437  for (ChangerIt ce = myChanger.begin(); ce != myChanger.end(); ++ce) {
438 
439  ce->lane->swapAfterLaneChange(t);
440  }
441 }
442 
443 
446  // Find the vehicle in myChanger with the smallest position. If there
447  // is no vehicle in myChanger (shouldn't happen) , return
448  // myChanger.end().
449  ChangerIt max = myChanger.end();
450  for (ChangerIt ce = myChanger.begin(); ce != myChanger.end(); ++ce) {
451  if (veh(ce) == 0) {
452  continue;
453  }
454  if (max == myChanger.end()) {
455  max = ce;
456  continue;
457  }
458  assert(veh(ce) != 0);
459  assert(veh(max) != 0);
460  if (veh(max)->getPositionOnLane() < veh(ce)->getPositionOnLane()) {
461  max = ce;
462  }
463  }
464  assert(max != myChanger.end());
465  assert(veh(max) != 0);
466  return max;
467 }
468 
469 int
471  int laneOffset,
472  const std::pair<MSVehicle* const, SUMOReal>& leader,
473  const std::vector<MSVehicle::LaneQ>& preb) const {
474  std::pair<MSVehicle* const, SUMOReal> neighLead = getRealLeader(myCandi + laneOffset);
475  std::pair<MSVehicle* const, SUMOReal> neighFollow = getRealFollower(myCandi + laneOffset);
476  MSVehicle* vehicle = veh(myCandi);
477  ChangerIt target = myCandi + laneOffset;
478  int blocked = 0;
479  int blockedByLeader = (laneOffset == -1 ? LCA_BLOCKED_BY_RIGHT_LEADER : LCA_BLOCKED_BY_LEFT_LEADER);
480  int blockedByFollower = (laneOffset == -1 ? LCA_BLOCKED_BY_RIGHT_FOLLOWER : LCA_BLOCKED_BY_LEFT_FOLLOWER);
481  // overlap
482  if (neighFollow.first != 0 && neighFollow.second < 0) {
483  blocked |= (blockedByFollower | LCA_OVERLAPPING);
484  }
485  if (neighLead.first != 0 && neighLead.second < 0) {
486  blocked |= (blockedByLeader | LCA_OVERLAPPING);
487  }
488  // safe back gap
489  if (neighFollow.first != 0) {
490  // !!! eigentlich: vsafe braucht die Max. Geschwindigkeit beider Spuren
491  if (neighFollow.second < neighFollow.first->getCarFollowModel().getSecureGap(neighFollow.first->getSpeed(), vehicle->getSpeed(), vehicle->getCarFollowModel().getMaxDecel())) {
492  blocked |= blockedByFollower;
493  }
494  }
495 
496  // safe front gap
497  if (neighLead.first != 0) {
498  // !!! eigentlich: vsafe braucht die Max. Geschwindigkeit beider Spuren
499  if (neighLead.second < vehicle->getCarFollowModel().getSecureGap(vehicle->getSpeed(), neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())) {
500  blocked |= blockedByLeader;
501  }
502  }
503 
504  MSAbstractLaneChangeModel::MSLCMessager msg(leader.first, neighLead.first, neighFollow.first);
505  int state = blocked | vehicle->getLaneChangeModel().wantsChange(
506  laneOffset, msg, blocked, leader, neighLead, neighFollow, *(target->lane), preb, &(myCandi->lastBlocked), &(myCandi->firstBlocked));
507 
508  if (blocked == 0 && (state & LCA_WANTS_LANECHANGE) != 0 && neighLead.first != 0) {
509  // do are more carefull (but expensive) check to ensure that a
510  // safety-critical leader is not being overloocked
511  const SUMOReal seen = myCandi->lane->getLength() - vehicle->getPositionOnLane();
512  const SUMOReal speed = vehicle->getSpeed();
513  const SUMOReal dist = vehicle->getCarFollowModel().brakeGap(speed) + vehicle->getVehicleType().getMinGap();
514  const MSLane* targetLane = (myCandi + laneOffset)->lane;
515  if (seen < dist) {
516  std::pair<MSVehicle* const, SUMOReal> neighLead2 = targetLane->getCriticalLeader(dist, seen, speed, *vehicle);
517  if (neighLead2.first != 0 && neighLead2.first != neighLead.first
518  && (neighLead2.second < vehicle->getCarFollowModel().getSecureGap(
519  vehicle->getSpeed(), neighLead2.first->getSpeed(), neighLead2.first->getCarFollowModel().getMaxDecel()))) {
520  state |= blockedByLeader;
521  }
522  }
523  }
524 #ifndef NO_TRACI
525  // let TraCI influence the wish to change lanes and the security to take
526  //const int oldstate = state;
527  state = vehicle->influenceChangeDecision(state);
528  //if (vehicle->getID() == "150_2_36000000") {
529  // std::cout << STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) << " veh=" << vehicle->getID() << " oldstate=" << oldstate << " newstate=" << state << "\n";
530  //}
531 #endif
532  return state;
533 }
534 
535 /****************************************************************************/
536 
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge&#39;e lanes.
MSVehicle * firstBlocked
the first vehicle on this edge that wants to change to this lane
Definition: MSLaneChanger.h:85
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:78
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:961
MSLane * lane
the lane the vehicle is on
Definition: MSLaneChanger.h:77
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:538
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1105
a vehicles
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
std::pair< MSVehicle *const, SUMOReal > getRealLeader(const ChangerIt &target) const
bool hasInfluencer() const
Definition: MSVehicle.h:1044
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
MSLane::VehCont::reverse_iterator veh
the regarded vehicle
Definition: MSLaneChanger.h:79
bool isVTDControlled() const
Definition: MSVehicle.h:982
void initChanger()
Initialize the changer before looping over all vehicles.
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:88
SUMOReal getLength() const
Get vehicle&#39;s length [m].
T MAX2(T a, T b)
Definition: StdDefs.h:74
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
MSVehicle * veh(ConstChangerIt ce) const
SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum.
Definition: MSCFModel.h:270
SUMOReal mySpeed
the stored speed
Definition: MSVehicle.h:118
void startChange(MSVehicle *vehicle, ChangerIt &from, int direction)
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0) ...
SUMOReal getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:284
std::pair< MSVehicle *const, SUMOReal > getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
Definition: MSLane.cpp:1272
MSVehicle * lead
the vehicle in front of the current vehicle
Definition: MSLaneChanger.h:75
The action is urgent (to be defined by lc-model)
MSVehicle * follow
the vehicle following the current vehicle
Definition: MSLaneChanger.h:73
ChangerIt findCandidate()
Find current candidate. If there is none, myChanger.end() is returned.
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
Definition: MSVehicle.cpp:1676
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, unsigned int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:991
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:1801
SUMOReal getPartialOccupatorEnd() const
Returns the position of the in-lapping vehicle&#39;s end.
Definition: MSLane.h:261
A class responsible for exchanging messages between cars involved in lane-change interaction.
The vehicle changes lanes (micro only)
Wants go to the left.
#define max(a, b)
Definition: polyfonts.c:65
std::pair< MSVehicle *const, SUMOReal > getRealFollower(const ChangerIt &target) const
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver&#39;s reaction time.
Definition: MSCFModel.h:232
void updateChanger(bool vehHasChanged)
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle&#39;s current lane and their successors...
Definition: MSVehicle.cpp:2085
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:1819
The vehicle is blocked by left follower.
std::pair< MSVehicle *const, SUMOReal > getRealThisLeader(const ChangerIt &target) const
T MIN2(T a, T b)
Definition: StdDefs.h:68
SUMOReal getMaxDecel() const
Get the vehicle type&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:184
MSVehicle * getLastVehicle() const
returns the last vehicle
Definition: MSLane.cpp:973
MSLaneChanger()
Default constructor.
int checkChange(int laneOffset, const std::pair< MSVehicle *const, SUMOReal > &leader, const std::vector< MSVehicle::LaneQ > &preb) const
void updateLanes(SUMOTime t)
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:1813
Wants go to the right.
MSVehicle * lastBlocked
the vehicle that really wants to change to this lane
Definition: MSLaneChanger.h:83
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
void leaveLane(const MSMoveReminder::Notification reason)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
Definition: MSVehicle.cpp:1761
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:2391
bool myAllowsSwap
Whether blocking vehicles may be swapped.
~MSLaneChanger()
Destructor.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:90
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
Definition: MSLaneChanger.h:97
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:292
int SUMOTime
Definition: SUMOTime.h:43
virtual void changed(int dir)=0
SUMOReal myPos
the stored position
Definition: MSVehicle.h:111
Changer myChanger
Container for ChangeElemements, one for every lane in the edge.
MSVehicle * getPartialOccupator() const
Returns the vehicle which laps into this lane.
Definition: MSLane.h:253
void registerUnchanged(MSVehicle *vehicle)
#define SUMOReal
Definition: config.h:218
The vehicle is blocked by right follower.
void adaptBestLanesOccupation(int laneIndex, SUMOReal density)
update occupation from MSLaneChanger
Definition: MSVehicle.cpp:2123
virtual int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, SUMOReal > &leader, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked)=0
Called to examine whether the vehicle wants to change using the given laneOffset. This method gets th...
The vehicle is blocked by left leader.
MSVehicle * hoppedVeh
last vehicle that changed into this lane
Definition: MSLaneChanger.h:81
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:329
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
Definition: MSVehicle.cpp:2409
bool vehInChanger() const
Check if there is a single change-candidate in the changer. Returns true if there is one...
GUISelectedStorage gSelected
A global holder of selected objects.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
The vehicle is blocked by right leader.
ChangerIt myCandi