SUMO - Simulation of Urban MObility
MSLaneChanger Class Reference

Performs lane changing of vehicles. More...

#include <MSLaneChanger.h>

Inheritance diagram for MSLaneChanger:
Inheritance graph
Collaboration diagram for MSLaneChanger:
Collaboration graph

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

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 54 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 112 of file MSLaneChanger.h.

◆ ChangerIt

typedef Changer::iterator MSLaneChanger::ChangerIt

the iterator moving over the ChangeElems

Definition at line 115 of file MSLaneChanger.h.

◆ ConstChangerIt

typedef Changer::const_iterator MSLaneChanger::ConstChangerIt

the iterator moving over the ChangeElems

Definition at line 118 of file MSLaneChanger.h.

Constructor & Destructor Documentation

◆ MSLaneChanger() [1/3]

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

Constructor.

Definition at line 94 of file MSLaneChanger.cpp.

References myChanger.

◆ ~MSLaneChanger()

MSLaneChanger::~MSLaneChanger ( )
virtual

Destructor.

Definition at line 117 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 410 of file MSLaneChanger.cpp.

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

Referenced by change(), and veh().

◆ change()

◆ changeOpposite()

bool MSLaneChanger::changeOpposite ( std::pair< MSVehicle *, double >  leader)
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().

Referenced by change(), and veh().

◆ 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

◆ checkChangeWithinEdge()

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

Definition at line 678 of file MSLaneChanger.cpp.

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

Referenced by change(), and veh().

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

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

◆ continueChange()

◆ findCandidate()

MSLaneChanger::ChangerIt MSLaneChanger::findCandidate ( )
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().

◆ getCloserFollower()

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

return the closer follower of ego

Definition at line 663 of file MSLaneChanger.cpp.

References MSVehicle::getPositionOnLane().

Referenced by getRealFollower(), and veh().

◆ getRealFollower()

std::pair< MSVehicle *const, double > MSLaneChanger::getRealFollower ( const ChangerIt target) const
protected

◆ getRealLeader()

◆ initChanger()

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

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

◆ mayChange()

bool MSLaneChanger::mayChange ( int  direction) const
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().

◆ operator=()

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

Assignment operator.

◆ registerUnchanged()

◆ startChange()

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

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

Referenced by change(), and veh().

◆ updateChanger()

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

◆ 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 179 of file MSLaneChanger.cpp.

References myChanger.

Referenced by laneChange(), and veh().

◆ veh()

◆ 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 126 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

ChangerIt MSLaneChanger::myCandi
protected

◆ 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: