28 #define DEBUG_COND (myVehicle.isSelected()) 71 throw ProcessError(
"Lane change model '" +
toString(lcm) +
"' is not compatible with sublane simulation");
141 #ifdef DEBUG_MANEUVER 161 if (neighLeader ==
nullptr) {
181 if (leader.first == 0) {
185 if (leader.first->getSpeed() < (80.0 / 3.6)) {
277 return DIST2SPEED(maneuverDist / stepsToChange);
321 #ifdef DEBUG_SHADOWLANE 323 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" posLat=" << posLat <<
" overlap=" << overlap <<
"\n";
327 const int shadowDirection = posLat < 0 ? -1 : 1;
351 std::cout <<
SIMTIME <<
" cleanupShadowLane\n";
358 std::cout <<
SIMTIME <<
" cleanupShadowLane2\n";
360 (*it)->resetPartialOccupation(&
myVehicle);
370 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
377 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
379 if (*it !=
nullptr) {
380 (*it)->resetManeuverReservation(&
myVehicle);
401 }
else if (dir < 0) {
413 #ifdef DEBUG_SHADOWLANE 415 std::cout <<
SIMTIME <<
" updateShadowLane()\n";
421 std::vector<MSLane*> passed;
426 assert(further.size() == furtherPosLat.size());
428 for (
int i = 0; i < (int)further.size(); ++i) {
430 #ifdef DEBUG_SHADOWLANE 432 std::cout <<
SIMTIME <<
" further=" << further[i]->getID() <<
" (posLat=" << furtherPosLat[i] <<
") shadowFurther=" <<
Named::getIDSecure(shadowFurther) <<
"\n";
436 passed.push_back(shadowFurther);
439 std::reverse(passed.begin(), passed.end());
447 #ifdef DEBUG_SHADOWLANE 452 std::cout << std::endl;
456 #ifdef DEBUG_SHADOWLANE 482 #ifdef DEBUG_TARGET_LANE 487 <<
"\n oldTarget: " << (oldTarget ==
nullptr ?
"NULL" : oldTarget->
getID())
488 <<
" oldFurtherTargets: " <<
toString(oldFurtherTargets);
496 if (oldTargetLane !=
nullptr) {
497 oldTargetLane->resetManeuverReservation(&
myVehicle);
500 myFurtherTargetLanes.clear();
511 myFurtherTargetLanes.push_back(furtherTargetLane);
512 if (furtherTargetLane !=
nullptr) {
517 #ifdef DEBUG_TARGET_LANE 519 std::cout <<
"\n newTarget (offset=" << targetDir <<
"): " << (
myTargetLane ==
nullptr ?
"NULL" : myTargetLane->
getID())
520 <<
" newFurtherTargets: " <<
toString(myFurtherTargetLanes)
545 if (targetDir == 0) {
579 if (remainingManeuverDist == 0) {
585 assert(remainingManeuverDist >= 0);
592 const double v0 = speed;
593 const double D = remainingManeuverDist;
594 const double b = decel;
611 const double vm = (wmax - wmin) / f;
612 double distSoFar = 0.;
613 double timeSoFar = 0.;
616 const double wmaxTime = (v0 - vm) / b;
617 const double d1 = wmax * wmaxTime;
622 timeSoFar += wmaxTime;
633 const double t = v / b;
634 const double d2 = (wmin + 0.5 * f * v) * t;
636 if (distSoFar + d2 >= D) {
638 const double x = 0.5 * f * b;
639 const double y = wmin + f * v;
643 const double p = 0.5 * y / x;
644 const double q = (D - distSoFar) / x;
645 assert(p * p - q > 0);
646 const double t2 = p + sqrt(p * p - q);
647 return timeSoFar + t2;
660 return timeSoFar + (D - distSoFar) / wmin;
705 const int dir = (newstate &
LCA_RIGHT) != 0 ? -1 : ((newstate &
LCA_LEFT) != 0 ? 1 : 0);
711 }
else if (((newstate &
LCA_RIGHT) != 0 && dir < 0)
712 || ((newstate & LCA_LEFT) != 0 && dir > 0)) {
734 std::cout <<
" traci influenced maneuverDist=" << maneuverDist <<
"\n";
751 if (follower.first != 0) {
752 myLastFollowerGap = follower.second + follower.first->getVehicleType().getMinGap();
759 if (leader.first != 0) {
767 if (leader.first != 0) {
778 for (
int i = rightmost; i <= leftmost; ++i) {
780 if (vehDist.first != 0) {
782 const MSVehicle* follower = vehDist.first;
784 if (netGap < myLastFollowerGap && netGap >= 0) {
797 for (
int i = rightmost; i <= leftmost; ++i) {
799 if (vehDist.first != 0) {
803 if (netGap < myLastLeaderGap && netGap >= 0) {
816 for (
int i = rightmost; i <= leftmost; ++i) {
818 if (vehDist.first != 0) {
822 if (netGap < myLastOrigLeaderGap && netGap >= 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
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
double myLastLateralGapRight
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
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)
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 getPositionOnLane() const
Get the vehicle's position along the lane.
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.
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 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.
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.
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...
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)
double getCenterOnEdge() const
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
virtual double interactionGap(const MSVehicle *const veh, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
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 ...
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.
LaneChangeAction
The state of a vehicle's lane-change behavior.
virtual void setOwnState(const int state)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOTime myLastLaneChangeOffset
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.
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...
The action is due to a TraCI request.
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
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 ...
std::map< int, int > myCanceledStates
double getLatDist() const
static SUMOTime gLaneChangeDuration
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.
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.
bool myAmOpposite
whether the vehicle is driving in the opposite direction
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
Interface for lane-change models.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double getWidth() const
Returns the vehicle's width.
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
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.