62 myCandi->ahead.addLeader(lead,
false, 0);
64 if (shadowLane != 0) {
67 (
myChanger.begin() + shadowLane->
getIndex())->ahead.addLeader(lead,
false, latOffset);
82 #ifdef DEBUG_VEHICLE_GUI_SELECTION 87 assert(vehicle->
getLane() == (*myCandi).lane);
95 for (
int i = 0; i < (int)
myChanger.size(); ++i) {
100 int sublaneIndex = 0;
103 sublaneIndex += ce->ahead.numSublanes();
137 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
139 result.
dir = laneOffset;
141 (
myCandi + laneOffset)->lastBlocked = vehicle;
142 if ((
myCandi + laneOffset)->firstBlocked == 0) {
143 (
myCandi + laneOffset)->firstBlocked = vehicle;
166 to = from + direction;
171 if (changedToNewLane) {
172 vehicle->
myState.
myPosLat -= direction * 0.5 * (from->lane->getWidth() + to->lane->getWidth());
173 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
176 to->ahead.addLeader(vehicle,
false, 0);
179 from->ahead.addLeader(vehicle,
false, 0);
185 if (shadowLane != 0 && shadowLane != oldShadowLane) {
188 (
myChanger.begin() + shadowLane->
getIndex())->ahead.addLeader(vehicle,
false, latOffset);
197 double changeAngle = 0;
204 <<
" latDist=" << latDist
207 <<
" laneA=" <<
RAD2DEG(laneAngle)
208 <<
" changeA=" <<
RAD2DEG(changeAngle)
210 <<
" newA=" <<
RAD2DEG(laneAngle + changeAngle)
212 vehicle->
setAngle(laneAngle + changeAngle);
214 return changedToNewLane;
225 std::cout <<
SIMTIME <<
" getLeaders lane=" << target->lane->getID() <<
" ego=" << ego->
getID() <<
" ahead=" << target->ahead.toString() <<
"\n";
228 for (
int i = 0; i < target->ahead.numSublanes(); ++i) {
242 for (
int i = 0; i < aheadSamePos.
numSublanes(); ++i) {
244 if (veh != 0 && veh != ego) {
247 std::cout <<
" further lead=" << veh->
getID() <<
" leadBack=" << veh->
getBackPositionOnLane(target->lane) <<
" gap=" << gap <<
"\n";
254 MSLane* targetLane = target->lane;
263 target->lane->getLeadersOnConsecutive(dist, seen, speed, ego, bestLaneConts, result);
272 const std::vector<MSVehicle::LaneQ>& preb,
273 double& latDist)
const {
277 const MSLane& neighLane = *(target->lane);
290 <<
" checkChangeSublane: veh=" << vehicle->
getID()
291 <<
" laneOffset=" << laneOffset
292 <<
"\n leaders=" << leaders.toString()
293 <<
"\n neighLeaders=" << neighLeaders.
toString()
299 leaders, followers, blockers,
300 neighLeaders, neighFollowers, neighBlockers,
302 &(
myCandi->lastBlocked), &(
myCandi->firstBlocked), latDist, blocked);
303 int state = blocked | wish;
313 const int oldstate = state;
bool gDebugFlag1
global utility flags for debugging
void setAngle(double angle)
Set a custom vehicle angle in rad.
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].
StateAndDist checkChangeHelper(MSVehicle *vehicle, int laneOffset)
helper function that calls checkChangeSublane and sets blocker information
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time, assuming that during...
saves leader/follower vehicles and their distances relative to an ego vehicle
Representation of a vehicle in the micro simulation.
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
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, double &latDist, int &blocked)
double getAngle() const
Returns the vehicle's direction in radians.
State myState
This Vehicles driving state (pos and speed)
virtual std::string toString() const
print a debugging representation
MSLane * getLane() const
Returns the lane the vehicle is on.
double getPositionOnLane() const
Get the vehicle's position along the lane.
double myPosLat
the stored lateral position
MSVehicle * veh(ConstChangerIt ce) const
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
virtual StateAndDist decideDirection(StateAndDist sd1, StateAndDist sd2) const
decide in which direction to move in case both directions are desirable
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
double getWidth() const
Returns the lane's width.
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)
Performs lane changing of vehicles.
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
int getIndex() const
Returns the lane's index.
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)
int checkChangeSublane(int laneOffset, const std::vector< MSVehicle::LaneQ > &preb, double &latDist) const
check whether sub-lane changing in the given direction is desirable and possible
virtual void updateExpectedSublaneSpeeds(const MSLeaderInfo &ahead, int sublaneOffset, int laneIndex)
update expected speeds for each sublane of the current edge
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.
Position myCachedPosition
bool startChangeSublane(MSVehicle *vehicle, ChangerIt &from, double latDist)
change by the specified amount and return whether a new lane was entered
double getMinGap() const
Get the free space in front of vehicles of this class.
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
~MSLaneChangerSublane()
Destructor.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getRightSideOnEdge() const
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
MSLeaderDistanceInfo getLeaders(const ChangerIt &target, const MSVehicle *ego) const
get leaders for ego on the given lane
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.
double interpolateLanePosToGeometryPos(double lanePos) const
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
double getLength() const
Get vehicle's length [m].
MSAbstractLaneChangeModel::StateAndDist StateAndDist
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)
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
int numFreeSublanes() const
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.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
const std::string & getID() const
Returns the name of the vehicle.
Representation of a lane in the micro simulation.
bool mayChange(int direction) const
whether changing to the lane in the given direction should be considered
static const Position INVALID
used to indicate that a position is valid