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) | |
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 |
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 | ||
) |
|
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(), getRealLeader(), MSAbstractLaneChangeModel::isChangingLanes(), MSVehicle::isRemoteControlled(), LCA_BLOCKED, LCA_LEFT, LCA_RIGHT, LCA_URGENT, mayChange(), myAllowsChanging, myCandi, myChanger, registerUnchanged(), MSAbstractLaneChangeModel::setOwnState(), startChange(), MSVehicle::updateBestLanes(), and veh().
Referenced by laneChange().
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 805 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().
Referenced by change().
|
protected |
Definition at line 579 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(), and checkChangeWithinEdge().
|
protected |
Definition at line 562 of file MSLaneChanger.cpp.
References checkChange(), getRealFollower(), getRealLeader(), and myCandi.
Referenced by change().
|
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 1028 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().
continue a lane change maneuver and return whether the midpoint was passed in this step (used if gLaneChangeDuration > 0)
Definition at line 346 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(), and startChange().
|
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(), and changeOpposite().
|
staticprotected |
return the closer follower of ego
Definition at line 547 of file MSLaneChanger.cpp.
References MSVehicle::getPositionOnLane().
Referenced by getRealFollower().
|
protected |
Definition at line 472 of file MSLaneChanger.cpp.
References DEBUG_COND, MSVehicle::getCarFollowModel(), getCloserFollower(), MSBaseVehicle::getID(), MSVehicleType::getLength(), MSCFModel::getMaxDecel(), MSVehicle::getPositionOnLane(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), myCandi, SIMTIME, SUMOReal, and veh().
Referenced by checkChangeWithinEdge().
|
protected |
Definition at line 397 of file MSLaneChanger.cpp.
References MSCFModel::brakeGap(), DEBUG_COND, MSVehicle::getBackPositionOnLane(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSBaseVehicle::getID(), MSVehicleType::getMinGap(), MSVehicle::getPositionOnLane(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), myCandi, MSLane::myPartialVehicles, SIMTIME, SUMOReal, and veh().
Referenced by change(), and checkChangeWithinEdge().
|
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(), and MSLaneChangerSublane::startChangeSublane().
|
private |
Assignment operator.
|
protected |
Update changer for vehicles that did not change
Definition at line 321 of file MSLaneChanger.cpp.
References MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSBaseVehicle::getVehicleType(), myCandi, MSAbstractLaneChangeModel::unchanged(), and veh().
Referenced by MSLaneChangerSublane::change(), change(), and MSLaneChangerSublane::startChangeSublane().
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0)
Definition at line 329 of file MSLaneChanger.cpp.
References continueChange(), MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSBaseVehicle::getVehicleType(), myCandi, and MSAbstractLaneChangeModel::startLaneChangeManeuver().
Referenced by change().
|
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(), and MSLaneChangerSublane::updateChanger().
|
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().
|
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.
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 214 of file MSLaneChanger.h.
Referenced by change(), and mayChange().
|
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 217 of file MSLaneChanger.h.
Referenced by changeOpposite().