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 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.
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
double getWidth() const
Returns the lane's width.
Representation of a vehicle in the micro simulation.
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)
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
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
virtual std::string toString() const
print a debugging representation
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.
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
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
void saveState(const int dir, const int stateWithoutTraCI, const int state)
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
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
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.
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
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, assuming that during...
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.