28 #define DEBUG_MANEUVER 29 #define DEBUG_COND (myVehicle.isSelected()) 72 throw ProcessError(
"Lane change model '" +
toString(lcm) +
"' is not compatible with sublane simulation");
152 #ifdef DEBUG_MANEUVER 180 myLeftLeaders = std::make_shared<MSLeaderDistanceInfo>(leaders);
181 }
else if (dir == 1) {
196 }
else if (dir == 1) {
215 const std::shared_ptr<MSLeaderDistanceInfo>
219 }
else if (dir == 1) {
228 const std::shared_ptr<MSLeaderDistanceInfo>
232 }
else if (dir == 1) {
244 if (neighLeader ==
nullptr) {
264 if (leader.first == 0) {
268 if (leader.first->getSpeed() < (80.0 / 3.6)) {
353 if (maneuverDist != 0) {
369 return DIST2SPEED(maneuverDist / stepsToChange);
414 #ifdef DEBUG_SHADOWLANE 416 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" posLat=" << posLat <<
" overlap=" << overlap <<
"\n";
423 const int shadowDirection = posLat < 0 ? -1 : 1;
447 std::cout <<
SIMTIME <<
" cleanupShadowLane\n";
454 std::cout <<
SIMTIME <<
" cleanupShadowLane2\n";
456 (*it)->resetPartialOccupation(&
myVehicle);
466 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
473 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
475 if (*it !=
nullptr) {
476 (*it)->resetManeuverReservation(&
myVehicle);
497 }
else if (dir < 0) {
509 #ifdef DEBUG_SHADOWLANE 511 std::cout <<
SIMTIME <<
" updateShadowLane()\n";
517 std::vector<MSLane*> passed;
522 assert(further.size() == furtherPosLat.size());
524 for (
int i = 0; i < (int)further.size(); ++i) {
526 #ifdef DEBUG_SHADOWLANE 528 std::cout <<
SIMTIME <<
" further=" << further[i]->getID() <<
" (posLat=" << furtherPosLat[i] <<
") shadowFurther=" <<
Named::getIDSecure(shadowFurther) <<
"\n";
532 passed.push_back(shadowFurther);
535 std::reverse(passed.begin(), passed.end());
543 #ifdef DEBUG_SHADOWLANE 548 std::cout << std::endl;
552 #ifdef DEBUG_SHADOWLANE 581 #ifdef DEBUG_TARGET_LANE 586 <<
"\n oldTarget: " << (oldTarget ==
nullptr ?
"NULL" : oldTarget->
getID())
587 <<
" oldFurtherTargets: " <<
toString(oldFurtherTargets);
595 if (oldTargetLane !=
nullptr) {
596 oldTargetLane->resetManeuverReservation(&
myVehicle);
599 myFurtherTargetLanes.clear();
610 myFurtherTargetLanes.push_back(furtherTargetLane);
611 if (furtherTargetLane !=
nullptr) {
616 #ifdef DEBUG_TARGET_LANE 618 std::cout <<
"\n newTarget (offset=" << targetDir <<
"): " << (
myTargetLane ==
nullptr ?
"NULL" : myTargetLane->
getID())
619 <<
" newFurtherTargets: " <<
toString(myFurtherTargetLanes)
645 if (targetDir == 0) {
679 if (remainingManeuverDist == 0) {
685 assert(remainingManeuverDist >= 0);
692 const double v0 = speed;
693 const double D = remainingManeuverDist;
694 const double b = decel;
711 const double vm = (wmax - wmin) / f;
712 double distSoFar = 0.;
713 double timeSoFar = 0.;
716 const double wmaxTime = (v0 - vm) / b;
717 const double d1 = wmax * wmaxTime;
722 timeSoFar += wmaxTime;
733 const double t = v / b;
734 const double d2 = (wmin + 0.5 * f * v) * t;
736 if (distSoFar + d2 >= D) {
738 const double x = 0.5 * f * b;
739 const double y = wmin + f * v;
743 const double p = 0.5 * y / x;
744 const double q = (D - distSoFar) / x;
745 assert(p * p - q > 0);
746 const double t2 = p + sqrt(p * p - q);
747 return timeSoFar + t2;
760 return timeSoFar + (D - distSoFar) / wmin;
805 const int dir = (newstate &
LCA_RIGHT) != 0 ? -1 : ((newstate &
LCA_LEFT) != 0 ? 1 : 0);
811 }
else if (((newstate &
LCA_RIGHT) != 0 && dir < 0)
812 || ((newstate & LCA_LEFT) != 0 && dir > 0)) {
834 std::cout <<
" traci influenced maneuverDist=" << maneuverDist <<
"\n";
851 if (follower.first != 0) {
852 myLastFollowerGap = follower.second + follower.first->getVehicleType().getMinGap();
860 if (leader.first != 0) {
869 if (leader.first != 0) {
881 for (
int i = rightmost; i <= leftmost; ++i) {
883 if (vehDist.first != 0) {
885 const MSVehicle* follower = vehDist.first;
887 if (netGap < myLastFollowerGap && netGap >= 0) {
901 for (
int i = rightmost; i <= leftmost; ++i) {
903 if (vehDist.first != 0) {
907 if (netGap < myLastLeaderGap && netGap >= 0) {
921 for (
int i = rightmost; i <= leftmost; ++i) {
923 if (vehDist.first != 0) {
927 if (netGap < myLastOrigLeaderGap && netGap >= 0) {
948 (stateLeft & LCA_STRATEGIC) != 0
950 && (stateLeft & LCA_BLOCKED) != 0) {
bool myDontResetLCGaps
Flag to prevent resetting the memorized values for LC relevant gaps until the LC output is triggered ...
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
static double gLateralResolution
static bool myLCEndedOutput
A lane change model developed by J. Erdmann.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const SubParams & getLCParams() const
Returns the LC parameter.
saves leader/follower vehicles and their distances relative to an ego vehicle
std::shared_ptr< MSLeaderDistanceInfo > myRightLeaders
double myLastLeaderSpeed
speeds of surrounding vehicles at the time of lane change
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
std::pair< int, int > mySavedStateRight
double myLastLateralGapRight
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
std::shared_ptr< MSLeaderDistanceInfo > myLeftLeaders
int myPreviousState
lane changing state from the previous simulation step
virtual double getAssumedDecelForLaneChangeDuration() const
Returns a deceleration value which is used for the estimation of the duration of a lane change...
MSLane * getLane() const
Returns the lane the vehicle is on.
void setLeaderGaps(CLeaderDist, double secGap)
void laneChangeOutput(const std::string &tag, MSLane *source, MSLane *target, int direction, double maneuverDist=0)
called once the vehicle ends a lane change manoeuvre (non-instant)
void clearNeighbors()
Clear info on neighboring vehicle from previous step.
double myLastLeaderGap
the actual minimum longitudinal distances to vehicles on the target lane
int getShadowDirection() const
return the direction in which the current shadow lane lies
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model) ...
double myLaneChangeCompletion
progress of the lane change maneuver 0:started, 1:complete
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
double myLastOrigLeaderSpeed
double getPositionOnLane() const
Get the vehicle's position along the lane.
double myPreviousManeuverDist
Maneuver distance from the previous simulation step.
Notification
Definition of a vehicle state.
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
std::string time2string(SUMOTime t)
static bool myLCOutput
whether to record lane-changing
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
std::shared_ptr< MSLeaderDistanceInfo > myRightFollowers
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double myLastOrigLeaderGap
acutal and secure distance to closest leader vehicle on the original when performing lane change ...
double getPreviousManeuverDist() const
double myLastFollowerSpeed
double getAngleOffset() const
return the angle offset during a continuous change maneuver
static bool myLCStartedOutput
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key ...
void leftByLaneChange(MSVehicle *v)
double myMaxSpeedLatStanding
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
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
const int VTYPEPARS_MAXSPEED_LAT_SET
MSLane * myTargetLane
The target lane for the vehicle's current maneuver.
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
double getWidth() const
Returns the lane's width.
#define UNUSED_PARAMETER(x)
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
#define WRITE_WARNING(msg)
void memorizeGapsAtLCInit()
Control for resetting the memorized values for LC relevant gaps until the LC output is triggered in t...
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
MSAbstractLaneChangeModel & getLaneChangeModel()
double myLastOrigLeaderSecureGap
Right blinker lights are switched on.
bool wasSet(int what) const
Returns whether the given parameter was set.
std::vector< double > myShadowFurtherLanesPosLat
void setFollowerGaps(CLeaderDist follower, double secGap)
Needs to stay on the current lane.
const LaneChangeModel myModel
the type of this model
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
The vehicle changes lanes (micro only)
virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel) const
Calculates the maximal time needed to complete a lane change maneuver if lcMaxSpeedLatFactor and lcMa...
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
The action has not been determined.
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013...
int getIndex() const
Returns the lane's index.
Left blinker lights are switched on.
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
double myManeuverDist
The complete lateral distance the vehicle wants to travel to finish its maneuver Only used by sublane...
blocked in all directions
double myLastFollowerSecureGap
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane ...
double updateFurtherLanes(std::vector< MSLane *> &furtherLanes, std::vector< double > &furtherLanesPosLat, const std::vector< MSLane *> &passedLanes)
update a vector of further lanes and return the new backPos
virtual double getSecureGap(const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
void enteredByLaneChange(MSVehicle *v)
double myMaxSpeedLatFactor
std::vector< MSLane * > myShadowFurtherLanes
const std::vector< MSLane * > & getFurtherLanes() const
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
virtual double interactionGap(const MSVehicle *const veh, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
The action is needed to follow the route (navigational lc)
int myLaneChangeDirection
direction of the lane change maneuver -1 means right, 1 means left
bool hasInfluencer() const
bool pastMidpoint() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver ...
MSLane * updateTargetLane()
double getMinGap() const
Get the free space in front of vehicles of this class.
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
void fixPosition()
repair errors in vehicle position after changing between internal edges
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
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.
MSLane * determineTargetLane(int &targetDir) const
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
bool cancelRequest(int state, int laneOffset)
whether the influencer cancels the given request
const SUMOVTypeParameter & getParameter() const
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
void setOrigLeaderGaps(CLeaderDist, double secGap)
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
void removeShadowApproachingInformation() const
const std::vector< double > & getFurtherLanesPosLat() const
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
std::pair< const MSVehicle *, double > CLeaderDist
trigger: the time of the step
Influencer & getInfluencer()
Returns the velocity/lane influencer.
std::shared_ptr< MSLeaderDistanceInfo > myLeftFollowers
Cached info on lc-relevant neighboring vehicles.
LaneChangeAction
The state of a vehicle's lane-change behavior.
void saveNeighbors(const int dir, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &leaders)
Saves the lane change relevant vehicles, which are currently on neighboring lanes in the given direct...
virtual void setOwnState(const int state)
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOTime myLastLaneChangeOffset
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool isStrategicBlocked() const
int & getCanceledState(const int dir)
A storage for options typed value containers)
std::vector< MSLane * > myFurtherTargetLanes
double mySpeedLat
the current lateral speed
const std::string & getID() const
Returns the name of the vehicle type.
The abstract direction of a link.
A lane change model developed by D. Krajzewicz between 2004 and 2010.
virtual double computeSpeedLat(double latDist, double &maneuverDist)
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
const std::shared_ptr< MSLeaderDistanceInfo > getFollowers(const int dir)
Returns the neighboring, lc-relevant followers for the last step in the requested direction...
The action is due to a TraCI request.
int myCanceledStateCenter
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
void switchOffSignal(int signal)
Switches the given signal off.
void switchOnSignal(int signal)
Switches the given signal on.
double myCommittedSpeed
the speed when committing to a change maneuver
std::vector< MSLink * > myApproachedByShadow
links which are approached by the shadow vehicle
const std::shared_ptr< MSLeaderDistanceInfo > getLeaders(const int dir)
Returns the neighboring, lc-relevant leaders for the last step in the requested direction.
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
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...
int myPreviousState2
lane changing state from step before the previous simulation step
double getSpeed() const
Returns the vehicle's current speed.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
double myLastLateralGapLeft
the minimum lateral gaps to other vehicles that were found when last changing to the left and right ...
double getLatDist() const
static SUMOTime gLaneChangeDuration
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
const std::string & getID() const
Returns the name of the vehicle.
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.
std::pair< int, int > mySavedStateLeft
bool myAmOpposite
whether the vehicle is driving in the opposite direction
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
void saveLCState(const int dir, const int stateWithoutTraCI, const int state)
Interface for lane-change models.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double getWidth() const
Returns the vehicle's width.
virtual bool congested(const MSVehicle *const neighLeader)
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
virtual ~MSAbstractLaneChangeModel()
Destructor.