60 ce->ahead = ce->lane->getPartialBeyond();
73 myCandi->ahead.addLeader(lead,
false, 0);
75 if (shadowLane != 0) {
78 (
myChanger.begin() + shadowLane->
getIndex())->ahead.addLeader(lead,
false, latOffset);
93 #ifdef DEBUG_VEHICLE_GUI_SELECTION 98 assert(vehicle->
getLane() == (*myCandi).lane);
111 for (
int i = 0; i < (int)
myChanger.size(); ++i) {
116 int sublaneIndex = 0;
119 sublaneIndex += ce->ahead.numSublanes();
159 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
161 result.
dir = laneOffset;
163 (
myCandi + laneOffset)->lastBlocked = vehicle;
164 if ((
myCandi + laneOffset)->firstBlocked == 0) {
165 (
myCandi + laneOffset)->firstBlocked = vehicle;
189 to = from + direction;
194 if (changedToNewLane) {
195 vehicle->
myState.
myPosLat -= direction * 0.5 * (from->lane->getWidth() + to->lane->getWidth());
196 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
203 to->ahead.addLeader(vehicle,
false, 0);
206 from->ahead.addLeader(vehicle,
false, 0);
212 if (shadowLane != 0 && shadowLane != oldShadowLane) {
215 (
myChanger.begin() + shadowLane->
getIndex())->ahead.addLeader(vehicle,
false, latOffset);
224 double changeAngle = 0;
231 <<
" latDist=" << latDist
234 <<
" laneA=" <<
RAD2DEG(laneAngle)
235 <<
" changeA=" <<
RAD2DEG(changeAngle)
237 <<
" newA=" <<
RAD2DEG(laneAngle + changeAngle)
239 vehicle->
setAngle(laneAngle + changeAngle);
241 return changedToNewLane;
252 std::cout <<
SIMTIME <<
" getLeaders lane=" << target->lane->getID() <<
" ego=" << ego->
getID() <<
" ahead=" << target->ahead.toString() <<
"\n";
255 for (
int i = 0; i < target->ahead.numSublanes(); ++i) {
268 for (
int i = 0; i < aheadSamePos.
numSublanes(); ++i) {
270 if (veh != 0 && veh != ego) {
273 std::cout <<
" further lead=" << veh->
getID() <<
" leadBack=" << veh->
getBackPositionOnLane(target->lane) <<
" gap=" << gap <<
"\n";
280 MSLane* targetLane = target->lane;
290 std::cout <<
" add consecutive before=" << result.
toString() <<
" dist=" << dist;
292 target->lane->getLeadersOnConsecutive(dist, seen, speed, ego, bestLaneConts, result);
294 std::cout <<
" after=" << result.
toString() <<
"\n";
305 const std::vector<MSVehicle::LaneQ>& preb,
306 double& latDist)
const {
310 const MSLane& neighLane = *(target->lane);
323 <<
" checkChangeSublane: veh=" << vehicle->
getID()
324 <<
" laneOffset=" << laneOffset
325 <<
"\n leaders=" << leaders.toString()
326 <<
"\n neighLeaders=" << neighLeaders.
toString()
327 <<
"\n followers=" << followers.
toString()
328 <<
"\n neighFollowers=" << neighFollowers.
toString()
333 laneOffset, alternatives,
334 leaders, followers, blockers,
335 neighLeaders, neighFollowers, neighBlockers,
337 &(
myCandi->lastBlocked), &(
myCandi->firstBlocked), latDist, blocked);
338 int state = blocked | wish;
348 const int oldstate = state;
bool gDebugFlag1
global utility flags for debugging
void setAngle(double angle)
Set a custom vehicle angle in rad.
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
double getMinGap() const
Get the free space in front of vehicles of this class.
saves leader/follower vehicles and their distances relative to an ego vehicle
double getWidth() const
Returns the lane's width.
Representation of a vehicle in the micro simulation.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
virtual int wantsChangeSublane(int laneOffset, LaneChangeAction alternatives, 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, double &latDist, int &blocked)
State myState
This Vehicles driving state (pos and speed)
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
void setLeaderGaps(CLeaderDist, double secGap)
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
virtual std::string toString() const
print a debugging representation
bool isStoppedOnLane() const
virtual void initChanger()
Initialize the changer before looping over all vehicles.
bool mayChange(int direction) const
whether changing to the lane in the given direction should be considered
double myPosLat
the stored lateral position
double interpolateLanePosToGeometryPos(double lanePos) const
double getLength() const
Returns the lane's length.
StateAndDist checkChangeHelper(MSVehicle *vehicle, int laneOffset, LaneChangeAction alternatives)
helper function that calls checkChangeSublane and sets blocker information
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
double getPositionOnLane() const
Get the vehicle's position along the lane.
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
double getAngle() const
Returns the vehicle's direction in radians.
virtual void updateChanger(bool vehHasChanged)
ChangerIt findCandidate()
Find current candidate. If there is none, myChanger.end() is returned.
MSAbstractLaneChangeModel & getLaneChangeModel()
std::string gDebugSelectedVehicle
void saveState(const int dir, const int stateWithoutTraCI, const int state)
void setFollowerGaps(CLeaderDist follower, double secGap)
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
Performs lane changing of vehicles.
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
int numFreeSublanes() const
void setSpeedLat(double speedLat)
MSLaneChangerSublane()
Default constructor.
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)
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 best sequence of lanes to continue the route starting at myLane.
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
bool startChangeSublane(MSVehicle *vehicle, ChangerIt &from, double latDist)
change by the specified amount and return whether a new lane was entered
virtual StateAndDist decideDirection(StateAndDist sd1, StateAndDist sd2) const
decide in which direction to move in case both directions are desirable
virtual void initChanger()
Initialize the changer before looping over all vehicles.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
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
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double getLength() const
Get vehicle's length [m].
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.
static bool haveLCOutput()
whether lanechange-output is active
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
MSAbstractLaneChangeModel::StateAndDist StateAndDist
const PositionVector & getShape() const
Returns this lane's shape.
Changer myChanger
Container for ChangeElemements, one for every lane in the edge.
double getRightSideOnEdge() const
void registerUnchanged(MSVehicle *vehicle)
MSLane * getLane() const
Returns the lane the vehicle is on.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
int checkChangeSublane(int laneOffset, LaneChangeAction alternatives, const std::vector< MSVehicle::LaneQ > &preb, double &latDist) const
check whether sub-lane changing in the given direction is desirable and possible
Representation of a lane in the micro simulation.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
static const Position INVALID
used to indicate that a position is valid
const std::string & getID() const
Returns the name of the vehicle.
double getSpeed() const
Returns the vehicle's current speed.