47 #define OPPOSITE_OVERTAKING_SAFE_TIMEGAP 0.0 49 #define OPPOSITE_OVERTAKING_MAX_LOOKAHEAD 150.0 // just a guess 50 #define OPPOSITE_OVERTAKING_MAX_LOOKAHEAD_EMERGENCY 1000.0 // just a guess 52 #define OPPOSITE_OVERTAKING_ONCOMING_LOOKAHEAD 200.0 // just a guess 66 #define DEBUG_COND (vehicle->isSelected()) 80 aheadNext(lane, 0, 0) {
100 for (std::vector<MSLane*>::const_iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
102 myChanger.back().mayChangeRight = lane != lanes->begin();
103 myChanger.back().mayChangeLeft = (lane + 1) != lanes->end();
105 if ((*lane)->isInternal()) {
106 if (
myChanger.back().mayChangeRight && (*lane)->getLogicalPredecessorLane() == (*(lane - 1))->getLogicalPredecessorLane()) {
109 if (
myChanger.back().mayChangeLeft && (*lane)->getLogicalPredecessorLane() == (*(lane + 1))->getLogicalPredecessorLane()) {
130 const bool haveChanged =
change();
137 ce->lane->releaseVehicles();
151 ce->firstBlocked = 0;
153 ce->lane->getVehiclesSecure();
190 ce->lane->swapAfterLaneChange(t);
191 ce->lane->releaseVehicles();
201 #ifdef DEBUG_CANDIDATE 202 std::cout <<
SIMTIME <<
" findCandidate() on edge " <<
myChanger.begin()->lane->getEdge().getID() << std::endl;
209 #ifdef DEBUG_CANDIDATE 210 std::cout <<
" lane = " << ce->lane->getID() <<
"\n";
214 #ifdef DEBUG_CANDIDATE 220 assert(
veh(ce) != 0);
221 assert(
veh(max) != 0);
222 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
223 #ifdef DEBUG_CANDIDATE 230 assert(
veh(max) != 0);
237 if (direction == 0) {
243 if (direction == -1) {
244 return myCandi->mayChangeRight && (
myCandi - 1)->lane->allowsVehicleClass(
veh(
myCandi)->getVehicleType().getVehicleClass());
245 }
else if (direction == 1) {
246 return myCandi->mayChangeLeft && (
myCandi + 1)->lane->allowsVehicleClass(
veh(
myCandi)->getVehicleType().getVehicleClass());
263 #ifdef DEBUG_ACTIONSTEPS 288 #ifdef DEBUG_ACTIONSTEPS 290 std::cout <<
SIMTIME <<
" veh '" << vehicle->
getID() <<
"' skips regular change checks." << std::endl;
293 bool changed =
false;
319 for (
int i = 0; i < (int)
myChanger.size(); ++i) {
323 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
334 if ((stateRight & LCA_RIGHT) != 0 && (stateRight &
LCA_URGENT) != 0) {
335 (
myCandi - 1)->lastBlocked = vehicle;
336 if ((
myCandi - 1)->firstBlocked == 0) {
337 (
myCandi - 1)->firstBlocked = vehicle;
352 if ((stateLeft & LCA_LEFT) != 0 && (stateLeft &
LCA_URGENT) != 0) {
353 (
myCandi + 1)->lastBlocked = vehicle;
354 if ((
myCandi + 1)->firstBlocked == 0) {
355 (
myCandi + 1)->firstBlocked = vehicle;
398 <<
" veh=" << vehicle->
getID()
401 << ((newstate &
LCA_BLOCKED) != 0 ?
" (blocked)" :
"")
412 bool changed =
false;
414 const int dir = (state &
LCA_RIGHT) != 0 ? -1 : ((state &
LCA_LEFT) != 0 ? 1 : 0);
415 const bool execute = dir != 0 && ((state &
LCA_BLOCKED) == 0);
423 to->registerHop(vehicle);
441 to->registerHop(vehicle);
455 MSLane* target = to->lane;
458 to->registerHop(vehicle);
460 from->registerHop(vehicle);
470 shadow->hoppedVeh = vehicle;
474 #ifdef DEBUG_CONTINUE_CHANGE 477 <<
" continueChange veh=" << vehicle->
getID()
479 <<
" dir=" << direction
480 <<
" pastMidpoint=" << pastMidpoint
492 std::pair<MSVehicle* const, double>
496 #ifdef DEBUG_SURROUNDING_VEHICLES 498 std::cout <<
SIMTIME <<
" veh '" << vehicle->
getID() <<
"' looks for leader on lc-target lane '" << target->lane->getID() <<
"'." << std::endl;
504 #ifdef DEBUG_SURROUNDING_VEHICLES 506 if (neighLead != 0) {
507 std::cout <<
"Considering '" << neighLead->
getID() <<
"' at position " << neighLead->
getPositionOnLane() << std::endl;
518 if (target->hoppedVeh != 0) {
519 double hoppedPos = target->hoppedVeh->getPositionOnLane();
520 #ifdef DEBUG_SURROUNDING_VEHICLES 522 std::cout <<
"Considering hopped vehicle '" << target->hoppedVeh->getID() <<
"' at position " << hoppedPos << std::endl;
526 neighLead = target->hoppedVeh;
530 if (neighLead == 0) {
531 #ifdef DEBUG_SURROUNDING_VEHICLES 533 std::cout <<
"Looking for leader on consecutive lanes." << std::endl;
538 MSLane* targetLane = target->lane;
540 double leaderBack = targetLane->
getLength();
543 if (plBack < leaderBack &&
549 if (neighLead != 0) {
550 #ifdef DEBUG_SURROUNDING_VEHICLES 552 std::cout <<
" found leader=" << neighLead->
getID() <<
" (partial)\n";
561 #ifdef DEBUG_SURROUNDING_VEHICLES 563 std::cout <<
" found no leader within dist=" << dist <<
"\n";
566 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(0), -1);
570 std::pair<MSVehicle* const, double> result = target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
571 #ifdef DEBUG_SURROUNDING_VEHICLES 579 #ifdef DEBUG_SURROUNDING_VEHICLES 581 std::cout <<
" found leader=" << neighLead->
getID() <<
"\n";
589 std::pair<MSVehicle* const, double>
593 #ifdef DEBUG_SURROUNDING_VEHICLES 596 std::cout <<
SIMTIME <<
" veh '" << vehicle->
getID() <<
"' looks for follower on lc-target lane '" << target->lane->getID() <<
"'." << std::endl;
603 #ifdef DEBUG_SURROUNDING_VEHICLES 605 if (neighFollow != 0) {
606 std::cout <<
"veh(target) returns '" << neighFollow->
getID() <<
"' at position " << neighFollow->
getPositionOnLane() << std::endl;
608 std::cout <<
"veh(target) returns none." << std::endl;
614 #ifdef DEBUG_SURROUNDING_VEHICLES 616 if (
getCloserFollower(candiPos, neighFollow, target->hoppedVeh) != neighFollow) {
617 std::cout <<
"Hopped vehicle '" << target->hoppedVeh->getID() <<
"' at position " << target->hoppedVeh->getPositionOnLane() <<
" is closer." << std::endl;
626 #ifdef DEBUG_SURROUNDING_VEHICLES 629 if (partialBehind != 0 && partialBehind != neighFollow) {
630 std::cout <<
"'Partial behind'-vehicle '" << target->lane->getPartialBehind(candi)->
getID() <<
"' at position " << target->hoppedVeh->getPositionOnLane() <<
" is closer." << std::endl;
635 neighFollow =
getCloserFollower(candiPos, neighFollow, target->lane->getPartialBehind(candi));
637 if (neighFollow == 0) {
639 #ifdef DEBUG_SURROUNDING_VEHICLES 641 if (consecutiveFollower.first == 0) {
642 std::cout <<
"no follower found." << std::endl;
644 std::cout <<
"found follower '" << consecutiveFollower.first->
getID() <<
"' on consecutive lanes." << std::endl;
648 return std::make_pair(const_cast<MSVehicle*>(consecutiveFollower.first), consecutiveFollower.second);
650 #ifdef DEBUG_SURROUNDING_VEHICLES 652 std::cout <<
"found follower '" << neighFollow->
getID() <<
"'." << std::endl;
656 return std::pair<MSVehicle* const, double>(neighFollow,
680 const std::pair<MSVehicle* const, double>& leader,
681 const std::vector<MSVehicle::LaneQ>& preb)
const {
685 if (neighLead.first != 0 && neighLead.first == neighFollow.first) {
688 neighFollow.first = 0;
691 return checkChange(laneOffset, target->lane, leader, neighLead, neighFollow, preb);
698 const std::pair<MSVehicle* const, double>& leader,
699 const std::pair<MSVehicle* const, double>& neighLead,
700 const std::pair<MSVehicle* const, double>& neighFollow,
701 const std::vector<MSVehicle::LaneQ>& preb)
const {
706 #ifdef DEBUG_CHECK_CHANGE 709 <<
"\n" <<
SIMTIME <<
" checkChange() for vehicle '" << vehicle->
getID() <<
"'" 719 if (neighFollow.first != 0 && neighFollow.second < 0) {
723 #ifdef DEBUG_CHECK_CHANGE 726 <<
" overlapping with follower..." 732 if (neighLead.first != 0 && neighLead.second < 0) {
736 #ifdef DEBUG_CHECK_CHANGE 739 <<
" overlapping with leader..." 751 if ((blocked & blockedByFollower) == 0 && neighFollow.first != 0) {
760 const double followerTauRemainder =
MAX2(neighFollow.first->getCarFollowModel().getHeadwayTime() -
TS, 0.);
761 const double vNextFollower = neighFollow.first->getSpeed() +
MAX2(0., followerTauRemainder * neighFollow.first->getAcceleration());
764 secureBackGap = neighFollow.first->getCarFollowModel().getSecureGap(vNextFollower,
766 if (neighFollow.second < secureBackGap) {
767 blocked |= blockedByFollower;
770 #ifdef DEBUG_CHECK_CHANGE 773 <<
" back gap unsafe: " 774 <<
"gap = " << neighFollow.second
776 << neighFollow.first->getCarFollowModel().getSecureGap(vNextFollower,
786 if ((blocked & blockedByLeader) == 0 && neighLead.first != 0) {
797 const double vNextLeader = neighLead.first->getSpeed() +
MIN2(0., followerTauRemainder * neighLead.first->getAcceleration());
800 vNextLeader, neighLead.first->getCarFollowModel().getMaxDecel());
801 if (neighLead.second < secureFrontGap) {
802 blocked |= blockedByLeader;
805 #ifdef DEBUG_CHECK_CHANGE 808 <<
" front gap unsafe: " 809 <<
"gap = " << neighLead.second
812 vNextLeader, neighLead.first->getCarFollowModel().getMaxDecel())
819 if (leader.first != 0) {
825 laneOffset, msg, blocked, leader, neighLead, neighFollow, *targetLane, preb, &(
myCandi->lastBlocked), &(
myCandi->firstBlocked));
831 const double speed = vehicle->
getSpeed();
834 std::pair<MSVehicle* const, double> neighLead2 = targetLane->
getCriticalLeader(dist, seen, speed, *vehicle);
835 if (neighLead2.first != 0 && neighLead2.first != neighLead.first
837 vehicle->
getSpeed(), neighLead2.first->getSpeed(), neighLead2.first->getCarFollowModel().getMaxDecel()))) {
838 state |= blockedByLeader;
842 if (blocked == 0 && (state & LCA_WANTS_LANECHANGE)) {
845 state |= blockedByLeader;
854 const double avgSpeed = 0.5 * (
862 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*vehicle, view, *nextLane, bestLaneConts);
863 while (!nextLane->
isLinkEnd(link) && seen <= space2change) {
867 || (nextLane->
getEdge().
isInternal() && (*link)->getViaLaneOrLane()->getEdge().isInternal())
872 if ((*link)->getViaLane() == 0) {
875 nextLane = (*link)->getViaLaneOrLane();
880 if (nextLane->
isLinkEnd(link) && seen < space2change) {
881 #ifdef DEBUG_CHECK_CHANGE 883 std::cout <<
SIMTIME <<
" checkChange insufficientSpace: seen=" << seen <<
" space2change=" << space2change <<
"\n";
889 if ((state & LCA_BLOCKED) == 0) {
892 const double speed = vehicle->
getSpeed();
897 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*vehicle, view, *nextLane, bestLaneConts);
898 while (!nextLane->
isLinkEnd(link) && seen <= space2change && seen <= dist) {
899 nextLane = (*link)->getViaLaneOrLane();
901 if (targetLane == 0) {
905 std::pair<MSVehicle* const, double> neighLead2 = targetLane->
getLeader(vehicle, -seen, std::vector<MSLane*>());
906 if (neighLead2.first != 0 && neighLead2.first != neighLead.first
908 vehicle->
getSpeed(), neighLead2.first->getSpeed(), neighLead2.first->getCarFollowModel().getMaxDecel()))) {
909 state |= blockedByLeader;
913 if ((*link)->getViaLane() == 0) {
922 const int oldstate = state;
927 #ifdef DEBUG_CHECK_CHANGE 930 <<
" veh=" << vehicle->
getID()
939 if (blocked == 0 && (state & LCA_WANTS_LANECHANGE)) {
963 if (!isOpposite && leader.first == 0) {
975 int direction = isOpposite ? -1 : 1;
976 std::pair<MSVehicle*, double> neighLead((
MSVehicle*)0, -1);
979 double timeToOvertake;
980 double spaceToOvertake;
982 assert(leader.first != 0);
986 std::pair<MSVehicle*, double> columnLeader = leader;
987 double egoGap = leader.second;
988 bool foundSpaceAhead =
false;
989 double seen = leader.second + leader.first->getVehicleType().getLengthWithGap();
991 while (!foundSpaceAhead) {
992 const double requiredSpaceAfterLeader = (columnLeader.first->getCarFollowModel().getSecureGap(
998 const bool checkTmpVehicles = (&columnLeader.first->getLane()->getEdge() == &source->
getEdge());
999 std::pair<MSVehicle* const, double> leadLead = columnLeader.first->getLane()->getLeader(
1000 columnLeader.first, columnLeader.first->getPositionOnLane(), conts, requiredSpaceAfterLeader + mergeBrakeGap,
1003 #ifdef DEBUG_CHANGE_OPPOSITE 1005 std::cout <<
" leadLead=" <<
Named::getIDSecure(leadLead.first) <<
" gap=" << leadLead.second <<
"\n";
1008 if (leadLead.first == 0) {
1009 foundSpaceAhead =
true;
1014 const double requiredSpace = (requiredSpaceAfterLeader
1015 + vehicle->
getCarFollowModel().
getSecureGap(overtakingSpeed, leadLead.first->getSpeed(), leadLead.first->getCarFollowModel().getMaxDecel()));
1016 if (leadLead.second > requiredSpace) {
1017 foundSpaceAhead =
true;
1019 #ifdef DEBUG_CHANGE_OPPOSITE 1021 std::cout <<
" not enough space after columnLeader=" << columnLeader.first->getID() <<
" required=" << requiredSpace <<
"\n";
1024 seen +=
MAX2(0., leadLead.second) + leadLead.first->getVehicleType().getLengthWithGap();
1025 if (seen > maxLookAhead) {
1026 #ifdef DEBUG_CHANGE_OPPOSITE 1028 std::cout <<
" cannot changeOpposite due to insufficient free space after columnLeader (seen=" << seen <<
" columnLeader=" << columnLeader.first->getID() <<
")\n";
1034 egoGap += columnLeader.first->getVehicleType().getLengthWithGap() + leadLead.second;
1035 columnLeader = leadLead;
1036 #ifdef DEBUG_CHANGE_OPPOSITE 1038 std::cout <<
" new columnLeader=" << columnLeader.first->getID() <<
"\n";
1044 #ifdef DEBUG_CHANGE_OPPOSITE 1046 std::cout <<
" compute time/space to overtake for columnLeader=" << columnLeader.first->getID() <<
" gap=" << columnLeader.second <<
"\n";
1052 #ifdef DEBUG_CHANGE_OPPOSITE 1054 std::cout <<
" cannot changeOpposite due to upcoming stop (dist=" << vehicle->
nextStopDist() <<
" spaceToOvertake=" << spaceToOvertake <<
")\n";
1061 #ifdef DEBUG_CHANGE_OPPOSITE 1064 <<
" veh=" << vehicle->
getID()
1065 <<
" changeOpposite opposite=" << opposite->
getID()
1067 <<
" timeToOvertake=" << timeToOvertake
1068 <<
" spaceToOvertake=" << spaceToOvertake
1074 if (neighLead.first != 0) {
1075 const MSVehicle* oncoming = neighLead.first;
1077 #ifdef DEBUG_CHANGE_OPPOSITE 1080 <<
" oncoming=" << oncoming->
getID()
1081 <<
" oncomingGap=" << neighLead.second
1082 <<
" leaderGap=" << leader.second
1086 if (neighLead.second - spaceToOvertake - timeToOvertake * oncoming->
getSpeed() < 0) {
1088 #ifdef DEBUG_CHANGE_OPPOSITE 1090 std::cout <<
" cannot changeOpposite due to dangerous oncoming\n";
1097 timeToOvertake = -1;
1099 spaceToOvertake = std::numeric_limits<double>::max();
1108 if (usableDist < spaceToOvertake) {
1111 assert(bestLaneConts.size() >= 1);
1112 std::vector<MSLane*>::const_iterator it = bestLaneConts.begin() + 1;
1113 while (usableDist < spaceToOvertake && it != bestLaneConts.end()) {
1114 #ifdef DEBUG_CHANGE_OPPOSITE 1116 std::cout <<
" usableDist=" << usableDist <<
" opposite=" <<
Named::getIDSecure((*it)->getOpposite()) <<
"\n";
1119 if ((*it)->getOpposite() == 0) {
1124 if (*(it - 1) != 0) {
1133 #ifdef DEBUG_CHANGE_OPPOSITE 1135 std::cout <<
" stop lookahead at link=" << (link == 0 ?
"NULL" : link->
getViaLaneOrLane()->
getID()) <<
" state=" << (link == 0 ?
"?" :
toString(link->getState())) <<
" ignoreRed=" << vehicle->
ignoreRed(link,
true) <<
"\n";
1141 usableDist += (*it)->getLength();
1145 if (!isOpposite && usableDist < spaceToOvertake) {
1146 #ifdef DEBUG_CHANGE_OPPOSITE 1148 std::cout <<
" cannot changeOpposite due to insufficient space (seen=" << usableDist <<
" spaceToOvertake=" << spaceToOvertake <<
")\n";
1153 #ifdef DEBUG_CHANGE_OPPOSITE 1155 std::cout <<
" usableDist=" << usableDist <<
" spaceToOvertake=" << spaceToOvertake <<
" timeToOvertake=" << timeToOvertake <<
"\n";
1161 std::vector<MSVehicle::LaneQ> preb = vehicle->
getBestLanes();
1176 if (leader.first != 0) {
1178 #ifdef DEBUG_CHANGE_OPPOSITE 1180 std::cout <<
SIMTIME <<
" found oncoming leader=" << leader.first->getID() <<
" gap=" << leader.second <<
"\n";
1185 #ifdef DEBUG_CHANGE_OPPOSITE 1187 std::cout <<
SIMTIME <<
" veh=" << vehicle->
getID() <<
" remaining dist=" << laneQ.
length - forwardPos <<
" forwardPos=" << forwardPos <<
" laneQ.length=" << laneQ.
length <<
"\n";
1192 int state =
checkChange(direction, opposite, leader, neighLead, neighFollow, preb);
1194 bool changingAllowed = (state &
LCA_BLOCKED) == 0;
1207 #ifdef DEBUG_CHANGE_OPPOSITE 1209 std::cout <<
SIMTIME <<
" changing to opposite veh=" << vehicle->
getID() <<
" dir=" << direction <<
" opposite=" <<
Named::getIDSecure(opposite) <<
" state=" << state <<
"\n";
1214 #ifdef DEBUG_CHANGE_OPPOSITE 1216 std::cout <<
SIMTIME <<
" not changing to opposite veh=" << vehicle->
getID() <<
" dir=" << direction
1234 const double v = vehicle->
getSpeed();
1235 const double u = leader->
getSpeed();
1247 const double sign = -1;
1251 double t = (u - v - sqrt(4 * (u - v) * (u - v) + 8 * a * g) * sign * 0.5) / a;
1256 t = ceil(t /
TS) *
TS;
1259 const double timeToMaxSpeed = (vMax - v) / a;
1261 if (t <= timeToMaxSpeed) {
1263 spaceToOvertake = v * t + t * t * a * 0.5;
1267 const double s = v * timeToMaxSpeed + timeToMaxSpeed * timeToMaxSpeed * a * 0.5;
1268 const double m = timeToMaxSpeed;
1271 t = (g - s + m * vMax) / (vMax - u);
1276 t = ceil(t /
TS) *
TS;
1279 spaceToOvertake = s + (t - m) * vMax;
double myPos
the stored position
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
bool getRespectJunctionPriority() const
Returns whether junction priority rules shall be respected.
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double computeAngle() const
compute the current vehicle angle
static MSVehicle * getCloserFollower(const double maxPos, MSVehicle *follow1, MSVehicle *follow2)
return the closer follower of ego
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
bool ignoreRed(const MSLink *link, bool canBrake) const
decide whether a red (or yellow light) may be ignore
MSEdge & getEdge() const
Returns the lane's edge.
double myAngle
the angle in radians (
Representation of a vehicle in the micro simulation.
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
MSLane * lane
the lane the vehicle is on
The action is done to help someone else.
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
State myState
This Vehicles driving state (pos and speed)
MSLane * getLane() const
Returns the lane the vehicle is on.
void setLeaderGaps(CLeaderDist, double secGap)
The vehicle is blocked by left follower.
int checkChange(int laneOffset, const MSLane *targetLane, const std::pair< MSVehicle *const, double > &leader, const std::pair< MSVehicle *const, double > &neighLead, const std::pair< MSVehicle *const, double > &neighFollow, const std::vector< MSVehicle::LaneQ > &preb) const
bool continueChange(MSVehicle *vehicle, ChangerIt &from)
continue a lane change maneuver and return whether the midpoint was passed in this step (used if gLan...
virtual void initChanger()
Initialize the changer before looping over all vehicles.
int getShadowDirection() const
return the direction in which the current shadow lane lies
virtual bool changeOpposite(std::pair< MSVehicle *, double > leader)
const bool myAllowsChanging
double getPositionOnLane() const
Get the vehicle's position along the lane.
double myPosLat
the stored lateral position
MSVehicle * veh(ConstChangerIt ce) const
std::pair< MSVehicle *const, double > getRealLeader(const ChangerIt &target) const
const bool myChangeToOpposite
whether this edge allows changing to the opposite direction edge
#define OPPOSITE_OVERTAKING_MAX_LOOKAHEAD
double getLength() const
Returns the lane's length.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
bool isLinkEnd(MSLinkCont::const_iterator &i) const
bool isStoppedOnLane() const
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
bool alreadyChanged() const
reset the flag whether a vehicle already moved to false
static const double NO_NEIGHBOR
void startChange(MSVehicle *vehicle, ChangerIt &from, int direction)
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0) ...
const std::string & getID() const
Returns the id.
ChangeElem(MSLane *_lane)
double length
The overall length which may be driven when using this lane without a lane change.
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
double getWidth() const
Returns the lane's width.
ChangerIt findCandidate()
Find current candidate. If there is none, myChanger.end() is returned.
This is an uncontrolled, zipper-merge link.
The link is a (hard) left direction.
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
MSAbstractLaneChangeModel & getLaneChangeModel()
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
bool vehInChanger() const
Check if there is a single change-candidate in the changer. Returns true if there is one...
LinkState getState() const
Returns the current state of the link.
void saveState(const int dir, const int stateWithoutTraCI, const int state)
bool applyTraCICommands(MSVehicle *vehicle)
Execute TraCI LC-commands.
The link is a straight direction.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
void setFollowerGaps(CLeaderDist follower, double secGap)
void checkTraCICommands(MSVehicle *vehicle)
Take into account traci LC-commands.
A class responsible for exchanging messages between cars involved in lane-change interaction.
The vehicle changes lanes (micro only)
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
virtual void updateChanger(bool vehHasChanged)
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
blocked in all directions
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The action is urgent (to be defined by lc-model)
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
#define OPPOSITE_OVERTAKING_MAX_LOOKAHEAD_EMERGENCY
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...
Position myCachedPosition
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
int getLaneChangeDirection() const
return the direction of the current lane change maneuver
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
void registerHop(MSVehicle *vehicle)
Register that vehicle belongs to Changer Item to after LC decisions.
bool havePriority() const
Returns whether this link is a major link.
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
The link is a (hard) right direction.
std::pair< MSVehicle *const, double > getLeader(const MSVehicle *veh, const double vehPos, const std::vector< MSLane *> &bestLaneConts, double dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
static void computeOvertakingTime(const MSVehicle *vehicle, const MSVehicle *leader, double gap, double &timeToOvertake, double &spaceToOvertake)
Compute the time and space required for overtaking the given leader.
A structure representing the best lanes for continuing the current route starting at 'lane'...
bool hasInfluencer() const
double getMinGap() const
Get the free space in front of vehicles of this class.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
MSLaneChanger()
Default constructor.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
bool isInternal() const
return whether this edge is an internal edge
void updateLanes(SUMOTime t)
std::vector< MSVehicle * > VehCont
Container for vehicles.
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
int checkChangeWithinEdge(int laneOffset, const std::pair< MSVehicle *const, double > &leader, const std::vector< MSVehicle::LaneQ > &preb) const
std::pair< MSVehicle *const, double > getRealFollower(const ChangerIt &target) 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
#define OPPOSITE_OVERTAKING_ONCOMING_LOOKAHEAD
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
#define OPPOSITE_OVERTAKING_SAFE_TIMEGAP
std::pair< const MSVehicle *, double > CLeaderDist
Influencer & getInfluencer()
Returns the velocity/lane influencer.
LaneChangeAction
The state of a vehicle's lane-change behavior.
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.
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
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...
virtual ~MSLaneChanger()
Destructor.
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
The vehicle is blocked being overlapping.
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
std::pair< MSVehicle *const, double > getCriticalLeader(double dist, double seen, double speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
double getLength() const
Get vehicle's length [m].
Changer myChanger
Container for ChangeElemements, one for every lane in the edge.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void registerUnchanged(MSVehicle *vehicle)
The vehicle does not have enough space to complete a continuous lane and change before the next turni...
bool unsafeLinkAhead(const MSLane *lane) const
whether the vehicle may safely move to the given lane with regard to upcoming links ...
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
bool isStopped() const
Returns whether the vehicle is at a stop.
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)
MSVehicle * hoppedVeh
last vehicle that changed into this lane
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
double getSpeed() const
Returns the vehicle's current speed.
The vehicle is blocked by right leader.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
public emergency vehicles
static SUMOTime gLaneChangeDuration
const std::string & getID() const
Returns the name of the vehicle.
Representation of a lane in the micro simulation.
double myBackPos
the stored back position
The vehicle is blocked by right follower.
bool mayChange(int direction) const
whether changing to the lane in the given direction should be considered
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
Interface for lane-change models.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
static const Position INVALID
used to indicate that a position is valid
double nextStopDist() const
return the distance to the next stop or doubleMax if there is none.
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)