48 #ifdef CHECK_MEMORY_LEAKS 50 #endif // CHECK_MEMORY_LEAKS 52 #define OPPOSITE_OVERTAKING_SAFE_TIMEGAP 0.0 54 #define OPPOSITE_OVERTAKING_MAX_LOOKAHEAD 150.0 // just a guess 56 #define OPPOSITE_OVERTAKING_ONCOMING_LOOKAHEAD 200.0 // just a guess 68 #define DEBUG_COND false 93 for (std::vector<MSLane*>::const_iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
112 const bool haveChanged =
change();
119 ce->lane->releaseVehicles();
133 ce->firstBlocked = 0;
136 ce->lane->getVehiclesSecure();
174 ce->lane->swapAfterLaneChange(t);
175 ce->lane->releaseVehicles();
194 assert(
veh(ce) != 0);
195 assert(
veh(max) != 0);
196 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
202 assert(
veh(max) != 0);
209 if (direction == 0) {
215 if (direction == -1) {
217 }
else if (direction == 1) {
237 #ifdef DEBUG_VEHICLE_GUI_SELECTION 264 for (
int i = 0; i < (int)
myChanger.size(); ++i) {
267 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
272 bool changingAllowed1 = (state1 &
LCA_BLOCKED) == 0;
274 if ((state1 &
LCA_RIGHT) != 0 && changingAllowed1) {
279 if ((state1 & LCA_RIGHT) != 0 && (state1 &
LCA_URGENT) != 0) {
280 (
myCandi - 1)->lastBlocked = vehicle;
281 if ((
myCandi - 1)->firstBlocked == 0) {
282 (
myCandi - 1)->firstBlocked = vehicle;
293 bool changingAllowed2 = (state2 &
LCA_BLOCKED) == 0;
295 if ((state2 &
LCA_LEFT) != 0 && changingAllowed2) {
300 if ((state2 & LCA_LEFT) != 0 && (state2 &
LCA_URGENT) != 0) {
301 (
myCandi + 1)->lastBlocked = vehicle;
302 if ((
myCandi + 1)->firstBlocked == 0) {
303 (
myCandi + 1)->firstBlocked = vehicle;
345 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
347 to->hoppedVeh = vehicle;
362 MSLane* target = to->lane;
365 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
367 to->hoppedVeh = vehicle;
369 from->lane->myTmpVehicles.insert(from->lane->myTmpVehicles.begin(), vehicle);
371 from->hoppedVeh = vehicle;
381 shadow->hoppedVeh = vehicle;
385 #ifdef DEBUG_CONTINUE_CHANGE 388 <<
" continueChange veh=" << vehicle->
getID()
390 <<
" dir=" << direction
391 <<
" pastMidpoint=" << pastMidpoint
403 std::pair<MSVehicle* const, SUMOReal>
407 #ifdef DEBUG_SURROUNDING_VEHICLES 410 std::cout <<
SIMTIME <<
" veh '" << vehicle->
getID() <<
"' looks for leader on lc-target lane '" << target->lane->getID() <<
"'." << std::endl;
416 #ifdef DEBUG_SURROUNDING_VEHICLES 418 if (neighLead != 0) {
419 std::cout <<
"Considering '" << neighLead->
getID() <<
"' at position " << neighLead->
getPositionOnLane() << std::endl;
430 if (target->hoppedVeh != 0) {
431 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
432 #ifdef DEBUG_SURROUNDING_VEHICLES 434 std::cout <<
"Considering hopped vehicle '" << target->hoppedVeh->getID() <<
"' at position " << hoppedPos << std::endl;
438 neighLead = target->hoppedVeh;
442 if (neighLead == 0) {
443 #ifdef DEBUG_SURROUNDING_VEHICLES 445 std::cout <<
"Looking for leader on consecutive lanes." << std::endl;
449 MSLane* targetLane = target->lane;
452 std::vector<MSVehicle*>::const_iterator i = targetLane->
myPartialVehicles.begin();
467 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
470 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
478 std::pair<MSVehicle* const, SUMOReal>
482 #ifdef DEBUG_SURROUNDING_VEHICLES 485 std::cout <<
SIMTIME <<
" veh '" << vehicle->
getID() <<
"' looks for follower on lc-target lane '" << target->lane->getID() <<
"'." << std::endl;
492 #ifdef DEBUG_SURROUNDING_VEHICLES 494 if (neighFollow != 0) {
495 std::cout <<
"veh(target) returns '" << neighFollow->
getID() <<
"' at position " << neighFollow->
getPositionOnLane() << std::endl;
497 std::cout <<
"veh(target) returns none." << std::endl;
503 #ifdef DEBUG_SURROUNDING_VEHICLES 505 if (
getCloserFollower(candiPos, neighFollow, target->hoppedVeh) != neighFollow) {
506 std::cout <<
"Hopped vehicle '" << target->hoppedVeh->getID() <<
"' at position " << target->hoppedVeh->getPositionOnLane() <<
" is closer." << std::endl;
515 #ifdef DEBUG_SURROUNDING_VEHICLES 518 if (partialBehind != 0 && partialBehind != neighFollow) {
519 std::cout <<
"'Partial behind'-vehicle '" << target->lane->getPartialBehind(candi)->
getID() <<
"' at position " << target->hoppedVeh->getPositionOnLane() <<
" is closer." << std::endl;
524 neighFollow =
getCloserFollower(candiPos, neighFollow, target->lane->getPartialBehind(candi));
526 if (neighFollow == 0) {
527 std::pair<MSVehicle* const, SUMOReal> consecutiveFollower = target->lane->getFollowerOnConsecutive(
530 #ifdef DEBUG_SURROUNDING_VEHICLES 532 if (consecutiveFollower.first == 0) {
533 std::cout <<
"no follower found." << std::endl;
535 std::cout <<
"found follower '" << consecutiveFollower.first->
getID() <<
"' on consecutive lanes." << std::endl;
539 return consecutiveFollower;
541 #ifdef DEBUG_SURROUNDING_VEHICLES 543 std::cout <<
"found follower '" << neighFollow->
getID() <<
"'." << std::endl;
547 return std::pair<MSVehicle* const, SUMOReal>(neighFollow,
571 const std::pair<MSVehicle* const, SUMOReal>& leader,
572 const std::vector<MSVehicle::LaneQ>& preb)
const {
576 if (neighLead.first != 0 && neighLead.first == neighFollow.first) {
579 neighFollow.first = 0;
582 return checkChange(laneOffset, target->lane, leader, neighLead, neighFollow, preb);
589 const std::pair<MSVehicle* const, SUMOReal>& leader,
590 const std::pair<MSVehicle* const, SUMOReal>& neighLead,
591 const std::pair<MSVehicle* const, SUMOReal>& neighFollow,
592 const std::vector<MSVehicle::LaneQ>& preb)
const {
597 #ifdef DEBUG_CHECK_CHANGE 600 <<
"\n" <<
SIMTIME <<
" checkChange() for vehicle '" << vehicle->
getID() <<
"'" 610 if (neighFollow.first != 0 && neighFollow.second < 0) {
614 #ifdef DEBUG_CHECK_CHANGE 617 <<
" overlapping with follower..." 623 if (neighLead.first != 0 && neighLead.second < 0) {
627 #ifdef DEBUG_CHECK_CHANGE 630 <<
" overlapping with leader..." 638 if ((blocked & blockedByFollower) == 0 && neighFollow.first != 0) {
641 blocked |= blockedByFollower;
644 #ifdef DEBUG_CHECK_CHANGE 647 <<
" back gap unsafe: " 648 <<
"gap = " << neighFollow.second
650 << neighFollow.first->getCarFollowModel().getSecureGap(neighFollow.first->getSpeed(),
660 if ((blocked & blockedByLeader) == 0 && neighLead.first != 0) {
663 blocked |= blockedByLeader;
666 #ifdef DEBUG_CHECK_CHANGE 669 <<
" front gap unsafe: " 670 <<
"gap = " << neighLead.second
673 neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())
684 laneOffset, msg, blocked, leader, neighLead, neighFollow, *targetLane, preb, &(
myCandi->lastBlocked), &(
myCandi->firstBlocked));
693 std::pair<MSVehicle* const, SUMOReal> neighLead2 = targetLane->
getCriticalLeader(dist, seen, speed, *vehicle);
694 if (neighLead2.first != 0 && neighLead2.first != neighLead.first
696 vehicle->
getSpeed(), neighLead2.first->getSpeed(), neighLead2.first->getCarFollowModel().getMaxDecel()))) {
697 state |= blockedByLeader;
701 if (blocked == 0 && (state & LCA_WANTS_LANECHANGE)) {
704 state |= blockedByLeader;
721 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*vehicle, view, *nextLane, bestLaneConts);
722 while (!nextLane->
isLinkEnd(link) && seen <= space2change) {
726 || (nextLane->
getEdge().
isInternal() && (*link)->getViaLaneOrLane()->getEdge().isInternal())
731 #ifdef HAVE_INTERNAL_LANES 732 if ((*link)->getViaLane() == 0) {
738 nextLane = (*link)->getViaLaneOrLane();
743 if (nextLane->
isLinkEnd(link) && seen < space2change) {
744 #ifdef DEBUG_CHECK_CHANGE 746 std::cout <<
SIMTIME <<
" checkChange insufficientSpace: seen=" << seen <<
" space2change=" << space2change <<
"\n";
752 if ((state & LCA_BLOCKED) == 0) {
760 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*vehicle, view, *nextLane, bestLaneConts);
761 while (!nextLane->
isLinkEnd(link) && seen <= space2change && seen <= dist) {
762 nextLane = (*link)->getViaLaneOrLane();
764 if (targetLane == 0) {
768 std::pair<MSVehicle* const, SUMOReal> neighLead2 = targetLane->
getLeader(vehicle, -seen, std::vector<MSLane*>());
769 if (neighLead2.first != 0 && neighLead2.first != neighLead.first
771 vehicle->
getSpeed(), neighLead2.first->getSpeed(), neighLead2.first->getCarFollowModel().getMaxDecel()))) {
772 state |= blockedByLeader;
776 #ifdef HAVE_INTERNAL_LANES 777 if ((*link)->getViaLane() == 0) {
790 #ifdef DEBUG_CHECK_CHANGE 791 const int oldstate = state;
796 #ifdef DEBUG_CHECK_CHANGE 799 <<
" veh=" << vehicle->
getID()
825 if (!isOpposite && leader.first == 0) {
837 int direction = isOpposite ? -1 : 1;
838 std::pair<MSVehicle*, SUMOReal> neighLead((
MSVehicle*)0, -1);
844 assert(leader.first != 0);
848 std::pair<MSVehicle*, SUMOReal> columnLeader = leader;
850 bool foundSpaceAhead =
false;
851 SUMOReal seen = leader.second + leader.first->getVehicleType().getLengthWithGap();
853 while (!foundSpaceAhead) {
854 const SUMOReal requiredSpaceAfterLeader = (columnLeader.first->getCarFollowModel().getSecureGap(
860 const bool checkTmpVehicles = (&columnLeader.first->getLane()->getEdge() == &source->
getEdge());
861 std::pair<MSVehicle* const, SUMOReal> leadLead = columnLeader.first->getLane()->getLeader(
862 columnLeader.first, columnLeader.first->getPositionOnLane(), conts, requiredSpaceAfterLeader + mergeBrakeGap,
865 #ifdef DEBUG_CHANGE_OPPOSITE 867 std::cout <<
" leadLead=" <<
Named::getIDSecure(leadLead.first) <<
" gap=" << leadLead.second <<
"\n";
870 if (leadLead.first == 0) {
871 foundSpaceAhead =
true;
873 const SUMOReal requiredSpace = (requiredSpaceAfterLeader
874 + vehicle->
getCarFollowModel().
getSecureGap(overtakingSpeed, leadLead.first->getSpeed(), leadLead.first->getCarFollowModel().getMaxDecel()));
875 if (leadLead.second > requiredSpace) {
876 foundSpaceAhead =
true;
878 #ifdef DEBUG_CHANGE_OPPOSITE 880 std::cout <<
" not enough space after columnLeader=" << columnLeader.first->getID() <<
" required=" << requiredSpace <<
"\n";
883 seen +=
MAX2((
SUMOReal)0, leadLead.second) + leadLead.first->getVehicleType().getLengthWithGap();
885 #ifdef DEBUG_CHANGE_OPPOSITE 887 std::cout <<
" cannot changeOpposite due to insufficient free space after columnLeader (seen=" << seen <<
" columnLeader=" << columnLeader.first->getID() <<
")\n";
893 egoGap += columnLeader.first->getVehicleType().getLengthWithGap() + leadLead.second;
894 columnLeader = leadLead;
895 #ifdef DEBUG_CHANGE_OPPOSITE 897 std::cout <<
" new columnLeader=" << columnLeader.first->getID() <<
"\n";
903 #ifdef DEBUG_CHANGE_OPPOSITE 905 std::cout <<
" compute time/space to overtake for columnLeader=" << columnLeader.first->getID() <<
" gap=" << columnLeader.second <<
"\n";
911 #ifdef DEBUG_CHANGE_OPPOSITE 913 std::cout <<
" cannot changeOpposite due to upcoming stop (dist=" << vehicle->
nextStopDist() <<
" spaceToOvertake=" << spaceToOvertake <<
")\n";
920 #ifdef DEBUG_CHANGE_OPPOSITE 923 <<
" veh=" << vehicle->
getID()
924 <<
" changeOpposite opposite=" << opposite->
getID()
926 <<
" timeToOvertake=" << timeToOvertake
927 <<
" spaceToOvertake=" << spaceToOvertake
933 if (neighLead.first != 0) {
934 const MSVehicle* oncoming = neighLead.first;
936 #ifdef DEBUG_CHANGE_OPPOSITE 939 <<
" oncoming=" << oncoming->
getID()
940 <<
" oncomingGap=" << neighLead.second
941 <<
" leaderGap=" << leader.second
945 if (neighLead.second - spaceToOvertake - timeToOvertake * oncoming->
getSpeed() < 0) {
947 #ifdef DEBUG_CHANGE_OPPOSITE 949 std::cout <<
" cannot changeOpposite due to dangerous oncoming\n";
967 if (usableDist < spaceToOvertake) {
970 assert(bestLaneConts.size() >= 1);
971 std::vector<MSLane*>::const_iterator it = bestLaneConts.begin() + 1;
972 while (usableDist < spaceToOvertake && it != bestLaneConts.end()) {
973 #ifdef DEBUG_CHANGE_OPPOSITE 975 std::cout <<
" usableDist=" << usableDist <<
" opposite=" <<
Named::getIDSecure((*it)->getOpposite()) <<
"\n";
978 if ((*it)->getOpposite() == 0) {
983 if (*(it - 1) != 0) {
989 usableDist += (*it)->getLength();
993 if (!isOpposite && usableDist < spaceToOvertake) {
994 #ifdef DEBUG_CHANGE_OPPOSITE 996 std::cout <<
" cannot changeOpposite due to insufficient space (seen=" << usableDist <<
" spaceToOvertake=" << spaceToOvertake <<
")\n";
1001 #ifdef DEBUG_CHANGE_OPPOSITE 1003 std::cout <<
" usableDist=" << usableDist <<
" spaceToOvertake=" << spaceToOvertake <<
" timeToOvertake=" << timeToOvertake <<
"\n";
1008 std::vector<MSVehicle::LaneQ> preb = vehicle->
getBestLanes();
1023 if (leader.first != 0) {
1025 #ifdef DEBUG_CHANGE_OPPOSITE 1027 std::cout <<
SIMTIME <<
" found oncoming leader=" << leader.first->getID() <<
" gap=" << leader.second <<
"\n";
1032 #ifdef DEBUG_CHANGE_OPPOSITE 1034 std::cout <<
SIMTIME <<
" veh=" << vehicle->
getID() <<
" remaining dist=" << laneQ.
length - forwardPos <<
" forwardPos=" << forwardPos <<
" laneQ.length=" << laneQ.
length <<
"\n";
1038 std::pair<MSVehicle* const, SUMOReal> neighFollow = opposite->
getOppositeFollower(vehicle);
1039 int state =
checkChange(direction, opposite, leader, neighLead, neighFollow, preb);
1041 bool changingAllowed = (state &
LCA_BLOCKED) == 0;
1054 #ifdef DEBUG_CHANGE_OPPOSITE 1056 std::cout <<
SIMTIME <<
" changing to opposite veh=" << vehicle->
getID() <<
" dir=" << direction <<
" opposite=" <<
Named::getIDSecure(opposite) <<
" state=" << state <<
"\n";
1061 #ifdef DEBUG_CHANGE_OPPOSITE 1063 std::cout <<
SIMTIME <<
" not changing to opposite veh=" << vehicle->
getID() <<
" dir=" << direction
1098 SUMOReal t = (u - v - sqrt(4 * (u - v) * (u - v) + 8 * a * g) * sign * 0.5) / a;
1103 t = ceil(t /
TS) *
TS;
1106 const SUMOReal timeToMaxSpeed = (vMax - v) / a;
1108 if (t <= timeToMaxSpeed) {
1110 spaceToOvertake = v * t + t * t * a * 0.5;
1114 const SUMOReal s = v * timeToMaxSpeed + timeToMaxSpeed * timeToMaxSpeed * a * 0.5;
1118 t = (g - s + m * vMax) / (vMax - u);
1123 t = ceil(t /
TS) *
TS;
1126 spaceToOvertake = s + (t - m) * vMax;
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
The action is done to help someone else.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
State myState
This Vehicles driving state (pos and speed)
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
std::pair< MSVehicle *const, SUMOReal > getRealLeader(const ChangerIt &target) const
std::pair< MSVehicle *const, SUMOReal > getOppositeFollower(const MSVehicle *ego) const
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
The vehicle is blocked by left follower.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
bool alreadyChanged() const
reset the flag whether a vehicle already moved to false
bool unsafeLinkAhead(const MSLane *lane) const
whether the vehicle may safely move to the given lane with regard to upcoming links ...
bool continueChange(MSVehicle *vehicle, ChangerIt &from)
continue a lane change maneuver and return whether the midpoint was passed in this step (used if gLan...
void initChanger()
Initialize the changer before looping over all vehicles.
SUMOReal getLength() const
Returns the lane's length.
int checkChangeWithinEdge(int laneOffset, const std::pair< MSVehicle *const, SUMOReal > &leader, const std::vector< MSVehicle::LaneQ > &preb) const
bool mayChange(int direction) const
whether changing to the lane in the given direction should be considered
int getShadowDirection() const
return the direction in which the current shadow lane lies
SUMOReal getLength() const
Get vehicle's length [m].
const bool myChangeToOpposite
whether this edge allows changing to the opposite direction edge
virtual int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, SUMOReal > &leader, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &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...
SUMOReal getWidth() const
Returns the lane's width.
#define OPPOSITE_OVERTAKING_MAX_LOOKAHEAD
MSVehicle * veh(ConstChangerIt ce) const
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
void startChange(MSVehicle *vehicle, ChangerIt &from, int direction)
start the lane change maneuver (and finish it instantly if gLaneChangeDuration == 0) ...
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
std::pair< MSVehicle *const, SUMOReal > getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
ChangeElem(MSLane *_lane)
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
SUMOReal length
The overall length which may be driven when using this lane without a lane change.
static void computeOvertakingTime(const MSVehicle *vehicle, const MSVehicle *leader, SUMOReal gap, SUMOReal &timeToOvertake, SUMOReal &spaceToOvertake)
Compute the time and space required for overtaking the given leader.
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.
static MSVehicle * getCloserFollower(const SUMOReal maxPos, MSVehicle *follow1, MSVehicle *follow2)
return the closer follower of ego
MSAbstractLaneChangeModel & getLaneChangeModel()
std::string gDebugSelectedVehicle
SUMOReal getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
The link is a straight direction.
A class responsible for exchanging messages between cars involved in lane-change interaction.
const std::string & getID() const
Returns the id.
The vehicle changes lanes (micro only) XXX: What if a vehicle changes lanes and passes a junction sim...
std::pair< MSVehicle *const, SUMOReal > getRealFollower(const ChangerIt &target) const
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time, assuming that during...
SUMOReal computeAngle() const
compute the current vehicle angle
virtual void updateChanger(bool vehHasChanged)
blocked in all directions
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The action is urgent (to be defined by lc-model)
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
SUMOReal getLateralSpeed() const
return the lateral speed of the current lane change maneuver
SUMOReal myAngle
the angle in radians (
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Position myCachedPosition
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 changeOpposite(std::pair< MSVehicle *, SUMOReal > leader)
bool isStopped() const
Returns whether the vehicle is at a stop.
The link is a (hard) right direction.
virtual void setOwnState(int state)
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
A structure representing the best lanes for continuing the current route starting at 'lane'...
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
MSLaneChanger()
Default constructor.
int checkChange(int laneOffset, const MSLane *targetLane, const std::pair< MSVehicle *const, SUMOReal > &leader, const std::pair< MSVehicle *const, SUMOReal > &neighLead, const std::pair< MSVehicle *const, SUMOReal > &neighFollow, const std::vector< MSVehicle::LaneQ > &preb) const
bool isInternal() const
return whether this edge is an internal edge
void updateLanes(SUMOTime t)
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
SUMOReal getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
#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
LaneChangeAction
The state of a vehicle's lane-change behavior.
bool havePriority() const
Returns whether this link is a major link.
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.
The vehicle is blocked being overlapping.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
std::pair< MSVehicle *const, SUMOReal > getOppositeLeader(const MSVehicle *ego, SUMOReal dist, bool oppositeDir) const
SUMOReal getSpeed() const
Returns the vehicle's current speed.
SUMOReal myPos
the stored position
SUMOReal getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
SUMOReal nextStopDist() const
return the distance to the next stop or SUMORealMax if there is none.
Changer myChanger
Container for ChangeElemements, one for every lane in the edge.
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
LinkState getState() const
Returns the current state of the link.
void registerUnchanged(MSVehicle *vehicle)
SUMOReal myPosLat
the stored lateral position
The vehicle does not have enough space to complete a continuous lane and change before the next turni...
void adaptBestLanesOccupation(int laneIndex, SUMOReal density)
update occupation from MSLaneChanger
SUMOReal myBackPos
the stored back position
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
The vehicle is blocked by right leader.
MSLane * getLane() const
Returns the lane the vehicle is on.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
bool vehInChanger() const
Check if there is a single change-candidate in the changer. Returns true if there is one...
public emergency vehicles
static SUMOTime gLaneChangeDuration
Representation of a lane in the micro simulation.
The vehicle is blocked by right follower.
Interface for lane-change models.
std::pair< MSVehicle *const, SUMOReal > getLeader(const MSVehicle *veh, const SUMOReal vehPos, const std::vector< MSLane * > &bestLaneConts, SUMOReal dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
static const Position INVALID
used to indicate that a position is valid
int getLaneChangeDirection() const
return the direction of the current lane change maneuver
const std::string & getID() const
Returns the name of the vehicle.
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)