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 /****************************************************************************/
11 // Performs lane changing of vehicles
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "MSLaneChanger.h"
35 #include "MSNet.h"
36 #include "MSVehicle.h"
37 #include "MSVehicleType.h"
38 #include "MSVehicleTransfer.h"
39 #include "MSGlobals.h"
40 #include <cassert>
41 #include <iterator>
42 #include <cstdlib>
43 #include <cmath>
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 //#define DEBUG_VEHICLE_GUI_SELECTION 1
52 #ifdef DEBUG_VEHICLE_GUI_SELECTION
54 #include <guisim/GUIVehicle.h>
55 #include <guisim/GUILane.h>
56 #endif
57 
58 
59 // ===========================================================================
60 // member method definitions
61 // ===========================================================================
62 MSLaneChanger::MSLaneChanger(std::vector<MSLane*>* lanes, bool allowSwap)
63  : myAllowsSwap(allowSwap) {
64  assert(lanes->size() > 1);
65 
66  // Fill the changer with the lane-data.
67  myChanger.reserve(lanes->size());
68  for (std::vector<MSLane*>::iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
69  ChangeElem ce;
70  ce.follow = 0;
71  ce.lead = 0;
72  ce.lane = *lane;
73  ce.veh = (*lane)->myVehicles.rbegin();
74  ce.hoppedVeh = 0;
75  ce.lastBlocked = 0;
76  ce.firstBlocked = 0;
77  myChanger.push_back(ce);
78  }
79 }
80 
81 
83 
84 
85 void
87  // This is what happens in one timestep. After initialization of the
88  // changer, each vehicle will try to change. After that the changer
89  // nedds an update to prevent multiple changes of one vehicle.
90  // Finally, the change-result has to be given back to the lanes.
91  initChanger();
92  while (vehInChanger()) {
93 
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  const std::vector<MSVehicle::LaneQ>& preb = vehicle->getBestLanes();
154  assert(preb.size() == myChanger.size());
155  for (int i = 0; i < (int) myChanger.size(); ++i) {
156  ((std::vector<MSVehicle::LaneQ>&) preb)[i].occupation = myChanger[i].dens + preb[i].nextOccupation;
157  }
158 
159  std::pair<MSVehicle* const, SUMOReal> leader = getRealThisLeader(myCandi);
160  // check whether the vehicle wants and is able to change to right lane
161  int state1 = 0;
162  if (myCandi != myChanger.begin() && (myCandi - 1)->lane->allowsVehicleClass(veh(myCandi)->getVehicleType().getVehicleClass())) {
163  state1 = checkChange(-1, leader, preb);
164  bool changingAllowed1 = (state1 & LCA_BLOCKED) == 0;
165  // change if the vehicle wants to and is allowed to change
166  if ((state1 & LCA_RIGHT) != 0 && changingAllowed1) {
167  startChange(vehicle, myCandi, -1);
168  return true;
169  }
170  if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
171  (myCandi - 1)->lastBlocked = vehicle;
172  if ((myCandi - 1)->firstBlocked == 0) {
173  (myCandi - 1)->firstBlocked = vehicle;
174  }
175  }
176  }
177 
178 
179 
180  // check whether the vehicle wants and is able to change to left lane
181  int state2 = 0;
182  if ((myCandi + 1) != myChanger.end() && (myCandi + 1)->lane->allowsVehicleClass(veh(myCandi)->getVehicleType().getVehicleClass())) {
183  state2 = checkChange(1, leader, preb);
184  bool changingAllowed2 = (state2 & LCA_BLOCKED) == 0;
185  // change if the vehicle wants to and is allowed to change
186  if ((state2 & LCA_LEFT) != 0 && changingAllowed2) {
187  startChange(vehicle, myCandi, 1);
188  return true;
189  }
190  if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
191  (myCandi + 1)->lastBlocked = vehicle;
192  if ((myCandi + 1)->firstBlocked == 0) {
193  (myCandi + 1)->firstBlocked = vehicle;
194  }
195  }
196  }
197 
198  if ((state1 & (LCA_URGENT)) != 0 && (state2 & (LCA_URGENT)) != 0) {
199  // ... wants to go to the left AND to the right
200  // just let them go to the right lane...
201  state2 = 0;
202  }
203  vehicle->getLaneChangeModel().setOwnState(state2 | state1);
204 
205  // check whether the vehicles should be swapped
206  if (myAllowsSwap && ((state1 & (LCA_URGENT)) != 0 || (state2 & (LCA_URGENT)) != 0)) {
207  // get the direction ...
208  ChangerIt target;
209  if ((state1 & (LCA_URGENT)) != 0) {
210  // ... wants to go right
211  target = myCandi - 1;
212  }
213  if ((state2 & (LCA_URGENT)) != 0) {
214  // ... wants to go left
215  target = myCandi + 1;
216  }
217  MSVehicle* prohibitor = target->lead;
218  if (target->hoppedVeh != 0) {
219  SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
220  if (prohibitor == 0 || (hoppedPos > vehicle->getPositionOnLane() && prohibitor->getPositionOnLane() > hoppedPos)) {
221  prohibitor = 0;// !!! vehicles should not jump over more than one lanetarget->hoppedVeh;
222  }
223  }
224  if (prohibitor != 0
225  &&
226  ((prohibitor->getLaneChangeModel().getOwnState() & (LCA_URGENT/*|LCA_SPEEDGAIN*/)) != 0
227  &&
228  (prohibitor->getLaneChangeModel().getOwnState() & (LCA_LEFT | LCA_RIGHT))
229  !=
230  (vehicle->getLaneChangeModel().getOwnState() & (LCA_LEFT | LCA_RIGHT))
231  )
232  ) {
233 
234  // check for position and speed
235  if (prohibitor->getVehicleType().getLengthWithGap() - vehicle->getVehicleType().getLengthWithGap() == 0) {
236  // ok, may be swapped
237  // remove vehicle to swap with
238  MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
239  if (i != target->lane->myTmpVehicles.end()) {
240  MSVehicle* bla = *i;
241  assert(bla == prohibitor);
242  target->lane->myTmpVehicles.erase(i);
243  // set this vehicle
244  target->hoppedVeh = vehicle;
245  target->lane->myTmpVehicles.insert(target->lane->myTmpVehicles.begin(), vehicle);
246  myCandi->hoppedVeh = prohibitor;
247  myCandi->lane->myTmpVehicles.insert(myCandi->lane->myTmpVehicles.begin(), prohibitor);
248 
249  // leave lane and detectors
252  // patch position and speed
253  SUMOReal p1 = vehicle->getPositionOnLane();
254  vehicle->myState.myPos = prohibitor->myState.myPos;
255  prohibitor->myState.myPos = p1;
256  p1 = vehicle->getSpeed();
257  vehicle->myState.mySpeed = prohibitor->myState.mySpeed;
258  prohibitor->myState.mySpeed = p1;
259  // enter lane and detectors
260  vehicle->enterLaneAtLaneChange(target->lane);
261  prohibitor->enterLaneAtLaneChange(myCandi->lane);
262  // mark lane change
263  vehicle->getLaneChangeModel().changed();
264  prohibitor->getLaneChangeModel().changed();
265  (myCandi)->dens += prohibitor->getVehicleType().getLengthWithGap();
266  (target)->dens += vehicle->getVehicleType().getLengthWithGap();
267  return true;
268  }
269  }
270  }
271  }
272  registerUnchanged(vehicle);
273  return false;
274 }
275 
276 
277 void
279  myCandi->lane->myTmpVehicles.insert(myCandi->lane->myTmpVehicles.begin(), veh(myCandi));
280  vehicle->getLaneChangeModel().unchanged();
281  (myCandi)->dens += vehicle->getVehicleType().getLengthWithGap();
282 }
283 
284 
285 void
286 MSLaneChanger::startChange(MSVehicle* vehicle, ChangerIt& from, int direction) {
287  ChangerIt to = from + direction;
288  to->hoppedVeh = vehicle;
289  // @todo delay entering the target lane until the vehicle intersects it
290  // physically (considering lane width and vehicle width)
291  to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
292  const bool continuous = vehicle->getLaneChangeModel().startLaneChangeManeuver(from->lane, to->lane, direction);
293  if (continuous) {
294  from->lane->myTmpVehicles.insert(from->lane->myTmpVehicles.begin(), vehicle);
295  from->dens += vehicle->getVehicleType().getLengthWithGap();
296  }
297  to->dens += to->hoppedVeh->getVehicleType().getLengthWithGap();
298 }
299 
300 
301 std::pair<MSVehicle* const, SUMOReal>
303  // get the leading vehicle on the lane to change to
304  MSVehicle* leader = target->lead;
305  if (leader == 0) {
306  MSLane* targetLane = target->lane;
307  MSVehicle* predP = targetLane->getPartialOccupator();
308  if (predP != 0) {
309  return std::pair<MSVehicle*, SUMOReal>(predP, targetLane->getPartialOccupatorEnd() - veh(myCandi)->getPositionOnLane());
310  }
311  const std::vector<MSLane*>& bestLaneConts = veh(myCandi)->getBestLanesContinuation();
312  MSLinkCont::const_iterator link = targetLane->succLinkSec(*veh(myCandi), 1, *targetLane, bestLaneConts);
313  if (targetLane->isLinkEnd(link)) {
314  return std::pair<MSVehicle*, SUMOReal>(static_cast<MSVehicle*>(0), -1);
315  }
316  MSLane* nextLane = (*link)->getLane();
317  if (nextLane == 0) {
318  return std::pair<MSVehicle*, SUMOReal>(static_cast<MSVehicle*>(0), -1);
319  }
320  leader = nextLane->getLastVehicle();
321  if (leader == 0) {
322  return std::pair<MSVehicle*, SUMOReal>(static_cast<MSVehicle*>(0), -1);
323  }
324  SUMOReal gap =
325  leader->getPositionOnLane() - leader->getVehicleType().getLength()
326  +
327  (myCandi->lane->getLength() - veh(myCandi)->getPositionOnLane() - veh(myCandi)->getVehicleType().getMinGap()); // !!! recheck
328  return std::pair<MSVehicle* const, SUMOReal>(leader, MAX2((SUMOReal) 0, gap));
329  } else {
330  MSVehicle* candi = veh(myCandi);
331  SUMOReal gap = leader->getPositionOnLane() - leader->getVehicleType().getLength() - candi->getPositionOnLane() - candi->getVehicleType().getMinGap();
332  return std::pair<MSVehicle* const, SUMOReal>(leader, MAX2((SUMOReal) 0, gap));
333  }
334 }
335 
336 
337 std::pair<MSVehicle* const, SUMOReal>
339  // get the leading vehicle on the lane to change to
340  MSVehicle* neighLead = target->lead;
341  // check whether the hopped vehicle got the leader
342  if (target->hoppedVeh != 0) {
343  SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
344  if (hoppedPos > veh(myCandi)->getPositionOnLane() && (neighLead == 0 || neighLead->getPositionOnLane() > hoppedPos)) {
345  neighLead = target->hoppedVeh;
346  }
347  }
348  if (neighLead == 0) {
349  MSLane* targetLane = target->lane;
350  MSVehicle* predP = targetLane->getPartialOccupator();
351  if (predP != 0) {
352  return std::pair<MSVehicle*, SUMOReal>(predP, targetLane->getPartialOccupatorEnd() - veh(myCandi)->getPositionOnLane() - veh(myCandi)->getVehicleType().getMinGap());
353  }
354  SUMOReal seen = myCandi->lane->getLength() - veh(myCandi)->getPositionOnLane();
355  SUMOReal speed = veh(myCandi)->getSpeed();
357  if (seen > dist) {
358  return std::pair<MSVehicle* const, SUMOReal>(static_cast<MSVehicle*>(0), -1);
359  }
360  const std::vector<MSLane*>& bestLaneConts = veh(myCandi)->getBestLanesContinuation(targetLane);
361  return target->lane->getLeaderOnConsecutive(dist, seen, speed, *veh(myCandi), bestLaneConts);
362  } else {
363  MSVehicle* candi = veh(myCandi);
364  return std::pair<MSVehicle* const, SUMOReal>(neighLead, neighLead->getPositionOnLane() - neighLead->getVehicleType().getLength() - candi->getPositionOnLane() - candi->getVehicleType().getMinGap());
365  }
366 }
367 
368 
369 std::pair<MSVehicle* const, SUMOReal>
371  MSVehicle* neighFollow = veh(target);
372  // check whether the hopped vehicle got the follower
373  if (target->hoppedVeh != 0) {
374  SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
375  if (hoppedPos <= veh(myCandi)->getPositionOnLane() && (neighFollow == 0 || neighFollow->getPositionOnLane() > hoppedPos)) {
376  neighFollow = target->hoppedVeh;
377  }
378  }
379  if (neighFollow == 0) {
380  SUMOReal speed = target->lane->getSpeedLimit();
381  // in order to look back, we'd need the minimum braking ability of vehicles in the net...
382  // we'll assume it to be 4m/s^2
383  // !!!revisit
384  SUMOReal dist = speed * speed / (2.*4.) + SPEED2DIST(speed);
385  dist = MIN2(dist, (SUMOReal) 500.);
386  MSVehicle* candi = veh(myCandi);
387  SUMOReal seen = candi->getPositionOnLane() - candi->getVehicleType().getLength();
388  return target->lane->getFollowerOnConsecutive(dist, seen, candi->getSpeed(), candi->getPositionOnLane() - candi->getVehicleType().getLength(), 4.5);
389  } else {
390  MSVehicle* candi = veh(myCandi);
391  return std::pair<MSVehicle* const, SUMOReal>(neighFollow, candi->getPositionOnLane() - candi->getVehicleType().getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
392  }
393 }
394 
395 
396 
397 
398 void
399 MSLaneChanger::updateChanger(bool vehHasChanged) {
400  assert(myCandi->veh != myCandi->lane->myVehicles.rend());
401 
402  // "Push" the vehicles to the back, i.e. follower becomes vehicle,
403  // vehicle becomes leader, and leader becomes predecessor of vehicle,
404  // if it exists.
405  if (!vehHasChanged) {
406  myCandi->lead = veh(myCandi);
407  }
408  myCandi->veh = myCandi->veh + 1;
409 
410  if (veh(myCandi) == 0) {
411  assert(myCandi->follow == 0);
412  // leader already 0.
413  return;
414  }
415  if (myCandi->veh + 1 == myCandi->lane->myVehicles.rend()) {
416  myCandi->follow = 0;
417  } else {
418  myCandi->follow = *(myCandi->veh + 1);
419  }
420  return;
421 }
422 
423 
424 void
426 
427  // Update the lane's vehicle-container.
428  // First: it is bad style to change other classes members, but for
429  // this release, other attempts were too time-consuming. In a next
430  // release we will change from this lane-centered design to a vehicle-
431  // centered. This will solve many problems.
432  // Second: this swap would be faster if vehicle-containers would have
433  // been pointers, but then I had to change too much of the MSLane code.
434  for (ChangerIt ce = myChanger.begin(); ce != myChanger.end(); ++ce) {
435 
436  ce->lane->swapAfterLaneChange(t);
437  }
438 }
439 
440 
443  // Find the vehicle in myChanger with the smallest position. If there
444  // is no vehicle in myChanger (shouldn't happen) , return
445  // myChanger.end().
446  ChangerIt max = myChanger.end();
447  for (ChangerIt ce = myChanger.begin(); ce != myChanger.end(); ++ce) {
448  if (veh(ce) == 0) {
449  continue;
450  }
451  if (max == myChanger.end()) {
452  max = ce;
453  continue;
454  }
455  assert(veh(ce) != 0);
456  assert(veh(max) != 0);
457  if (veh(max)->getPositionOnLane() < veh(ce)->getPositionOnLane()) {
458  max = ce;
459  }
460  }
461  assert(max != myChanger.end());
462  assert(veh(max) != 0);
463  return max;
464 }
465 
466 int
468  int laneOffset,
469  const std::pair<MSVehicle* const, SUMOReal>& leader,
470  const std::vector<MSVehicle::LaneQ>& preb) const {
471  std::pair<MSVehicle* const, SUMOReal> neighLead = getRealLeader(myCandi + laneOffset);
472  std::pair<MSVehicle* const, SUMOReal> neighFollow = getRealFollower(myCandi + laneOffset);
473  MSVehicle* vehicle = veh(myCandi);
474  ChangerIt target = myCandi + laneOffset;
475  int blocked = overlapWithHopped(target)
476  ? target->hoppedVeh->getPositionOnLane() < vehicle->getPositionOnLane()
479  : 0;
480  // overlap
481  if (neighFollow.first != 0 && neighFollow.second < 0) {
483  }
484  if (neighLead.first != 0 && neighLead.second < 0) {
486  }
487  // safe back gap
488  if (neighFollow.first != 0) {
489  // !!! eigentlich: vsafe braucht die Max. Geschwindigkeit beider Spuren
490  if (neighFollow.second < neighFollow.first->getCarFollowModel().getSecureGap(neighFollow.first->getSpeed(), vehicle->getSpeed(), vehicle->getCarFollowModel().getMaxDecel())) {
492  }
493  }
494 
495  // safe front gap
496  if (neighLead.first != 0) {
497  // !!! eigentlich: vsafe braucht die Max. Geschwindigkeit beider Spuren
498  if (neighLead.second < vehicle->getCarFollowModel().getSecureGap(vehicle->getSpeed(), neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())) {
499  blocked |= LCA_BLOCKED_BY_RIGHT_LEADER;
500  }
501  }
502 
503  MSAbstractLaneChangeModel::MSLCMessager msg(leader.first, neighLead.first, neighFollow.first);
504  int state = blocked | vehicle->getLaneChangeModel().wantsChange(
505  laneOffset, msg, blocked, leader, neighLead, neighFollow, *(target->lane), preb, &(myCandi->lastBlocked), &(myCandi->firstBlocked));
506 
507 #ifndef NO_TRACI
508  // let TraCI influence the wish to change lanes and the security to take
509  //const int oldstate = state;
510  state = vehicle->influenceChangeDecision(state);
511  //if (vehicle->getID() == "150_2_36000000") {
512  // std::cout << STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) << " veh=" << vehicle->getID() << " oldstate=" << oldstate << " newstate=" << state << "\n";
513  //}
514 #endif
515  return state;
516 }
517 
518 /****************************************************************************/
519 
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:84
virtual const std::vector< LaneQ > & getBestLanes(bool forceRebuild=false, MSLane *startLane=0) const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:1673
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:903
MSLane * lane
the lane the vehicle is on
Definition: MSLaneChanger.h:76
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:510
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1022
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:967
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
MSLane::VehCont::reverse_iterator veh
the regarded vehicle
Definition: MSLaneChanger.h:78
bool isVTDControlled() const
Definition: MSVehicle.h:911
void initChanger()
Initialize the changer before looping over all vehicles.
virtual MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, unsigned int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts) const
Definition: MSLane.cpp:933
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:63
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
bool overlapWithHopped(ChangerIt target) const
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:232
SUMOReal mySpeed
the stored speed
Definition: MSVehicle.h:117
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:283
MSVehicle * lead
the vehicle in front of the current vehicle
Definition: MSLaneChanger.h:74
The action is urgent (to be defined by lc-model)
MSVehicle * follow
the vehicle following the current vehicle
Definition: MSLaneChanger.h:72
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:1546
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:1661
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:61
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:213
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:1946
std::pair< MSVehicle *const, SUMOReal > getRealThisLeader(const ChangerIt &target) const
T MIN2(T a, T b)
Definition: StdDefs.h:57
SUMOReal getMaxDecel() const
Get the vehicle type&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:165
virtual void changed()=0
virtual MSVehicle * getLastVehicle() const
returns the last vehicle
Definition: MSLane.cpp:915
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)
Wants go to the right.
MSVehicle * lastBlocked
the vehicle that really wants to change to this lane
Definition: MSLaneChanger.h:82
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:1630
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:2187
bool myAllowsSwap
Whether blocking vehicles may be swapped.
~MSLaneChanger()
Destructor.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:94
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
Definition: MSLaneChanger.h:96
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:291
SUMOReal myPos
the stored position
Definition: MSVehicle.h:110
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:215
The vehicle is blocked by right follower.
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...
MSVehicle * hoppedVeh
last vehicle that changed into this lane
Definition: MSLaneChanger.h:80
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:322
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
Definition: MSVehicle.cpp:2205
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