![]() |
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 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, 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) |
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, 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... | |
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 54 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 112 of file MSLaneChanger.h.
typedef Changer::iterator MSLaneChanger::ChangerIt |
the iterator moving over the ChangeElems
Definition at line 115 of file MSLaneChanger.h.
typedef Changer::const_iterator MSLaneChanger::ConstChangerIt |
the iterator moving over the ChangeElems
Definition at line 118 of file MSLaneChanger.h.
MSLaneChanger::MSLaneChanger | ( | const std::vector< MSLane *> * | lanes, |
bool | allowChanging | ||
) |
|
virtual |
Destructor.
Definition at line 117 of file MSLaneChanger.cpp.
|
private |
Default constructor.
|
private |
Copy constructor.
|
protected |
Execute TraCI LC-commands.
Definition at line 410 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 254 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::isRemoteControlled(), 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 950 of file MSLaneChanger.cpp.
References MSCFModel::brakeGap(), checkChange(), computeOvertakingTime(), DEBUG_COND, findCandidate(), MSLane::forceVehicleInsertion(), MSVehicle::getBestLanes(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSLinkContHelper::getConnectingLink(), MSLink::getDirection(), MSLane::getEdge(), Named::getID(), MSBaseVehicle::getID(), Named::getIDSecure(), MSVehicle::getInfluencer(), MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSLane::getLength(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxDecel(), MSLane::getOpposite(), MSLane::getOppositeFollower(), MSLane::getOppositeLeader(), MSLane::getOppositePos(), MSVehicle::getPositionOnLane(), MSVehicle::Influencer::getRespectJunctionPriority(), MSCFModel::getSecureGap(), MSVehicle::getSpeed(), MSLane::getSpeedLimit(), MSLink::getState(), MSVehicleType::getVehicleClass(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), MSLink::getViaLaneOrLane(), MSVehicle::hasInfluencer(), MSLink::havePriority(), MSLink::haveRed(), MSLink::haveYellow(), MSVehicle::ignoreRed(), MSAbstractLaneChangeModel::isOpposite(), MSVehicle::isStopped(), LCA_BLOCKED, LCA_COOPERATIVE, LCA_WANTS_LANECHANGE, MSVehicle::LaneQ::length, LINKDIR_STRAIGHT, LINKSTATE_ZIPPER, MAX2(), MIN2(), MSVehicle::State::myBackPos, myCandi, myChangeToOpposite, MSVehicle::State::myPos, MSVehicle::myState, MSVehicle::nextStopDist(), MSMoveReminder::NOTIFICATION_LANE_CHANGE, OPPOSITE_OVERTAKING_MAX_LOOKAHEAD, OPPOSITE_OVERTAKING_MAX_LOOKAHEAD_EMERGENCY, OPPOSITE_OVERTAKING_ONCOMING_LOOKAHEAD, SIMTIME, MSAbstractLaneChangeModel::startLaneChangeManeuver(), SVC_EMERGENCY, toString(), and veh().
|
protected |
Definition at line 695 of file MSLaneChanger.cpp.
References ACCEL2SPEED, MSCFModel::brakeGap(), DEBUG_COND, DELTA_T, MSVehicle::getAcceleration(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), MSLane::getCriticalLeader(), MSLane::getEdge(), MSCFModel::getHeadwayTime(), 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(), MIN2(), myCandi, MSAbstractLaneChangeModel::NO_NEIGHBOR, MSAbstractLaneChangeModel::saveState(), MSAbstractLaneChangeModel::setFollowerGaps(), MSAbstractLaneChangeModel::setLeaderGaps(), MSAbstractLaneChangeModel::setOrigLeaderGaps(), SIMTIME, STEPS2TIME, MSLane::succLinkSec(), toString(), TS, MSVehicle::unsafeLinkAhead(), veh(), and MSAbstractLaneChangeModel::wantsChange().
Referenced by changeOpposite(), checkChangeWithinEdge(), and veh().
|
protected |
Definition at line 678 of file MSLaneChanger.cpp.
References checkChange(), getRealFollower(), getRealLeader(), and myCandi.
|
protected |
Take into account traci LC-commands.
Definition at line 389 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 1225 of file MSLaneChanger.cpp.
References MSVehicle::getCarFollowModel(), MSVehicle::getLane(), MSVehicleType::getLength(), MSVehicleType::getLengthWithGap(), MSCFModel::getMaxAccel(), MSCFModel::getMaxDecel(), MSVehicleType::getMinGap(), MSCFModel::getSecureGap(), MSVehicle::getSpeed(), MSLane::getVehicleMaxSpeed(), MSBaseVehicle::getVehicleType(), OPPOSITE_OVERTAKING_SAFE_TIMEGAP, and TS.
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 446 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(), SIMTIME, 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 197 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 663 of file MSLaneChanger.cpp.
References MSVehicle::getPositionOnLane().
Referenced by getRealFollower(), and veh().
|
protected |
Definition at line 590 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 493 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 145 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 122 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 236 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 380 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(), and veh().
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0)
Definition at line 432 of file MSLaneChanger.cpp.
References continueChange(), MSVehicle::getLaneChangeModel(), myCandi, and MSAbstractLaneChangeModel::startLaneChangeManeuver().
|
protectedvirtual |
After the possible change, update the changer.
Reimplemented in MSLaneChangerSublane.
Definition at line 161 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 practice to modify foreign members, I know). Swap this container with the real one.
Definition at line 179 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 139 of file MSLaneChanger.h.
References applyTraCICommands(), change(), changeOpposite(), checkChange(), checkChangeWithinEdge(), checkTraCICommands(), computeOvertakingTime(), continueChange(), findCandidate(), getCloserFollower(), getRealFollower(), getRealLeader(), 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 126 of file MSLaneChanger.h.
References myChanger, and veh().
Referenced by laneChange().
|
protected |
Definition at line 233 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 229 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 224 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 236 of file MSLaneChanger.h.
Referenced by changeOpposite().