 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
29 #define DEBUG_COND (myVehicle.isSelected())
73 throw ProcessError(
"Lane change model '" +
toString(lcm) +
"' is not compatible with sublane simulation");
104 myLaneChangeCompletion(1.0),
105 myLaneChangeDirection(0),
107 myPreviousManeuverDist(0.),
108 myAlreadyChanged(false),
109 myShadowLane(nullptr),
110 myTargetLane(nullptr),
111 myCarFollowModel(v.getCarFollowModel()),
113 myLastLateralGapLeft(0.),
114 myLastLateralGapRight(0.),
116 myLastFollowerGap(0.),
117 myLastLeaderSecureGap(0.),
118 myLastFollowerSecureGap(0.),
119 myLastOrigLeaderGap(0.),
120 myLastOrigLeaderSecureGap(0.),
121 myLastLeaderSpeed(0),
122 myLastFollowerSpeed(0),
123 myLastOrigLeaderSpeed(0),
124 myDontResetLCGaps(false),
128 myLastLaneChangeOffset(0),
129 myAmOpposite(false) {
154 #ifdef DEBUG_MANEUVER
182 myLeftLeaders = std::make_shared<MSLeaderDistanceInfo>(leaders);
183 }
else if (dir == 1) {
198 }
else if (dir == 1) {
217 const std::shared_ptr<MSLeaderDistanceInfo>
221 }
else if (dir == 1) {
230 const std::shared_ptr<MSLeaderDistanceInfo>
234 }
else if (dir == 1) {
246 if (neighLeader ==
nullptr) {
266 if (leader.first == 0) {
270 if (leader.first->getSpeed() < (80.0 / 3.6)) {
313 #ifdef DEBUG_OPPOSITE
360 if (maneuverDist != 0) {
376 return DIST2SPEED(maneuverDist / stepsToChange);
411 #ifdef DEBUG_OPPOSITE
426 #ifdef DEBUG_SHADOWLANE
428 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" posLat=" << posLat <<
" overlap=" << overlap <<
"\n";
435 const int shadowDirection = posLat < 0 ? -1 : 1;
459 std::cout <<
SIMTIME <<
" cleanupShadowLane\n";
466 std::cout <<
SIMTIME <<
" cleanupShadowLane2\n";
468 (*it)->resetPartialOccupation(&
myVehicle);
478 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
485 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
487 if (*it !=
nullptr) {
488 (*it)->resetManeuverReservation(&
myVehicle);
509 }
else if (dir < 0) {
521 #ifdef DEBUG_SHADOWLANE
523 std::cout <<
SIMTIME <<
" updateShadowLane()\n";
529 std::vector<MSLane*> passed;
534 assert(further.size() == furtherPosLat.size());
536 for (
int i = 0; i < (int)further.size(); ++i) {
538 #ifdef DEBUG_SHADOWLANE
540 std::cout <<
SIMTIME <<
" further=" << further[i]->getID() <<
" (posLat=" << furtherPosLat[i] <<
") shadowFurther=" <<
Named::getIDSecure(shadowFurther) <<
"\n";
544 passed.push_back(shadowFurther);
547 std::reverse(passed.begin(), passed.end());
555 #ifdef DEBUG_SHADOWLANE
560 std::cout << std::endl;
564 #ifdef DEBUG_SHADOWLANE
593 #ifdef DEBUG_TARGET_LANE
598 <<
"\n oldTarget: " << (oldTarget ==
nullptr ?
"NULL" : oldTarget->
getID())
599 <<
" oldFurtherTargets: " <<
toString(oldFurtherTargets);
607 if (oldTargetLane !=
nullptr) {
608 oldTargetLane->resetManeuverReservation(&
myVehicle);
623 if (furtherTargetLane !=
nullptr) {
628 #ifdef DEBUG_TARGET_LANE
657 if (targetDir == 0) {
691 if (remainingManeuverDist == 0) {
697 assert(remainingManeuverDist >= 0);
704 const double v0 = speed;
705 const double D = remainingManeuverDist;
706 const double b = decel;
723 const double vm = (wmax - wmin) / f;
724 double distSoFar = 0.;
725 double timeSoFar = 0.;
728 const double wmaxTime = (v0 - vm) / b;
729 const double d1 = wmax * wmaxTime;
734 timeSoFar += wmaxTime;
745 const double t = v / b;
746 const double d2 = (wmin + 0.5 * f * v) * t;
748 if (distSoFar + d2 >= D) {
750 const double x = 0.5 * f * b;
751 const double y = wmin + f * v;
755 const double p = 0.5 * y / x;
756 const double q = (D - distSoFar) / x;
757 assert(p * p - q > 0);
758 const double t2 = p + sqrt(p * p - q);
759 return timeSoFar + t2;
772 return timeSoFar + (D - distSoFar) / wmin;
817 const int dir = (newstate &
LCA_RIGHT) != 0 ? -1 : ((newstate &
LCA_LEFT) != 0 ? 1 : 0);
823 }
else if (((newstate &
LCA_RIGHT) != 0 && dir < 0)
824 || ((newstate &
LCA_LEFT) != 0 && dir > 0)) {
846 std::cout <<
" traci influenced maneuverDist=" << maneuverDist <<
"\n";
863 if (follower.first != 0) {
864 myLastFollowerGap = follower.second + follower.first->getVehicleType().getMinGap();
872 if (leader.first != 0) {
881 if (leader.first != 0) {
917 for (
int i = rightmost; i <= leftmost; ++i) {
919 if (vehDist.first != 0) {
921 const MSVehicle* follower = vehDist.first;
923 if (netGap < myLastFollowerGap && netGap >= 0) {
937 for (
int i = rightmost; i <= leftmost; ++i) {
939 if (vehDist.first != 0) {
943 if (netGap < myLastLeaderGap && netGap >= 0) {
957 for (
int i = rightmost; i <= leftmost; ++i) {
959 if (vehDist.first != 0) {
963 if (netGap < myLastOrigLeaderGap && netGap >= 0) {
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
MSLane * myTargetLane
The target lane for the vehicle's current maneuver.
MSLane * myShadowLane
A lane that is partially occupied by the front of the vehicle but that is not the primary lane.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
#define UNUSED_PARAMETER(x)
std::pair< int, int > mySavedStateLeft
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
bool myAmOpposite
whether the vehicle is driving in the opposite direction
const std::string & getID() const
Returns the name of the vehicle type.
double myPreviousManeuverDist
Maneuver distance from the previous simulation step.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
#define WRITE_WARNING(msg)
virtual ~MSAbstractLaneChangeModel()
Destructor.
double myLastFollowerSpeed
Representation of a lane in the micro simulation.
double myLastOrigLeaderSpeed
@ LCA_LEFT
Wants go to the left.
bool cancelRequest(int state, int laneOffset)
whether the influencer cancels the given request
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
Static storage of an output device and its base (abstract) implementation.
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
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...
bool hasInfluencer() const
static bool myLCStartedOutput
void setOrigLeaderGaps(CLeaderDist, double secGap)
double myLastLeaderSpeed
speeds of surrounding vehicles at the time of lane change
static bool myLCOutput
whether to record lane-changing
void setManeuverDist(const double dist)
Updates the remaining distance for the current maneuver while it is continued within non-action steps...
virtual double getSecureGap(const MSVehicle *const, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
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...
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
double myManeuverDist
The complete lateral distance the vehicle wants to travel to finish its maneuver Only used by sublane...
std::vector< MSLane * > myShadowFurtherLanes
double myLastLeaderSecureGap
the minimum longitudinal distances to vehicles on the target lane that would be necessary for stringe...
virtual void setOwnState(const int state)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
bool myAlreadyChanged
whether the vehicle has already moved this step
void setLeaderGaps(CLeaderDist, double secGap)
void initLastLaneChangeOffset(int dir)
SUMOTime myLastLaneChangeOffset
const std::shared_ptr< MSLeaderDistanceInfo > getLeaders(const int dir)
Returns the neighboring, lc-relevant leaders for the last step in the requested direction.
std::vector< MSLane * > myFurtherTargetLanes
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
@ SUMO_ATTR_LCA_MAXSPEEDLATFACTOR
double myLastLateralGapLeft
the minimum lateral gaps to other vehicles that were found when last changing to the left and right
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double myLaneChangeCompletion
progress of the lane change maneuver 0:started, 1:complete
@ SUMO_ATTR_DIR
The abstract direction of a link.
double myLastOrigLeaderGap
acutal and secure distance to closest leader vehicle on the original when performing lane change
MSLane * updateTargetLane()
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
const SubParams & getLCParams() const
Returns the LC parameter.
std::vector< MSLink * > myApproachedByShadow
links which are approached by the shadow vehicle
static double gLateralResolution
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
double myLastLeaderGap
the actual minimum longitudinal distances to vehicles on the target lane
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
virtual double interactionGap(const MSVehicle *const veh, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
double getAngleOffset() const
return the angle offset during a continuous change maneuver
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
@ SUMO_ATTR_LCA_MAXSPEEDLATSTANDING
void removeShadowApproachingInformation() const
void switchOffSignal(int signal)
Switches the given signal off.
void fixPosition()
repair errors in vehicle position after changing between internal edges
void switchOnSignal(int signal)
Switches the given signal on.
const int VTYPEPARS_MAXSPEED_LAT_SET
std::pair< int, int > mySavedStateRight
void memorizeGapsAtLCInit()
Control for resetting the memorized values for LC relevant gaps until the LC output is triggered in t...
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
double myLastLateralGapRight
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.
int myLaneChangeDirection
direction of the lane change maneuver -1 means right, 1 means left
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...
@ LCA_STRATEGIC
The action is needed to follow the route (navigational lc)
std::shared_ptr< MSLeaderDistanceInfo > myLeftLeaders
double getPositionOnLane() const
Get the vehicle's position along the lane.
int & getCanceledState(const int dir)
double myLastFollowerSecureGap
std::shared_ptr< MSLeaderDistanceInfo > myRightLeaders
LaneChangeAction
The state of a vehicle's lane-change behavior.
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
double myMaxSpeedLatFactor
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
virtual void prepareStep()
const LaneChangeModel myModel
the type of this model
void leftByLaneChange(MSVehicle *v)
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
int myPreviousState2
lane changing state from step before the previous simulation step
virtual bool congested(const MSVehicle *const neighLeader)
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
MSAbstractLaneChangeModel & getLaneChangeModel()
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
double mySpeedLat
the current lateral speed
std::string time2string(SUMOTime t)
double getMinGap() const
Get the free space in front of vehicles of this class.
A storage for options typed value containers)
double getPreviousManeuverDist() const
A lane change model developed by J. Erdmann.
const std::vector< double > & getFurtherLanesPosLat() const
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
double myCommittedSpeed
the speed when committing to a change maneuver
@ SUMO_ATTR_TIME
trigger: the time of the step
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
std::vector< double > myShadowFurtherLanesPosLat
MSLane * getLane() const
Returns the lane the vehicle is on.
MSEdge & getEdge() const
Returns the lane's edge.
bool pastMidpoint() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver
void clearNeighbors()
Clear info on neighboring vehicle from previous step.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
void setFollowerGaps(CLeaderDist follower, double secGap)
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double myMaxSpeedLatStanding
@ LCA_RIGHT
Wants go to the right.
const std::vector< MSLane * > & getFurtherLanes() const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const MSCFModel & myCarFollowModel
The vehicle's car following model.
@ LCA_STAY
Needs to stay on the current lane.
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...
@ LCA_AMBACKBLOCKER_STANDING
static bool myLCEndedOutput
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
virtual void updateSafeLatDist(const double travelledLatDist)
Updates the value of safe lateral distances (in SL2015) during maneuver continuation in non-action st...
bool wasSet(int what) const
Returns whether the given parameter was set.
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
int myOwnState
The current state of the vehicle.
static const double NO_NEIGHBOR
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 saveLCState(const int dir, const int stateWithoutTraCI, const int state)
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the name of the vehicle.
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.
bool isStrategicBlocked() const
double getWidth() const
Returns the lane's width.
double getWidth() const
Returns the vehicle's width.
int getShadowDirection() const
return the direction in which the current shadow lane lies
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Interface for lane-change models.
double getLatDist() const
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
double getSpeed() const
Returns the vehicle's current speed.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
bool myDontResetLCGaps
Flag to prevent resetting the memorized values for LC relevant gaps until the LC output is triggered ...
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane
static SUMOTime gLaneChangeDuration
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013.
virtual double computeSpeedLat(double latDist, double &maneuverDist)
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
MSLane * determineTargetLane(int &targetDir) const
std::pair< const MSVehicle *, double > CLeaderDist
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
int myPreviousState
lane changing state from the previous simulation step
double myLastOrigLeaderSecureGap
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
const std::shared_ptr< MSLeaderDistanceInfo > getFollowers(const int dir)
Returns the neighboring, lc-relevant followers for the last step in the requested direction.
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
int getIndex() const
Returns the lane's index.
@ LCA_UNKNOWN
The action has not been determined.
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
A lane change model developed by D. Krajzewicz between 2004 and 2010.
@ LCA_TRACI
The action is due to a TraCI request.
void enteredByLaneChange(MSVehicle *v)
virtual double getAssumedDecelForLaneChangeDuration() const
Returns a deceleration value which is used for the estimation of the duration of a lane change.
@ LCA_BLOCKED
blocked in all directions
std::shared_ptr< MSLeaderDistanceInfo > myRightFollowers
std::shared_ptr< MSLeaderDistanceInfo > myLeftFollowers
Cached info on lc-relevant neighboring vehicles.
Representation of a vehicle in the micro simulation.