42 myWidth(lane->getWidth()),
44 myFreeSublanes((int)myVehicles.size()),
47 myHasVehicles(false) {
75 int rightmost, leftmost;
78 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
114 double rightVehSide =
MAX2(0., vehCenter - vehHalfWidth);
115 double leftVehSide =
MIN2(
myWidth, vehCenter + vehHalfWidth);
120 rightVehSide -= maneuverDist;
124 leftVehSide += maneuverDist;
145 assert(sublane >= 0);
148 rightSide = sublane * res + latOffset;
149 leftSide =
MIN2((sublane + 1) * res,
myWidth) + latOffset;
155 assert(sublane >= 0);
163 std::ostringstream oss;
164 oss.setf(std::ios::fixed, std::ios::floatfield);
165 oss << std::setprecision(2);
166 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
182 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
197 myDistances(myVehicles.size(), std::numeric_limits<double>::max()) {
203 myDistances(1, cLeaderDist.second) {
217 if (veh ==
nullptr) {
224 if (sublane >= 0 && sublane < (
int)
myVehicles.size()) {
236 int rightmost, leftmost;
238 for (
int sublaneIdx = rightmost; sublaneIdx <= leftmost; ++sublaneIdx) {
262 assert(sublane >= 0);
270 std::ostringstream oss;
271 oss.setf(std::ios::fixed, std::ios::floatfield);
272 oss << std::setprecision(2);
273 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
296 myMissingGaps(myVehicles.size(), -std::numeric_limits<double>::max()) {
305 if (veh ==
nullptr) {
309 const double missingGap = requiredGap - gap;
334 if (sublane >= 0 && sublane < (
int)
myVehicles.size()) {
354 int rightmost, leftmost;
356 for (
int sublaneIdx = rightmost; sublaneIdx <= leftmost; ++sublaneIdx) {
361 || (missingGap > 0 && gap <
myDistances[sublaneIdx])
388 std::ostringstream oss;
389 oss.setf(std::ios::fixed, std::ios::floatfield);
390 oss << std::setprecision(2);
391 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
std::pair< const MSVehicle *, double > CLeaderDist
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual double getSecureGap(const MSVehicle *const, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
MSCriticalFollowerDistanceInfo(const MSLane *lane, const MSVehicle *ego, double latOffset)
Constructor.
std::vector< double > myMissingGaps
virtual ~MSCriticalFollowerDistanceInfo()
Destructor.
std::string toString() const
print a debugging representation
void clear()
discard all information
int addFollower(const MSVehicle *veh, const MSVehicle *ego, double gap, double latOffset=0, int sublane=-1)
static double gLateralResolution
Representation of a lane in the micro simulation.
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual std::string toString() const
print a debugging representation
virtual ~MSLeaderDistanceInfo()
Destructor.
CLeaderDist operator[](int sublane) const
return the vehicle and its distance for the given sublane
virtual void clear()
discard all information
std::vector< double > myDistances
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
MSLeaderDistanceInfo(const MSLane *lane, const MSVehicle *ego, double latOffset)
Constructor.
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
std::vector< const MSVehicle * > myVehicles
int myFreeSublanes
the number of free sublanes
bool hasStoppedVehicle() const
whether a stopped vehicle is leader
int egoRightMost
borders of the ego vehicle for filtering of free sublanes
void getSublaneBorders(int sublane, double latOffset, double &rightSide, double &leftSide) const
MSLeaderInfo(const MSLane *lane, const MSVehicle *ego=0, double latOffset=0)
Constructor.
virtual std::string toString() const
print a debugging representation
virtual void clear()
discard all information
virtual ~MSLeaderInfo()
Destructor.
const MSVehicle * operator[](int sublane) const
return the vehicle for the given sublane
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
double myWidth
the width of the lane to which this instance applies
Representation of a vehicle in the micro simulation.
MSAbstractLaneChangeModel & getLaneChangeModel()
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
SUMOTime getActionStepLength() const
Returns the vehicle's action step length in millisecs, i.e. the interval between two action points.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null