48 MSLaneChanger(
const std::vector<MSLane*>* lanes,
bool allowChanging);
143 if (!ce->lane->myVehicles.empty()) {
144 return ce->lane->myVehicles.back();
159 double> neighOncoming,
double searchDist,
double& vMax,
const MSVehicle* overtaken =
nullptr,
163 std::pair<MSVehicle*, double> overtaken,
double searchDist);
193 const std::pair<MSVehicle* const, double>& leader,
194 const std::vector<MSVehicle::LaneQ>& preb)
const;
201 const std::pair<MSVehicle* const, double>& leader,
202 const std::pair<MSVehicle* const, double>& follower,
203 const std::pair<MSVehicle* const, double>& neighLead,
204 const std::pair<MSVehicle* const, double>& neighFollow,
205 const std::vector<MSVehicle::LaneQ>& preb)
const;
213 const std::pair<MSVehicle* const, double>& leader,
214 const std::pair<MSVehicle* const, double>& neighLead,
215 const std::pair<MSVehicle* const, double>& neighFollow,
216 const std::vector<MSVehicle::LaneQ>& preb);
254 static std::pair<MSVehicle*, double>
getColumnleader(
double& maxSpace,
MSVehicle* vehicle, std::pair<MSVehicle*, double> leader,
double maxLookAhead = std::numeric_limits<double>::max());
257 static const MSLane*
getLaneAfter(
const MSLane* lane,
const std::vector<MSLane*>& conts,
bool allowMinor,
bool& contsEnd);
269 std::pair<MSVehicle*, double> neighLead,
270 std::pair<MSVehicle*, double> overtaken,
271 std::pair<MSVehicle*, double> leader);
277 std::pair<MSVehicle* const, double> leader,
278 std::pair<MSVehicle*, double> neighLead,
279 std::pair<MSVehicle*, double> overtaken);
289 std::pair<MSVehicle*, double> oncoming,
double vMax,
double oncomingSpeed,
290 std::pair<MSVehicle*, double> neighLead,
291 std::pair<MSVehicle*, double> overtaken,
292 std::pair<MSVehicle*, double> neighFollow,
293 double surplusGap,
const MSLane* opposite,
298 double spaceToOvertake,
double& oncomingSpeed,
bool oncomingOpposite =
false);
301 static bool foundHilltop(
MSVehicle* vehicle,
bool foundHill,
double searchDist,
const std::vector<MSLane*>& bestLanes,
int view,
double pos,
double lastMax,
double hilltopThreshold);
Performs lane changing of vehicles.
virtual ~MSLaneChanger()
Destructor.
bool applyTraCICommands(MSVehicle *vehicle)
Execute TraCI LC-commands.
bool continueChange(MSVehicle *vehicle, ChangerIt &from)
continue a lane change maneuver and return whether the vehicle has completely moved onto the new lane...
const bool myChangeToOpposite
whether this edge allows changing to the opposite direction edge
MSLaneChanger(const MSLaneChanger &)
Copy constructor.
bool checkOppositeStop(MSVehicle *vehicle, const MSLane *oncomingLane, const MSLane *opposite, std::pair< MSVehicle *, double > leader)
decide whether to change (back or forth) for an opposite stop
bool changeOpposite(MSVehicle *vehicle, std::pair< MSVehicle *, double > leader, MSVehicle *lastStopped)
MSLaneChanger()
Default constructor.
static bool hasOppositeStop(MSVehicle *vehicle)
whether vehicle has an opposite-direction stop within relevant range
void checkTraCICommands(MSVehicle *vehicle)
Take into account traci LC-commands.
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
virtual void initChanger()
Initialize the changer before looping over all vehicles.
bool vehInChanger() const
Check if there is a single change-candidate in the changer. Returns true if there is one.
std::pair< MSVehicle *const, double > getRealFollower(const ChangerIt &target) const
static const MSLane * getLaneAfter(const MSLane *lane, const std::vector< MSLane * > &conts, bool allowMinor, bool &contsEnd)
return the next lane in conts beyond lane or nullptr
std::pair< MSVehicle *const, double > getOncomingOppositeVehicle(const MSVehicle *vehicle, std::pair< MSVehicle *, double > overtaken, double searchDist)
std::vector< ChangeElem > Changer
The list of changers; For each lane, a ChangeElem is being build.
MSVehicle * veh(ConstChangerIt ce) const
std::pair< MSVehicle *const, double > getOncomingVehicle(const MSLane *opposite, std::pair< MSVehicle *, double > neighOncoming, double searchDist, double &vMax, const MSVehicle *overtaken=nullptr, MSLane::MinorLinkMode mLinkMode=MSLane::MinorLinkMode::FOLLOW_NEVER)
bool startChange(MSVehicle *vehicle, ChangerIt &from, int direction)
const bool myAllowsChanging
double computeSafeOppositeLength(MSVehicle *vehicle, double oppositeLength, const MSLane *source, double usableDist, std::pair< MSVehicle *, double > oncoming, double vMax, double oncomingSpeed, std::pair< MSVehicle *, double > neighLead, std::pair< MSVehicle *, double > overtaken, std::pair< MSVehicle *, double > neighFollow, double surplusGap, const MSLane *opposite, bool canOvertake)
determine for how long the vehicle can drive safely on the opposite side
int checkChangeWithinEdge(int laneOffset, const std::pair< MSVehicle *const, double > &leader, const std::vector< MSVehicle::LaneQ > &preb) const
static bool foundHilltop(MSVehicle *vehicle, bool foundHill, double searchDist, const std::vector< MSLane * > &bestLanes, int view, double pos, double lastMax, double hilltopThreshold)
Changer myChanger
Container for ChangeElemements, one for every lane in the edge.
static double computeSurplusGap(const MSVehicle *vehicle, const MSLane *opposite, std::pair< MSVehicle *, double > oncoming, double timeToOvertake, double spaceToOvertake, double &oncomingSpeed, bool oncomingOpposite=false)
ChangerIt findCandidate()
Find current candidate. If there is none, myChanger.end() is returned.
bool mayChange(int direction) const
whether changing to the lane in the given direction should be considered
Changer::const_iterator ConstChangerIt
the iterator moving over the ChangeElems
bool yieldToOppositeWaiting(const MSVehicle *vehicle, const MSVehicle *stoppedNeigh, double dist, SUMOTime deltaWait=0)
check whether to yield for oncoming vehicles that have waited longer for opposite overtaking
static MSVehicle * getCloserFollower(const double maxPos, MSVehicle *follow1, MSVehicle *follow2)
return the closer follower of ego
void registerUnchanged(MSVehicle *vehicle)
void updateLanes(SUMOTime t)
bool avoidDeadlock(MSVehicle *vehicle, std::pair< MSVehicle *, double > neighLead, std::pair< MSVehicle *, double > overtaken, std::pair< MSVehicle *, double > leader)
avoid opposite-diretion deadlock when vehicles are stopped on both sides of the road The method may c...
static std::pair< MSVehicle *, double > getColumnleader(double &maxSpace, MSVehicle *vehicle, std::pair< MSVehicle *, double > leader, double maxLookAhead=std::numeric_limits< double >::max())
return leader vehicle that is to be overtaken
static double getMaxOvertakingSpeed(const MSVehicle *vehicle, double maxSpaceToOvertake)
compute maximum maneuver speed
bool resolveDeadlock(MSVehicle *vehicle, std::pair< MSVehicle *const, double > leader, std::pair< MSVehicle *, double > neighLead, std::pair< MSVehicle *, double > overtaken)
keep stopping to resolve opposite-diretion deadlock while there is oncoming traffic The method may ca...
std::pair< MSVehicle *const, double > getRealLeader(const ChangerIt &target) const
bool yieldToDeadlockOncoming(const MSVehicle *vehicle, const MSVehicle *stoppedNeigh, double dist)
check whether to keep stopping for oncoming vehicles in the deadlock zone
Changer & getChanger()
return changer (only to be used by MSLaneChangerSublane from another instance)
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
int checkChange(int laneOffset, const MSLane *targetLane, const std::pair< MSVehicle *const, double > &leader, const std::pair< MSVehicle *const, double > &follower, const std::pair< MSVehicle *const, double > &neighLead, const std::pair< MSVehicle *const, double > &neighFollow, const std::vector< MSVehicle::LaneQ > &preb) const
virtual bool checkChangeOpposite(MSVehicle *vehicle, int laneOffset, 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)
MSLaneChanger & operator=(const MSLaneChanger &)
Assignment operator.
static void computeOvertakingTime(const MSVehicle *vehicle, double vMax, const MSVehicle *leader, double gap, double &timeToOvertake, double &spaceToOvertake)
Compute the time and space required for overtaking the given leader.
static std::vector< MSVehicle::LaneQ > getBestLanesOpposite(MSVehicle *vehicle, const MSLane *stopLane, double oppositeLength)
add LaneQ for opposite lanes
virtual void updateChanger(bool vehHasChanged)
Representation of a lane in the micro simulation.
MinorLinkMode
determine whether/how getFollowers looks upstream beyond minor links
saves leader/follower vehicles and their distances relative to an ego vehicle
Representation of a vehicle in the micro simulation.
std::vector< int > siblings
std::vector< MSVehicle * > outsideBounds
vehicles that cannot be stored in ahead because they are outside the lane bounds
bool mayChangeRight
whether changing is possible to either direction
MSVehicle * lead
the leader vehicle for the current change candidate
MSVehicle * lastStopped
the next vehicle downstream of the ego vehicle that is stopped (and thus an obstacle)
MSLeaderDistanceInfo aheadNext
MSLane * lane
the lane corresponding to this ChangeElem (the current change candidate is on this lane)
MSVehicle * lastBlocked
the next vehicle downstream of the ego vehicle that is blocked from changing to this lane
MSVehicle * firstBlocked
the farthest downstream vehicle on this edge that is blocked from changing to this lane
void registerHop(MSVehicle *vehicle)
Register that vehicle belongs to Changer Item to after LC decisions.
MSVehicle * hoppedVeh
last vehicle that changed into this lane