![]() |
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 | |
bool | applyTraCICommands (MSVehicle *vehicle) |
Execute TraCI LC-commands. More... | |
virtual bool | change () |
virtual bool | changeOpposite (std::pair< MSVehicle *, double > leader) |
int | checkChange (int laneOffset, const MSLane *targetLane, const std::pair< MSVehicle *const, double > &leader, const std::pair< MSVehicle *const, double > &neighLead, const std::pair< MSVehicle *const, double > &neighFollow, const std::vector< MSVehicle::LaneQ > &preb) const |
int | checkChangeWithinEdge (int laneOffset, const std::pair< MSVehicle *const, double > &leader, const std::vector< MSVehicle::LaneQ > &preb) const |
void | checkTraCICommands (MSVehicle *vehicle) |
Take into account traci LC-commands. More... | |
bool | continueChange (MSVehicle *vehicle, ChangerIt &from) |
continue a lane change maneuver and return whether the vehicle has completely moved onto the new lane (used if gLaneChangeDuration > 0) More... | |
ChangerIt | findCandidate () |
Find current candidate. If there is none, myChanger.end() is returned. More... | |
std::pair< MSVehicle *const, double > | getRealFollower (const ChangerIt &target) const |
std::pair< MSVehicle *const, double > | getRealLeader (const ChangerIt &target) const |
virtual 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) |
bool | startChange (MSVehicle *vehicle, ChangerIt &from, int direction) |
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, double gap, double &timeToOvertake, double &spaceToOvertake) |
Compute the time and space required for overtaking the given leader. More... | |
static MSVehicle * | getCloserFollower (const double maxPos, MSVehicle *follow1, MSVehicle *follow2) |
return the closer follower of ego More... | |
static std::pair< MSVehicle *, double > | getColumnleader (MSVehicle *vehicle, std::pair< MSVehicle *, double > leader, double maxLookAhead=std::numeric_limits< double >::max()) |
static MSLane * | getLaneAfter (MSLane *lane, const std::vector< MSLane *> &conts) |
return the next lane in conts beyond lane or nullptr More... | |
Protected Attributes | |
const 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 48 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 106 of file MSLaneChanger.h.
typedef Changer::iterator MSLaneChanger::ChangerIt |
the iterator moving over the ChangeElems
Definition at line 109 of file MSLaneChanger.h.
typedef Changer::const_iterator MSLaneChanger::ConstChangerIt |
the iterator moving over the ChangeElems
Definition at line 112 of file MSLaneChanger.h.
MSLaneChanger::MSLaneChanger | ( | const std::vector< MSLane *> * | lanes, |
bool | allowChanging | ||
) |
|
virtual |
Destructor.
Definition at line 115 of file MSLaneChanger.cpp.
|
private |
Default constructor.
|
private |
Copy constructor.
|
protected |
Execute TraCI LC-commands.
Definition at line 396 of file MSLaneChanger.cpp.
References continueChange(), MSVehicle::getLaneChangeModel(), MSAbstractLaneChangeModel::getOwnState(), LCA_BLOCKED, LCA_LEFT, LCA_RIGHT, myCandi, and MSAbstractLaneChangeModel::startLaneChangeManeuver().
|
protectedvirtual |
Find a new candidate and try to change it.
Reimplemented in MSLaneChangerSublane.
Definition at line 252 of file MSLaneChanger.cpp.
References MSVehicle::adaptBestLanesOccupation(), MSAbstractLaneChangeModel::alreadyChanged(), applyTraCICommands(), changeOpposite(), checkChangeWithinEdge(), checkTraCICommands(), continueChange(), DEBUG_COND, findCandidate(), MSVehicle::getBestLanes(), MSBaseVehicle::getID(), MSVehicle::getLaneChangeModel(), MSAbstractLaneChangeModel::getOwnState(), getRealLeader(), MSVehicleType::getVehicleClass(), MSBaseVehicle::getVehicleType(), MSVehicle::isActive(), MSAbstractLaneChangeModel::isChangingLanes(), MSAbstractLaneChangeModel::isOpposite(), MSVehicle::isStoppedOnLane(), LCA_BLOCKED, LCA_LEFT, LCA_RIGHT, LCA_URGENT, mayChange(), myAllowsChanging, myCandi, myChanger, registerUnchanged(), MSAbstractLaneChangeModel::setOwnState(), SIMTIME, startChange(), SVC_EMERGENCY, MSVehicle::updateBestLanes(), and veh().
Referenced by laneChange(), and veh().
|
protectedvirtual |
try changing to the opposite direction edge.
XXX use a dedicated transformation function
XXX compute a better lateral position
Definition at line 1014 of file MSLaneChanger.cpp.
References MSLane::allowsVehicleClass(), checkChange(), computeOvertakingTime(), DEBUG_COND, findCandidate(), MSLane::forceVehicleInsertion(), MSVehicle::getAcceleration(), MSVehicle::getBestLanes(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), getColumnleader(), MSLinkContHelper::getConnectingLink(), MSLink::getDirection(), MSCFModel::getHeadwayTime(), Named::getID(), MSBaseVehicle::getID(), Named::getIDSecure(), MSVehicle::getInfluencer(), MSNet::getInstance(), MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSVehicle::Influencer::getLaneTimeLineDuration(), MSLane::getLength(), MSLane::getOpposite(), MSLane::getOppositeFollower(), MSLane::getOppositeLeader(), MSLane::getOppositePos(), MSVehicle::getPositionOnLane(), MSVehicle::Influencer::getRespectJunctionPriority(), MSVehicle::getSpeed(), MSLane::getSpeedLimit(), MSLink::getState(), MSBaseVehicle::getVClass(), MSVehicleType::getVehicleClass(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), MSLink::getViaLaneOrLane(), MSVehicle::hasInfluencer(), MSLink::havePriority(), MSLink::haveRed(), MSLink::haveYellow(), MSVehicle::ignoreRed(), MSVehicle::influenceChangeDecision(), MSAbstractLaneChangeModel::isOpposite(), MSVehicle::isStopped(), LCA_BLOCKED, LCA_COOPERATIVE, LCA_TRACI, LCA_WANTS_LANECHANGE, MSVehicle::LaneQ::length, LINKDIR_STRAIGHT, LINKSTATE_ZIPPER, MIN2(), MSVehicle::State::myBackPos, myCandi, myChangeToOpposite, MSVehicle::State::myPos, MSVehicle::myState, MSVehicle::nextStopDist(), MSMoveReminder::NOTIFICATION_LANE_CHANGE, OPPOSITE_OVERTAKING_ONCOMING_LOOKAHEAD, OPPOSITE_OVERTAKING_SAFETYGAP_HEADWAY_FACTOR, MSAbstractLaneChangeModel::setOwnState(), SIMTIME, MSAbstractLaneChangeModel::startLaneChangeManeuver(), STEPS2TIME, SVC_EMERGENCY, toString(), veh(), MSVehicle::VEH_SIGNAL_BLINKER_LEFT, and MSVehicle::VEH_SIGNAL_BLINKER_RIGHT.
|
protected |
Definition at line 691 of file MSLaneChanger.cpp.
References ACCEL2SPEED, MSCFModel::brakeGap(), DEBUG_COND, DELTA_T, MSAbstractLaneChangeModel::estimateLCDuration(), MSVehicle::getAcceleration(), MSVehicle::getActionStepLength(), MSAbstractLaneChangeModel::getAssumedDecelForLaneChangeDuration(), MSVehicle::getBackPositionOnLane(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSLane::getCriticalLeader(), MSLane::getEdge(), MSCFModel::getHeadwayTime(), MSBaseVehicle::getID(), MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSLane::getLeader(), MSLane::getLength(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxDecel(), MSVehicleType::getMinGap(), MSPModel::getModel(), MSLane::getParallelLane(), MSVehicle::getPositionOnLane(), MSVehicle::getRightSideOnLane(), MSAbstractLaneChangeModel::getSafetyFactor(), MSCFModel::getSecureGap(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), MSVehicleType::getWidth(), MSLane::getWidth(), MSGlobals::gLaneChangeDuration, MSPModel::hasPedestrians(), 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_INSUFFICIENT_SPEED, LCA_OVERLAPPING, LCA_WANTS_LANECHANGE, LINKDIR_LEFT, LINKDIR_RIGHT, MAX2(), MIN2(), myCandi, MSPModel::nextBlocking(), MSAbstractLaneChangeModel::NO_NEIGHBOR, MSAbstractLaneChangeModel::saveLCState(), MSAbstractLaneChangeModel::setFollowerGaps(), MSAbstractLaneChangeModel::setLeaderGaps(), MSAbstractLaneChangeModel::setOrigLeaderGaps(), SIMTIME, MSLane::succLinkSec(), toString(), TS, MSVehicle::unsafeLinkAhead(), veh(), and MSAbstractLaneChangeModel::wantsChange().
Referenced by changeOpposite(), checkChangeWithinEdge(), and veh().
|
protected |
Definition at line 674 of file MSLaneChanger.cpp.
References checkChange(), getRealFollower(), getRealLeader(), and myCandi.
|
protected |
Take into account traci LC-commands.
Definition at line 375 of file MSLaneChanger.cpp.
References MSAbstractLaneChangeModel::checkTraCICommands(), DEBUG_COND, MSBaseVehicle::getID(), MSVehicle::getLaneChangeModel(), MSAbstractLaneChangeModel::getOwnState(), LCA_BLOCKED, LCA_OVERLAPPING, SIMTIME, and toString().
Referenced by MSLaneChangerSublane::change(), change(), and veh().
|
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 1337 of file MSLaneChanger.cpp.
References DEBUG_COND, MSVehicle::getAcceleration(), MSVehicle::getCarFollowModel(), MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSVehicleType::getLength(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxAccel(), MSCFModel::getMaxDecel(), MSVehicleType::getMinGap(), MSAbstractLaneChangeModel::getOppositeSafetyFactor(), MSCFModel::getSecureGap(), MSVehicle::getSpeed(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), OPPOSITE_OVERTAKING_SAFE_TIMEGAP, OPPOSITE_OVERTAKING_SAFETY_FACTOR, and TS.
Referenced by changeOpposite(), and veh().
continue a lane change maneuver and return whether the vehicle has completely moved onto the new lane (used if gLaneChangeDuration > 0)
Definition at line 438 of file MSLaneChanger.cpp.
References MSVehicle::computeAngle(), DEBUG_COND, MSAbstractLaneChangeModel::endLaneChangeManeuver(), MSBaseVehicle::getID(), Named::getIDSecure(), MSAbstractLaneChangeModel::getLaneChangeDirection(), MSVehicle::getLaneChangeModel(), MSVehicle::getLateralPositionOnLane(), MSAbstractLaneChangeModel::getShadowDirection(), MSAbstractLaneChangeModel::getShadowLane(), MSAbstractLaneChangeModel::getSpeedLat(), MSLane::getWidth(), Position::INVALID, MSAbstractLaneChangeModel::isChangingLanes(), MSVehicle::myAngle, MSVehicle::myCachedPosition, myCandi, MSVehicle::State::myPosLat, MSVehicle::myState, MSAbstractLaneChangeModel::primaryLaneChanged(), MSLane::requireCollisionCheck(), SIMTIME, SPEED2DIST, MSAbstractLaneChangeModel::updateCompletion(), and MSAbstractLaneChangeModel::updateShadowLane().
Referenced by applyTraCICommands(), change(), startChange(), and veh().
|
protected |
Find current candidate. If there is none, myChanger.end() is returned.
Definition at line 195 of file MSLaneChanger.cpp.
References MSBaseVehicle::getID(), MSVehicle::getPositionOnLane(), MSVehicle::isFrontOnLane(), myChanger, SIMTIME, and veh().
Referenced by MSLaneChangerSublane::change(), change(), changeOpposite(), and veh().
|
staticprotected |
return the closer follower of ego
Definition at line 659 of file MSLaneChanger.cpp.
References MSVehicle::getPositionOnLane().
Referenced by getRealFollower(), and veh().
|
staticprotected |
Definition at line 1442 of file MSLaneChanger.cpp.
References MSCFModel::brakeGap(), DEBUG_COND, MSVehicle::getBackPositionOnLane(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSLane::getEdge(), MSBaseVehicle::getID(), Named::getIDSecure(), MSVehicle::getLane(), getLaneAfter(), MSVehicle::getLaneChangeModel(), MSLane::getLastAnyVehicle(), MSLane::getLength(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxDecel(), MSAbstractLaneChangeModel::getOppositeSafetyFactor(), MSVehicle::getPositionOnLane(), MSCFModel::getSecureGap(), MSVehicleType::getVehicleClass(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), MAX2(), OPPOSITE_OVERTAKING_MAX_LOOKAHEAD, OPPOSITE_OVERTAKING_MAX_LOOKAHEAD_EMERGENCY, OPPOSITE_OVERTAKING_SAFETY_FACTOR, and SVC_EMERGENCY.
Referenced by changeOpposite(), and veh().
|
staticprotected |
return the next lane in conts beyond lane or nullptr
Definition at line 1576 of file MSLaneChanger.cpp.
Referenced by getColumnleader(), and veh().
|
protected |
Definition at line 586 of file MSLaneChanger.cpp.
References DEBUG_COND, MSVehicle::getBackPositionOnLane(), getCloserFollower(), MSBaseVehicle::getID(), MSVehicleType::getLength(), MSVehicle::getPositionOnLane(), MSBaseVehicle::getVehicleType(), myCandi, SIMTIME, and veh().
Referenced by checkChangeWithinEdge(), and veh().
|
protected |
Definition at line 488 of file MSLaneChanger.cpp.
References MSCFModel::brakeGap(), DEBUG_COND, MSVehicle::getBackPositionOnLane(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSBaseVehicle::getID(), Named::getIDSecure(), MSLane::getLength(), MSVehicleType::getMinGap(), MSVehicle::getPositionOnLane(), MSVehicle::getSpeed(), MSBaseVehicle::getVehicleType(), myCandi, MSLane::myPartialVehicles, SIMTIME, and veh().
Referenced by change(), checkChangeWithinEdge(), and veh().
|
protectedvirtual |
Initialize the changer before looping over all vehicles.
Reimplemented in MSLaneChangerSublane.
Definition at line 143 of file MSLaneChanger.cpp.
References myChanger.
Referenced by MSLaneChangerSublane::initChanger(), and laneChange().
void MSLaneChanger::laneChange | ( | SUMOTime | t | ) |
Start lane-change-process for all vehicles on the edge'e lanes.
Definition at line 120 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 234 of file MSLaneChanger.cpp.
References myAllowsChanging, myCandi, and veh().
Referenced by MSLaneChangerSublane::change(), change(), MSLaneChangerSublane::checkChangeHelper(), MSLaneChangerSublane::checkChangeToNewLane(), MSLaneChangerSublane::startChangeSublane(), and veh().
|
private |
Assignment operator.
|
protected |
Update changer for vehicles that did not change
Definition at line 366 of file MSLaneChanger.cpp.
References MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSBaseVehicle::getVehicleType(), myCandi, MSAbstractLaneChangeModel::unchanged(), and veh().
Referenced by MSLaneChangerSublane::abortLCManeuver(), MSLaneChangerSublane::change(), change(), MSLaneChangerSublane::checkChangeToNewLane(), MSLaneChangerSublane::continueChangeSublane(), startChange(), and veh().
Definition at line 418 of file MSLaneChanger.cpp.
References continueChange(), MSVehicle::getLaneChangeModel(), MSVehicle::isRemoteControlled(), myCandi, registerUnchanged(), and MSAbstractLaneChangeModel::startLaneChangeManeuver().
|
protectedvirtual |
After the possible change, update the changer.
Reimplemented in MSLaneChangerSublane.
Definition at line 159 of file MSLaneChanger.cpp.
References myCandi, and veh().
Referenced by laneChange(), MSLaneChangerSublane::updateChanger(), and veh().
|
protected |
During lane-change a temporary vehicle container is filled within the lanes (bad practice to modify foreign members, I know). Swap this container with the real one.
Definition at line 177 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 133 of file MSLaneChanger.h.
References applyTraCICommands(), change(), changeOpposite(), checkChange(), checkChangeWithinEdge(), checkTraCICommands(), computeOvertakingTime(), continueChange(), findCandidate(), getCloserFollower(), getColumnleader(), getLaneAfter(), getRealFollower(), getRealLeader(), MSLaneChanger::ChangeElem::lane, mayChange(), registerUnchanged(), startChange(), 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 120 of file MSLaneChanger.h.
References myChanger, and veh().
Referenced by laneChange().
|
protected |
Definition at line 234 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 230 of file MSLaneChanger.h.
Referenced by applyTraCICommands(), 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 225 of file MSLaneChanger.h.
Referenced by MSLaneChangerSublane::change(), change(), findCandidate(), MSLaneChangerSublane::initChanger(), initChanger(), laneChange(), MSLaneChanger(), MSLaneChangerSublane::MSLaneChangerSublane(), MSLaneChangerSublane::startChangeSublane(), MSLaneChangerSublane::updateChanger(), updateLanes(), and vehInChanger().
|
protected |
whether this edge allows changing to the opposite direction edge
Definition at line 237 of file MSLaneChanger.h.
Referenced by changeOpposite().