![]() |
SUMO - Simulation of Urban MObility
|
Performs lane changing of vehicles. More...
#include <MSLaneChanger.h>
Data Structures | |
struct | ChangeElem |
Public Types | |
typedef std::vector< ChangeElem > | Changer |
The list of changers; For each lane, a ChangeElem is being build. More... | |
typedef Changer::iterator | ChangerIt |
the iterator moving over the ChangeElems More... | |
typedef Changer::const_iterator | ConstChangerIt |
the iterator moving over the ChangeElems More... | |
Public Member Functions | |
void | laneChange (SUMOTime t) |
Start lane-change-process for all vehicles on the edge'e lanes. More... | |
MSLaneChanger (const std::vector< MSLane * > *lanes, bool allowChanging, bool allowSwap) | |
Constructor. More... | |
virtual | ~MSLaneChanger () |
Destructor. More... | |
Protected Member Functions | |
virtual bool | change () |
virtual bool | changeOpposite (std::pair< MSVehicle *, SUMOReal > leader) |
int | checkChange (int laneOffset, const MSLane *targetLane, const std::pair< MSVehicle *const, SUMOReal > &leader, const std::pair< MSVehicle *const, SUMOReal > &neighLead, const std::pair< MSVehicle *const, SUMOReal > &neighFollow, const std::vector< MSVehicle::LaneQ > &preb) const |
int | checkChangeWithinEdge (int laneOffset, const std::pair< MSVehicle *const, SUMOReal > &leader, const std::vector< MSVehicle::LaneQ > &preb) const |
bool | continueChange (MSVehicle *vehicle, ChangerIt &from) |
continue a lane change maneuver and return whether the midpoint was passed in this step (used if gLaneChangeDuration > 0) More... | |
ChangerIt | findCandidate () |
Find current candidate. If there is none, myChanger.end() is returned. More... | |
std::pair< MSVehicle *const, SUMOReal > | getRealFollower (const ChangerIt &target) const |
std::pair< MSVehicle *const, SUMOReal > | getRealLeader (const ChangerIt &target) const |
void | initChanger () |
Initialize the changer before looping over all vehicles. More... | |
bool | mayChange (int direction) const |
whether changing to the lane in the given direction should be considered More... | |
void | registerUnchanged (MSVehicle *vehicle) |
void | startChange (MSVehicle *vehicle, ChangerIt &from, int direction) |
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0) More... | |
virtual void | updateChanger (bool vehHasChanged) |
void | updateLanes (SUMOTime t) |
MSVehicle * | veh (ConstChangerIt ce) const |
bool | vehInChanger () const |
Check if there is a single change-candidate in the changer. Returns true if there is one. More... | |
Static Protected Member Functions | |
static void | computeOvertakingTime (const MSVehicle *vehicle, const MSVehicle *leader, SUMOReal gap, SUMOReal &timeToOvertake, SUMOReal &spaceToOvertake) |
Compute the time and space required for overtaking the given leader. More... | |
static MSVehicle * | getCloserFollower (const SUMOReal maxPos, MSVehicle *follow1, MSVehicle *follow2) |
return the closer follower of ego More... | |
Protected Attributes | |
bool | myAllowsChanging |
bool | myAllowsSwap |
Whether blocking vehicles may be swapped. More... | |
ChangerIt | myCandi |
Changer | myChanger |
Container for ChangeElemements, one for every lane in the edge. More... | |
const bool | myChangeToOpposite |
whether this edge allows changing to the opposite direction edge More... | |
Private Member Functions | |
MSLaneChanger () | |
Default constructor. More... | |
MSLaneChanger (const MSLaneChanger &) | |
Copy constructor. More... | |
MSLaneChanger & | operator= (const MSLaneChanger &) |
Assignment operator. More... | |
Performs lane changing of vehicles.
Definition at line 55 of file MSLaneChanger.h.
typedef std::vector< ChangeElem > MSLaneChanger::Changer |
The list of changers; For each lane, a ChangeElem is being build.
Definition at line 102 of file MSLaneChanger.h.
typedef Changer::iterator MSLaneChanger::ChangerIt |
the iterator moving over the ChangeElems
Definition at line 105 of file MSLaneChanger.h.
typedef Changer::const_iterator MSLaneChanger::ConstChangerIt |
the iterator moving over the ChangeElems
Definition at line 108 of file MSLaneChanger.h.
MSLaneChanger::MSLaneChanger | ( | const std::vector< MSLane * > * | lanes, |
bool | allowChanging, | ||
bool | allowSwap | ||
) |
|
virtual |
Destructor.
Definition at line 94 of file MSLaneChanger.cpp.
|
private |
Default constructor.
|
private |
Copy constructor.
|
protectedvirtual |
Find a new candidate and try to change it.
Reimplemented in MSLaneChangerSublane.
Definition at line 222 of file MSLaneChanger.cpp.
References MSVehicle::adaptBestLanesOccupation(), MSAbstractLaneChangeModel::alreadyChanged(), bla, changeOpposite(), checkChangeWithinEdge(), continueChange(), findCandidate(), gDebugSelectedVehicle, MSVehicle::getBestLanes(), MSBaseVehicle::getID(), MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSAbstractLaneChangeModel::getOwnState(), MSVehicle::getPositionOnLane(), getRealLeader(), MSBaseVehicle::getVehicleType(), MSAbstractLaneChangeModel::isChangingLanes(), MSVehicle::isRemoteControlled(), LCA_BLOCKED, LCA_LEFT, LCA_RIGHT, LCA_URGENT, mayChange(), myAllowsChanging, myAllowsSwap, myCandi, myChanger, MSVehicle::myState, registerUnchanged(), MSAbstractLaneChangeModel::setOwnState(), startChange(), SUMOReal, MSVehicle::updateBestLanes(), and veh().
Referenced by laneChange(), and veh().
try changing to the opposite direction edge.
XXX what about overtaking multiple vehicles?
XXX compute sensible distance
XXX compute sensible usable dist
XXX use a dedicated transformation function
XXX compute a bette lateral position
Definition at line 706 of file MSLaneChanger.cpp.
References MSCFModel::brakeGap(), MSEdge::canChangeToOpposite(), checkChange(), computeOvertakingTime(), DEBUG_COND, findCandidate(), MSLane::forceVehicleInsertion(), MSVehicle::getBestLanes(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSLinkContHelper::getConnectingLink(), MSLane::getEdge(), Named::getID(), MSBaseVehicle::getID(), Named::getIDSecure(), MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSLane::getLength(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxDecel(), MSLane::getOpposite(), MSLane::getOppositeFollower(), MSLane::getOppositeLeader(), MSLane::getOppositePos(), MSVehicle::getPositionOnLane(), MSCFModel::getSecureGap(), MSVehicle::getSpeed(), MSLane::getSpeedLimit(), MSLink::getState(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), MSLink::havePriority(), MSAbstractLaneChangeModel::isOpposite(), MSVehicle::isStopped(), LCA_BLOCKED, LCA_WANTS_LANECHANGE, MSVehicle::LaneQ::length, LINKSTATE_ZIPPER, MIN2(), MSVehicle::State::myBackPos, myCandi, myChangeToOpposite, MSVehicle::State::myPos, MSVehicle::myState, MSVehicle::nextStopDist(), MSMoveReminder::NOTIFICATION_LANE_CHANGE, SIMTIME, MSAbstractLaneChangeModel::startLaneChangeManeuver(), SUMOReal, and veh().
|
protected |
Definition at line 541 of file MSLaneChanger.cpp.
References ACCEL2SPEED, MSCFModel::brakeGap(), DEBUG_COND, DELTA_T, MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSLane::getCriticalLeader(), MSLane::getEdge(), MSBaseVehicle::getID(), MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSLane::getLeader(), MSLane::getLength(), MSCFModel::getMaxDecel(), MSVehicleType::getMinGap(), MSLane::getParallelLane(), MSVehicle::getPositionOnLane(), MSCFModel::getSecureGap(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), MSGlobals::gLaneChangeDuration, MSVehicle::influenceChangeDecision(), MSEdge::isInternal(), MSLane::isLinkEnd(), LCA_BLOCKED, LCA_BLOCKED_BY_LEFT_FOLLOWER, LCA_BLOCKED_BY_LEFT_LEADER, LCA_BLOCKED_BY_RIGHT_FOLLOWER, LCA_BLOCKED_BY_RIGHT_LEADER, LCA_INSUFFICIENT_SPACE, LCA_OVERLAPPING, LCA_WANTS_LANECHANGE, LINKDIR_LEFT, LINKDIR_RIGHT, MAX2(), myCandi, SIMTIME, STEPS2TIME, MSLane::succLinkSec(), SUMOReal, toString(), MSVehicle::unsafeLinkAhead(), veh(), and MSAbstractLaneChangeModel::wantsChange().
Referenced by changeOpposite(), checkChangeWithinEdge(), and veh().
|
protected |
Definition at line 524 of file MSLaneChanger.cpp.
References checkChange(), getRealFollower(), getRealLeader(), and myCandi.
|
staticprotected |
Compute the time and space required for overtaking the given leader.
[in] | vehicle | The vehicle that wants to overtake |
[in] | leader | The vehicle to be overtaken |
[in] | gap | The gap between vehicle and leader |
[out] | timeToOvertake | The time for overtaking |
[out] | spaceToOvertake | The space for overtaking |
XXX ignore speed limit when overtaking through the opposite lane?
Definition at line 929 of file MSLaneChanger.cpp.
References MSVehicle::getCarFollowModel(), MSVehicle::getLane(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxAccel(), MSVehicleType::getMinGap(), MSVehicle::getSpeed(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), sign, and SUMOReal.
Referenced by changeOpposite(), and veh().
continue a lane change maneuver and return whether the midpoint was passed in this step (used if gLaneChangeDuration > 0)
Definition at line 396 of file MSLaneChanger.cpp.
References MSVehicle::computeAngle(), DEBUG_COND, MSAbstractLaneChangeModel::endLaneChangeManeuver(), MSBaseVehicle::getID(), Named::getIDSecure(), MSAbstractLaneChangeModel::getLaneChangeDirection(), MSVehicle::getLaneChangeModel(), MSVehicle::getLateralPositionOnLane(), MSAbstractLaneChangeModel::getLateralSpeed(), MSVehicleType::getLengthWithGap(), MSAbstractLaneChangeModel::getShadowDirection(), MSAbstractLaneChangeModel::getShadowLane(), MSBaseVehicle::getVehicleType(), MSLane::getWidth(), Position::INVALID, MSAbstractLaneChangeModel::isChangingLanes(), MSVehicle::myAngle, MSVehicle::myCachedPosition, myCandi, MSVehicle::State::myPosLat, MSVehicle::myState, MSAbstractLaneChangeModel::primaryLaneChanged(), SIMTIME, MSAbstractLaneChangeModel::updateCompletion(), and MSAbstractLaneChangeModel::updateShadowLane().
Referenced by change(), startChange(), and veh().
|
protected |
Find current candidate. If there is none, myChanger.end() is returned.
Definition at line 176 of file MSLaneChanger.cpp.
References max, myChanger, and veh().
Referenced by MSLaneChangerSublane::change(), change(), changeOpposite(), and veh().
|
staticprotected |
return the closer follower of ego
Definition at line 509 of file MSLaneChanger.cpp.
References MSVehicle::getPositionOnLane().
Referenced by getRealFollower(), and veh().
|
protected |
Definition at line 489 of file MSLaneChanger.cpp.
References MSVehicle::getCarFollowModel(), getCloserFollower(), MSVehicleType::getLength(), MSCFModel::getMaxDecel(), MSVehicle::getPositionOnLane(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), myCandi, SUMOReal, and veh().
Referenced by checkChangeWithinEdge(), and veh().
|
protected |
Definition at line 449 of file MSLaneChanger.cpp.
References MSCFModel::brakeGap(), MSVehicle::getBackPositionOnLane(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSVehicleType::getMinGap(), MSVehicle::getPositionOnLane(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), myCandi, MSLane::myPartialVehicles, SUMOReal, and veh().
Referenced by change(), checkChangeWithinEdge(), and veh().
|
protected |
Initialize the changer before looping over all vehicles.
Definition at line 122 of file MSLaneChanger.cpp.
References myChanger.
Referenced by laneChange().
void MSLaneChanger::laneChange | ( | SUMOTime | t | ) |
Start lane-change-process for all vehicles on the edge'e lanes.
Definition at line 99 of file MSLaneChanger.cpp.
References change(), initChanger(), myChanger, updateChanger(), updateLanes(), and vehInChanger().
Referenced by MSEdge::changeLanes().
|
protected |
whether changing to the lane in the given direction should be considered
Definition at line 204 of file MSLaneChanger.cpp.
References myAllowsChanging, myCandi, myChanger, and veh().
Referenced by change(), MSLaneChangerSublane::checkChangeHelper(), MSLaneChangerSublane::startChangeSublane(), and veh().
|
private |
Assignment operator.
|
protected |
Update changer for vehicles that did not change
Definition at line 371 of file MSLaneChanger.cpp.
References MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSBaseVehicle::getVehicleType(), myCandi, MSAbstractLaneChangeModel::unchanged(), and veh().
Referenced by MSLaneChangerSublane::change(), change(), MSLaneChangerSublane::startChangeSublane(), and veh().
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0)
Definition at line 379 of file MSLaneChanger.cpp.
References continueChange(), MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSBaseVehicle::getVehicleType(), myCandi, and MSAbstractLaneChangeModel::startLaneChangeManeuver().
|
protectedvirtual |
After the possible change, update the changer.
Reimplemented in MSLaneChangerSublane.
Definition at line 140 of file MSLaneChanger.cpp.
References DELTA_T, MSGlobals::gLaneChangeDuration, myCandi, and veh().
Referenced by laneChange(), MSLaneChangerSublane::updateChanger(), and veh().
|
protected |
During lane-change a temporary vehicle container is filled within the lanes (bad pratice to modify foreign members, I know). Swap this container with the real one.
Definition at line 158 of file MSLaneChanger.cpp.
References myChanger.
Referenced by laneChange(), and veh().
|
inlineprotected |
Returns the furthes unhandled vehicle on this change-elements lane or 0 if there is none.
Definition at line 129 of file MSLaneChanger.h.
References change(), changeOpposite(), checkChange(), checkChangeWithinEdge(), computeOvertakingTime(), continueChange(), findCandidate(), getCloserFollower(), getRealFollower(), getRealLeader(), mayChange(), registerUnchanged(), startChange(), SUMOReal, updateChanger(), and updateLanes().
Referenced by MSLaneChangerSublane::change(), change(), changeOpposite(), checkChange(), MSLaneChangerSublane::checkChangeSublane(), findCandidate(), MSLaneChangerSublane::getLeaders(), getRealFollower(), getRealLeader(), mayChange(), registerUnchanged(), updateChanger(), and vehInChanger().
|
inlineprotected |
Check if there is a single change-candidate in the changer. Returns true if there is one.
Definition at line 116 of file MSLaneChanger.h.
References myChanger, and veh().
Referenced by laneChange().
|
protected |
Definition at line 217 of file MSLaneChanger.h.
Referenced by change(), and mayChange().
|
protected |
Whether blocking vehicles may be swapped.
Definition at line 213 of file MSLaneChanger.h.
Referenced by change().
|
protected |
Change-candidate. Last of the vehicles in changer. Only this one will try to change. Every vehicle on the edge will be a candidate once in the change-process.
Definition at line 210 of file MSLaneChanger.h.
Referenced by MSLaneChangerSublane::change(), change(), changeOpposite(), checkChange(), MSLaneChangerSublane::checkChangeHelper(), MSLaneChangerSublane::checkChangeSublane(), checkChangeWithinEdge(), continueChange(), MSLaneChangerSublane::getLeaders(), getRealFollower(), getRealLeader(), mayChange(), registerUnchanged(), startChange(), MSLaneChangerSublane::updateChanger(), and updateChanger().
|
protected |
Container for ChangeElemements, one for every lane in the edge.
Definition at line 205 of file MSLaneChanger.h.
Referenced by MSLaneChangerSublane::change(), change(), findCandidate(), initChanger(), laneChange(), mayChange(), MSLaneChanger(), MSLaneChangerSublane::startChangeSublane(), MSLaneChangerSublane::updateChanger(), updateLanes(), and vehInChanger().
|
protected |
whether this edge allows changing to the opposite direction edge
Definition at line 220 of file MSLaneChanger.h.
Referenced by changeOpposite().