24 #ifndef MSAbstractLaneChangeModel_h 25 #define MSAbstractLaneChangeModel_h 126 StateAndDist(
int _state,
double _latDist,
double _targetDist,
int _dir) :
129 maneuverDist(_targetDist),
133 return latDist * other.
latDist > 0;
193 void saveState(
const int dir,
const int stateWithoutTraCI,
const int state) {
194 mySavedStates[dir] = std::make_pair(stateWithoutTraCI, state);
226 const std::pair<MSVehicle*, double>& leader,
227 const std::pair<MSVehicle*, double>& neighLead,
228 const std::pair<MSVehicle*, double>& neighFollow,
230 const std::vector<MSVehicle::LaneQ>& preb,
256 const std::vector<MSVehicle::LaneQ>& preb,
259 double& latDist,
double& targetDistLat,
int& blocked) {
308 virtual double patchSpeed(
const double min,
const double wanted,
const double max,
499 virtual void setParameter(
const std::string& key,
const std::string& value) {
514 virtual bool predInteraction(
const std::pair<MSVehicle*, double>& leader);
static bool myLCEndedOutput
std::vector< MSLane * > myPartiallyOccupatedByShadow
list of lanes where the shadow vehicle is partial occupator
saves leader/follower vehicles and their distances relative to an ego vehicle
Representation of a vehicle in the micro simulation.
double myLastLateralGapRight
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
int myPreviousState
lane changing state from the previous simulation step
virtual void * inform(void *info, MSVehicle *sender)=0
void setLeaderGaps(CLeaderDist, double secGap)
MSVehicle * myNeighLeader
The leader on the lane the vehicle want to change to.
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
MSLane * getTargetLane() const
Returns the lane the vehicle has committed to enter during a sublane lane change. ...
~MSLCMessager()
Destructor.
bool alreadyChanged() const
reset the flag whether a vehicle already moved to false
double myLastLeaderGap
the actual minimum longitudinal distances to vehicles on the target lane
double myLaneChangeCompletion
progress of the lane change maneuver 0:started, 1:complete
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
The car-following model abstraction.
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
int getShadowDirection() const
return the direction in which the current shadow lane lies
Notification
Definition of a vehicle state.
static bool myLCOutput
whether to record lane-changing
double myLastOrigLeaderGap
acutal and secure distance to closest leader vehicle on the original when performing lane change ...
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model) ...
const std::pair< int, int > & getSavedState(const int dir) const
MSLCMessager(MSVehicle *leader, MSVehicle *neighLead, MSVehicle *neighFollow)
Constructor.
static bool myLCStartedOutput
MSLane * myShadowLane
A lane that is partially occupied by the front of the vehicle but that is not the primary lane...
void initLastLaneChangeOffset(int dir)
static const double NO_NEIGHBOR
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
MSLane * myTargetLane
The target lane for the vehicle's current maneuver.
virtual bool sublaneChangeCompleted(const double latDist) const
whether the current change completes the manoeuvre
#define UNUSED_PARAMETER(x)
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
MSAbstractLaneChangeModel & getLaneChangeModel()
double myLastOrigLeaderSecureGap
void saveState(const int dir, const int stateWithoutTraCI, const int state)
std::vector< double > myShadowFurtherLanesPosLat
virtual double computeSpeedLat(double latDist, double &maneuverDist)
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
virtual double patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)=0
Called to adapt the speed in order to allow a lane change. It uses information on LC-related desired ...
MSVehicle * myNeighFollower
The follower on the lane the vehicle want to change to.
void setFollowerGaps(CLeaderDist follower, double secGap)
MSLane * determineTargetLane(int &targetDir) const
const LaneChangeModel myModel
the type of this model
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
A class responsible for exchanging messages between cars involved in lane-change interaction.
The vehicle changes lanes (micro only)
void setSpeedLat(double speedLat)
The action has not been determined.
bool cancelRequest(int state)
whether the influencer cancels the given request
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
double myManeuverDist
The complete lateral distance the vehicle wants to travel to finish its maneuver Only used by sublane...
double getAngleOffset() const
return the angle offset during a continuous change maneuver
double myLastFollowerSecureGap
bool pastMidpoint() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver ...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void setShadowPartialOccupator(MSLane *lane)
void setShadowLane(MSLane *lane)
set the shadow lane
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key ...
double getCommittedSpeed() const
virtual int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &neighFollow, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked)
Called to examine whether the vehicle wants to change using the given laneOffset. This method gets th...
std::vector< MSLane * > myShadowFurtherLanes
const std::vector< MSLane * > & getShadowFurtherLanes() const
bool sameDirection(const StateAndDist &other) const
void removeShadowApproachingInformation() const
virtual StateAndDist decideDirection(StateAndDist sd1, StateAndDist sd2) const
decide in which direction to move in case both directions are desirable
int myLaneChangeDirection
direction of the lane change maneuver -1 means right, 1 means left
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
const std::vector< double > & getShadowFurtherLanesPosLat() const
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
double myLastLeaderSecureGap
the minimum longitudinal distances to vehicles on the target lane that would be necessary for stringe...
int myOwnState
The current state of the vehicle.
void setOrigLeaderGaps(CLeaderDist, double secGap)
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key ...
virtual void updateExpectedSublaneSpeeds(const MSLeaderDistanceInfo &ahead, int sublaneOffset, int laneIndex)
update expected speeds for each sublane of the current edge
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
MSAbstractLaneChangeModel & operator=(const MSAbstractLaneChangeModel &s)
Invalidated assignment operator.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
std::pair< const MSVehicle *, double > CLeaderDist
LaneChangeAction
The state of a vehicle's lane-change behavior.
virtual void setOwnState(const int state)
SUMOTime remainingTime() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver ...
SUMOTime myLastLaneChangeOffset
void setNoShadowPartialOccupator(MSLane *lane)
StateAndDist(int _state, double _latDist, double _targetDist, int _dir)
void * informLeader(void *info, MSVehicle *sender)
Informs the leader on the same lane.
void resetChanged()
reset the flag whether a vehicle already moved to false
A storage for options typed value containers)
std::vector< MSLane * > myFurtherTargetLanes
double mySpeedLat
the current lateral speed
static bool haveLCOutput()
whether lanechange-output is active
virtual int wantsChangeSublane(int laneOffset, LaneChangeAction alternatives, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked, double &latDist, double &targetDistLat, int &blocked)
virtual void prepareStep()
virtual void saveBlockerLength(double length)
reserve space at the end of the lane to avoid dead locks
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
static bool outputLCStarted()
whether start of maneuvers shall be recorede
double myCommittedSpeed
the speed when committing to a change maneuver
std::vector< MSLink * > myApproachedByShadow
links which are approached by the shadow vehicle
void setManeuverDist(const double dist)
Updates the remaining distance for the current maneuver while it is continued within non-action steps...
virtual void updateSafeLatDist(const double travelledLatDist)
Updates the value of safe lateral distances (in SL2015) during maneuver continuation in non-action st...
static bool outputLCEnded()
whether start of maneuvers shall be recorede
int myPreviousState2
lane changing state from step before the previous simulation step
const std::vector< MSLane * > & getFurtherTargetLanes() const
double myLastLateralGapLeft
the minimum lateral gaps to other vehicles that were found when last changing to the left and right ...
void laneChangeOutput(const std::string &tag, MSLane *source, MSLane *target, int direction)
called once the vehicle ends a lane change manoeuvre (non-instant)
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
Representation of a lane in the micro simulation.
bool myAlreadyChanged
whether the vehicle has already moved this step
const MSCFModel & myCarFollowModel
The vehicle's car following model.
bool myAmOpposite
whether the vehicle is driving in the opposite direction
SUMOTime getLastLaneChangeOffset() const
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
Interface for lane-change models.
MSVehicle * myLeader
The leader on the informed vehicle's lane.
std::map< int, std::pair< int, int > > mySavedStates
int getLaneChangeDirection() const
return the direction of the current lane change maneuver
virtual bool congested(const MSVehicle *const neighLeader)
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
virtual ~MSAbstractLaneChangeModel()
Destructor.