43 #ifdef CHECK_MEMORY_LEAKS 45 #endif // CHECK_MEMORY_LEAKS 65 myCandi->ahead.addLeader(lead,
false, 0);
67 if (shadowLane != 0) {
70 (
myChanger.begin() + shadowLane->
getIndex())->ahead.addLeader(lead,
false, latOffset);
85 #ifdef DEBUG_VEHICLE_GUI_SELECTION 90 assert(vehicle->
getLane() == (*myCandi).lane);
98 for (
int i = 0; i < (int)
myChanger.size(); ++i) {
103 int sublaneIndex = 0;
106 sublaneIndex += ce->ahead.numSublanes();
140 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
142 result.
dir = laneOffset;
144 (
myCandi + laneOffset)->lastBlocked = vehicle;
145 if ((
myCandi + laneOffset)->firstBlocked == 0) {
146 (
myCandi + laneOffset)->firstBlocked = vehicle;
170 to = from + direction;
175 if (changedToNewLane) {
176 vehicle->
myState.
myPosLat -= direction * 0.5 * (from->lane->getWidth() + to->lane->getWidth());
177 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
180 to->ahead.addLeader(vehicle,
false, 0);
183 from->ahead.addLeader(vehicle,
false, 0);
189 if (shadowLane != 0 && shadowLane != oldShadowLane) {
192 (
myChanger.begin() + shadowLane->
getIndex())->ahead.addLeader(vehicle,
false, latOffset);
197 return changedToNewLane;
208 std::cout <<
SIMTIME <<
" getLeaders lane=" << target->lane->getID() <<
" ego=" << ego->
getID() <<
" ahead=" << target->ahead.toString() <<
"\n";
211 for (
int i = 0; i < target->ahead.numSublanes(); ++i) {
225 for (
int i = 0; i < aheadSamePos.
numSublanes(); ++i) {
227 if (veh != 0 && veh != ego) {
230 std::cout <<
" further lead=" << veh->
getID() <<
" leadBack=" << veh->
getBackPositionOnLane(target->lane) <<
" gap=" << gap <<
"\n";
237 MSLane* targetLane = target->lane;
246 target->lane->getLeadersOnConsecutive(dist, seen, speed, ego, bestLaneConts, result);
255 const std::vector<MSVehicle::LaneQ>& preb,
260 const MSLane& neighLane = *(target->lane);
273 <<
" checkChangeSublane: veh=" << vehicle->
getID()
274 <<
" laneOffset=" << laneOffset
275 <<
"\n leaders=" << leaders.toString()
276 <<
"\n neighLeaders=" << neighLeaders.
toString()
282 leaders, followers, blockers,
283 neighLeaders, neighFollowers, neighBlockers,
285 &(
myCandi->lastBlocked), &(
myCandi->firstBlocked), latDist, blocked);
286 int state = blocked | wish;
bool gDebugFlag1
global utility flags for debugging
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
StateAndDist checkChangeHelper(MSVehicle *vehicle, int laneOffset)
helper function that calls checkChangeSublane and sets blocker information
saves leader/follower vehicles and their distances relative to an ego vehicle
Representation of a vehicle in the micro simulation.
bool startChangeSublane(MSVehicle *vehicle, ChangerIt &from, SUMOReal latDist)
change by the specified amount and return whether a new lane was entered
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
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
virtual std::string toString() const
print a debugging representation
SUMOReal getLength() const
Returns the lane's length.
bool mayChange(int direction) const
whether changing to the lane in the given direction should be considered
SUMOReal getWidth() const
Returns the lane's width.
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
int checkChangeSublane(int laneOffset, const std::vector< MSVehicle::LaneQ > &preb, SUMOReal &latDist) const
check whether sub-lane changing in the given direction is desirable and possible
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
virtual void updateChanger(bool vehHasChanged)
ChangerIt findCandidate()
Find current candidate. If there is none, myChanger.end() is returned.
MSAbstractLaneChangeModel & getLaneChangeModel()
std::string gDebugSelectedVehicle
SUMOReal getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
virtual int wantsChangeSublane(int laneOffset, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked, SUMOReal &latDist, int &blocked)
Performs lane changing of vehicles.
int numFreeSublanes() const
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time.
MSLaneChangerSublane()
Default constructor.
virtual void updateChanger(bool vehHasChanged)
The action is urgent (to be defined by lc-model)
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
virtual void updateExpectedSublaneSpeeds(const MSLeaderInfo &ahead, int sublaneOffset, int laneIndex)
update expected speeds for each sublane of the current edge
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle's current lane and their successors...
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Position myCachedPosition
MSLeaderDistanceInfo getLeaders(const ChangerIt &target, const MSVehicle *ego) const
get leaders for ego on the given lane
virtual StateAndDist decideDirection(StateAndDist sd1, StateAndDist sd2) const
decide in which direction to move in case both directions are desirable
virtual void setOwnState(int state)
virtual int addLeader(const MSVehicle *veh, SUMOReal gap, SUMOReal latOffset=0, int sublane=-1)
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
int getIndex() const
Returns the lane's index.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
~MSLaneChangerSublane()
Destructor.
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
LaneChangeAction
The state of a vehicle's lane-change behavior.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
SUMOReal getSpeed() const
Returns the vehicle's current speed.
SUMOReal getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
MSAbstractLaneChangeModel::StateAndDist StateAndDist
Changer myChanger
Container for ChangeElemements, one for every lane in the edge.
void registerUnchanged(MSVehicle *vehicle)
SUMOReal myPosLat
the stored lateral position
void adaptBestLanesOccupation(int laneIndex, SUMOReal density)
update occupation from MSLaneChanger
MSLane * getLane() const
Returns the lane the vehicle is on.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
Representation of a lane in the micro simulation.
static const Position INVALID
SUMOReal getRightSideOnEdge() const
const std::string & getID() const
Returns the name of the vehicle.