29 #define DEBUG_COND (myVehicle.isSelected()) 76 throw ProcessError(
"Lane change model '" +
toString(lcm) +
"' is not compatible with sublane simulation");
143 #ifdef DEBUG_MANEUVER 163 if (neighLeader == 0) {
183 if (leader.first == 0) {
187 if (leader.first->getSpeed() < (80.0 / 3.6)) {
283 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" posLat=" << posLat <<
" overlap=" << overlap <<
"\n";
288 const int shadowDirection = posLat < 0 ? -1 : 1;
309 std::cout <<
SIMTIME <<
" cleanupShadowLane\n";
316 std::cout <<
SIMTIME <<
" cleanupShadowLane2\n";
318 (*it)->resetPartialOccupation(&
myVehicle);
328 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
335 std::cout <<
SIMTIME <<
" cleanupTargetLane\n";
337 if (*it !=
nullptr) {
338 (*it)->resetManeuverReservation(&
myVehicle);
357 }
else if (dir < 0) {
366 std::cout <<
SIMTIME <<
" updateShadowLane()\n";
371 std::vector<MSLane*> passed;
376 assert(further.size() == furtherPosLat.size());
378 for (
int i = 0; i < (int)further.size(); ++i) {
381 std::cout <<
SIMTIME <<
" further=" << further[i]->getID() <<
" (posLat=" << furtherPosLat[i] <<
") shadowFurther=" <<
Named::getIDSecure(shadowFurther) <<
"\n";
384 passed.push_back(shadowFurther);
387 std::reverse(passed.begin(), passed.end());
399 std::cout << std::endl;
426 #ifdef DEBUG_TARGET_LANE 431 <<
"\n oldTarget: " << (oldTarget ==
nullptr ?
"NULL" : oldTarget->
getID())
432 <<
" oldFurtherTargets: " <<
toString(oldFurtherTargets);
440 if (oldTargetLane !=
nullptr) {
441 oldTargetLane->resetManeuverReservation(&
myVehicle);
444 myFurtherTargetLanes.clear();
455 myFurtherTargetLanes.push_back(furtherTargetLane);
456 if (furtherTargetLane !=
nullptr) {
461 #ifdef DEBUG_TARGET_LANE 463 std::cout <<
"\n newTarget (offset=" << targetDir <<
"): " << (
myTargetLane ==
nullptr ?
"NULL" : myTargetLane->
getID())
464 <<
" newFurtherTargets: " <<
toString(myFurtherTargetLanes)
489 if (targetDir == 0) {
541 const int dir = (newstate &
LCA_RIGHT) != 0 ? -1 : ((newstate &
LCA_LEFT) != 0 ? 1 : 0);
547 }
else if (((newstate &
LCA_RIGHT) != 0 && dir < 0)
548 || ((newstate & LCA_LEFT) != 0 && dir > 0)) {
570 std::cout <<
" traci influenced maneuverDist=" << maneuverDist <<
"\n";
587 if (follower.first != 0) {
588 myLastFollowerGap = follower.second + follower.first->getVehicleType().getMinGap();
595 if (leader.first != 0) {
603 if (leader.first != 0) {
614 for (
int i = rightmost; i <= leftmost; ++i) {
616 if (vehDist.first != 0) {
618 const MSVehicle* follower = vehDist.first;
620 if (netGap < myLastFollowerGap && netGap >= 0) {
633 for (
int i = rightmost; i <= leftmost; ++i) {
635 if (vehDist.first != 0) {
639 if (netGap < myLastLeaderGap && netGap >= 0) {
652 for (
int i = rightmost; i <= leftmost; ++i) {
654 if (vehDist.first != 0) {
658 if (netGap < myLastOrigLeaderGap && netGap >= 0) {
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
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
int myPreviousState
lane changing state from the previous simulation step
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
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
void leftByLaneChange(MSVehicle *v)
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.
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
return whether the vehicle passed the midpoint of a continuous lane change maneuver ...
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
#define WRITE_WARNING(msg)
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.
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)
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.
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 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
double getCenterOnEdge() const
void enteredByLaneChange(MSVehicle *v)
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
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
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.
The action is due to a TraCI request.
Static storage of an output device and its base (abstract) implementation.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
bool closeTag()
Closes the most recently opened tag.
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...
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)
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
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.