Eclipse SUMO - Simulation of Urban MObility
MSLaneChanger Class Reference

Performs lane changing of vehicles. More...

#include <MSLaneChanger.h>

Inheritance diagram for MSLaneChanger:
Collaboration diagram for MSLaneChanger:

Data Structures

struct  ChangeElem
 

Public Types

typedef std::vector< ChangeElemChanger
 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)
 
MSVehicleveh (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 MSVehiclegetCloserFollower (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 MSLanegetLaneAfter (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...
 
MSLaneChangeroperator= (const MSLaneChanger &)
 Assignment operator. More...
 

Detailed Description

Performs lane changing of vehicles.

Definition at line 47 of file MSLaneChanger.h.

Member Typedef Documentation

◆ Changer

typedef std::vector< ChangeElem > MSLaneChanger::Changer

The list of changers; For each lane, a ChangeElem is being build.

Definition at line 105 of file MSLaneChanger.h.

◆ ChangerIt

typedef Changer::iterator MSLaneChanger::ChangerIt

the iterator moving over the ChangeElems

Definition at line 108 of file MSLaneChanger.h.

◆ ConstChangerIt

typedef Changer::const_iterator MSLaneChanger::ConstChangerIt

the iterator moving over the ChangeElems

Definition at line 111 of file MSLaneChanger.h.

Constructor & Destructor Documentation

◆ MSLaneChanger() [1/3]

MSLaneChanger::MSLaneChanger ( const std::vector< MSLane * > *  lanes,
bool  allowChanging 
)

Constructor.

Definition at line 92 of file MSLaneChanger.cpp.

References myChanger.

◆ ~MSLaneChanger()

MSLaneChanger::~MSLaneChanger ( )
virtual

Destructor.

Definition at line 115 of file MSLaneChanger.cpp.

◆ MSLaneChanger() [2/3]

MSLaneChanger::MSLaneChanger ( )
private

Default constructor.

◆ MSLaneChanger() [3/3]

MSLaneChanger::MSLaneChanger ( const MSLaneChanger )
private

Copy constructor.

Member Function Documentation

◆ applyTraCICommands()

bool MSLaneChanger::applyTraCICommands ( MSVehicle vehicle)
protected

Execute TraCI LC-commands.

Note
This is currently only used within non-actionsteps for the non-sublane model.
Returns
whether lane was changed

Definition at line 398 of file MSLaneChanger.cpp.

References continueChange(), MSVehicle::getLaneChangeModel(), MSAbstractLaneChangeModel::getOwnState(), LCA_BLOCKED, LCA_LEFT, LCA_RIGHT, myCandi, and MSAbstractLaneChangeModel::startLaneChangeManeuver().

Referenced by change().

◆ change()

◆ changeOpposite()

bool MSLaneChanger::changeOpposite ( std::pair< MSVehicle *, double >  leader)
protectedvirtual

try changing to the opposite direction edge.

Definition at line 1019 of file MSLaneChanger.cpp.

References MSLane::allowsVehicleClass(), checkChange(), computeOvertakingTime(), continueChange(), DEBUG_COND, findCandidate(), MSVehicle::getAcceleration(), MSVehicle::getBestLanes(), MSVehicle::getBestLanesContinuation(), MSVehicle::getCarFollowModel(), getColumnleader(), MSLinkContHelper::getConnectingLink(), MSLink::getDirection(), MSCFModel::getHeadwayTime(), MSBaseVehicle::getID(), Named::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, MSNet::lefthand(), MSVehicle::LaneQ::length, LINKDIR_STRAIGHT, LINKSTATE_ZIPPER, MIN2(), myCandi, myChangeToOpposite, MSVehicle::nextStopDist(), 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.

Referenced by change().

◆ checkChange()

int MSLaneChanger::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
protected

Definition at line 701 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(), MSLane::getWidth(), MSVehicleType::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::saveNeighbors(), MSAbstractLaneChangeModel::setFollowerGaps(), MSAbstractLaneChangeModel::setLeaderGaps(), MSAbstractLaneChangeModel::setOrigLeaderGaps(), SIMTIME, MSLane::succLinkSec(), toString(), TS, MSVehicle::unsafeLinkAhead(), veh(), and MSAbstractLaneChangeModel::wantsChange().

Referenced by changeOpposite(), and checkChangeWithinEdge().

◆ checkChangeWithinEdge()

int MSLaneChanger::checkChangeWithinEdge ( int  laneOffset,
const std::pair< MSVehicle *const, double > &  leader,
const std::vector< MSVehicle::LaneQ > &  preb 
) const
protected

Definition at line 684 of file MSLaneChanger.cpp.

References checkChange(), getRealFollower(), getRealLeader(), and myCandi.

Referenced by change().

◆ checkTraCICommands()

void MSLaneChanger::checkTraCICommands ( MSVehicle vehicle)
protected

Take into account traci LC-commands.

Note
This is currently only used within non-actionsteps.

Definition at line 377 of file MSLaneChanger.cpp.

References MSAbstractLaneChangeModel::checkTraCICommands(), DEBUG_COND, MSBaseVehicle::getID(), MSVehicle::getLaneChangeModel(), MSAbstractLaneChangeModel::getOwnState(), LCA_BLOCKED, LCA_OVERLAPPING, SIMTIME, and toString().

Referenced by change(), and MSLaneChangerSublane::change().

◆ computeOvertakingTime()

void MSLaneChanger::computeOvertakingTime ( const MSVehicle vehicle,
const MSVehicle leader,
double  gap,
double &  timeToOvertake,
double &  spaceToOvertake 
)
staticprotected

Compute the time and space required for overtaking the given leader.

Parameters
[in]vehicleThe vehicle that wants to overtake
[in]leaderThe vehicle to be overtaken
[in]gapThe gap between vehicle and leader
[out]timeToOvertakeThe time for overtaking
[out]spaceToOvertakeThe space for overtaking

XXX ignore speed limit when overtaking through the opposite lane?

Definition at line 1349 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(), MAX2(), OPPOSITE_OVERTAKING_SAFE_TIMEGAP, OPPOSITE_OVERTAKING_SAFETY_FACTOR, and TS.

Referenced by changeOpposite().

◆ continueChange()

◆ findCandidate()

MSLaneChanger::ChangerIt MSLaneChanger::findCandidate ( )
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 change(), MSLaneChangerSublane::change(), and changeOpposite().

◆ getCloserFollower()

MSVehicle * MSLaneChanger::getCloserFollower ( const double  maxPos,
MSVehicle follow1,
MSVehicle follow2 
)
staticprotected

return the closer follower of ego

Definition at line 669 of file MSLaneChanger.cpp.

References MSVehicle::getPositionOnLane().

Referenced by getRealFollower().

◆ getColumnleader()

◆ getLaneAfter()

MSLane * MSLaneChanger::getLaneAfter ( MSLane lane,
const std::vector< MSLane * > &  conts 
)
staticprotected

return the next lane in conts beyond lane or nullptr

Definition at line 1590 of file MSLaneChanger.cpp.

Referenced by getColumnleader().

◆ getRealFollower()

◆ getRealLeader()

◆ initChanger()

void MSLaneChanger::initChanger ( )
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().

◆ 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().

◆ mayChange()

bool MSLaneChanger::mayChange ( int  direction) const
protected

◆ operator=()

MSLaneChanger& MSLaneChanger::operator= ( const MSLaneChanger )
private

Assignment operator.

◆ registerUnchanged()

◆ startChange()

bool MSLaneChanger::startChange ( MSVehicle vehicle,
ChangerIt from,
int  direction 
)
protected

◆ updateChanger()

void MSLaneChanger::updateChanger ( bool  vehHasChanged)
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(), and MSLaneChangerSublane::updateChanger().

◆ updateLanes()

void MSLaneChanger::updateLanes ( SUMOTime  t)
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().

◆ veh()

MSVehicle* MSLaneChanger::veh ( ConstChangerIt  ce) const
inlineprotected

◆ vehInChanger()

bool MSLaneChanger::vehInChanger ( ) const
inlineprotected

Check if there is a single change-candidate in the changer. Returns true if there is one.

Definition at line 119 of file MSLaneChanger.h.

References myChanger, and veh().

Referenced by laneChange().

Field Documentation

◆ myAllowsChanging

const bool MSLaneChanger::myAllowsChanging
protected

Definition at line 233 of file MSLaneChanger.h.

Referenced by change(), and mayChange().

◆ myCandi

◆ myChanger

◆ myChangeToOpposite

const bool MSLaneChanger::myChangeToOpposite
protected

whether this edge allows changing to the opposite direction edge

Definition at line 236 of file MSLaneChanger.h.

Referenced by changeOpposite().


The documentation for this class was generated from the following files: