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, bool allowSwap)
 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, SUMORealgetRealFollower (const ChangerIt &target) const
 
std::pair< MSVehicle *const, SUMORealgetRealLeader (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)
 
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, SUMOReal gap, SUMOReal &timeToOvertake, SUMOReal &spaceToOvertake)
 Compute the time and space required for overtaking the given leader. More...
 
static MSVehiclegetCloserFollower (const SUMOReal maxPos, MSVehicle *follow1, MSVehicle *follow2)
 return the closer follower of ego More...
 

Protected Attributes

bool myAllowsChanging
 
bool myAllowsSwap
 Whether blocking vehicles may be swapped. More...
 
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 55 of file MSLaneChanger.h.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 81 of file MSLaneChanger.cpp.

References myChanger.

MSLaneChanger::~MSLaneChanger ( )
virtual

Destructor.

Definition at line 94 of file MSLaneChanger.cpp.

MSLaneChanger::MSLaneChanger ( )
private

Default constructor.

MSLaneChanger::MSLaneChanger ( const MSLaneChanger )
private

Copy constructor.

Member Function Documentation

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

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 706 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(), and veh().

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

Definition at line 524 of file MSLaneChanger.cpp.

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

Referenced by change(), and veh().

void MSLaneChanger::computeOvertakingTime ( const MSVehicle vehicle,
const MSVehicle leader,
SUMOReal  gap,
SUMOReal timeToOvertake,
SUMOReal 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 929 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(), and veh().

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

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

return the closer follower of ego

Definition at line 509 of file MSLaneChanger.cpp.

References MSVehicle::getPositionOnLane().

Referenced by getRealFollower(), and veh().

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

bool MSLaneChanger::mayChange ( int  direction) const
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(), MSLaneChangerSublane::startChangeSublane(), and veh().

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

Assignment operator.

void MSLaneChanger::registerUnchanged ( MSVehicle vehicle)
protected
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 379 of file MSLaneChanger.cpp.

References continueChange(), MSVehicle::getLaneChangeModel(), MSVehicleType::getLengthWithGap(), MSBaseVehicle::getVehicleType(), myCandi, and MSAbstractLaneChangeModel::startLaneChangeManeuver().

Referenced by change(), and veh().

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

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

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

References myChanger, and veh().

Referenced by laneChange().

Field Documentation

bool MSLaneChanger::myAllowsChanging
protected

Definition at line 217 of file MSLaneChanger.h.

Referenced by change(), and mayChange().

bool MSLaneChanger::myAllowsSwap
protected

Whether blocking vehicles may be swapped.

Definition at line 213 of file MSLaneChanger.h.

Referenced by change().

ChangerIt MSLaneChanger::myCandi
protected
Changer MSLaneChanger::myChanger
protected
const bool MSLaneChanger::myChangeToOpposite
protected

whether this edge allows changing to the opposite direction edge

Definition at line 220 of file MSLaneChanger.h.

Referenced by changeOpposite().


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