41 myFreeSublanes((int)myVehicles.size()),
44 myHasVehicles(false) {
72 int rightmost, leftmost;
78 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
114 double rightVehSide = vehCenter - vehHalfWidth;
115 double leftVehSide = vehCenter + vehHalfWidth;
120 rightVehSide -= maneuverDist;
124 leftVehSide += maneuverDist;
127 if (rightVehSide >
myWidth || leftVehSide < 0) {
154 assert(sublane >= 0);
164 assert(sublane >= 0);
172 std::ostringstream oss;
173 oss.setf(std::ios::fixed, std::ios::floatfield);
174 oss << std::setprecision(2);
175 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
198 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
212 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
222 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
238 myDistances(myVehicles.size(),
std::numeric_limits<double>::max()) {
244 myDistances(1, cLeaderDist.second) {
258 if (veh ==
nullptr) {
265 if (sublane >= 0 && sublane < (
int)
myVehicles.size()) {
277 int rightmost, leftmost;
283 for (
int sublaneIdx = rightmost; sublaneIdx <= leftmost; ++sublaneIdx) {
301 for (
int i = 0; i < maxSubLane; i++) {
302 addLeader(other[i].first, other[i].second, 0, i);
320 assert(sublane >= 0);
328 std::ostringstream oss;
329 oss.setf(std::ios::fixed, std::ios::floatfield);
330 oss << std::setprecision(2);
331 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
348 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
350 if (
myVehicles[i]->getLaneChangeModel().isOpposite()) {
352 }
else if (isFollower &&
myDistances[i] > POSITION_EPS) {
364 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
376 minGap = std::numeric_limits<double>::max();
377 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
384 return std::make_pair(veh, minGap);
391 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
405 double result = std::numeric_limits<double>::max();
409 for (
int i = 0; i < (int)
myVehicles.size(); ++i) {
425 myMissingGaps(myVehicles.size(), -
std::numeric_limits<double>::max()),
426 myHaveOppositeLeaders(haveOppositeLeaders)
435 if (veh ==
nullptr) {
440 const double missingGap = requiredGap - gap;
465 if (sublane >= 0 && sublane < (
int)
myVehicles.size()) {
485 int rightmost, leftmost;
487 for (
int sublaneIdx = rightmost; sublaneIdx <= leftmost; ++sublaneIdx) {
492 || (missingGap > 0 && gap <
myDistances[sublaneIdx])
519 std::ostringstream oss;
520 oss.setf(std::ios::fixed, std::ios::floatfield);
521 oss << std::setprecision(2);
522 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 veh, 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].
bool myHaveOppositeLeaders
std::vector< double > myMissingGaps
virtual ~MSCriticalFollowerDistanceInfo()
Destructor.
MSCriticalFollowerDistanceInfo(const double laneWidth, const MSVehicle *ego, const double latOffset, const bool haveOppositeLeaders=false)
Constructor.
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.
MSEdge & getEdge() const
Returns the lane's edge.
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual void addLeaders(MSLeaderDistanceInfo &other)
updatd empty sublanes with vehicles and gaps from other
virtual std::string toString() const
print a debugging representation
double getMinDistToStopped() const
return minimum distance to a stopped vehicle or max double
CLeaderDist getClosest() const
return vehicle with the smalles gap
virtual ~MSLeaderDistanceInfo()
Destructor.
MSLeaderDistanceInfo(const double laneWidth, const MSVehicle *ego, const double latOffset)
Constructor.
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
void fixOppositeGaps(bool isFollower)
subtract vehicle length from all gaps if the leader vehicle is driving in the opposite direction
void patchGaps(double amount)
add given value to all gaps
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
void moveSamePosTo(const MSVehicle *ego, MSLeaderDistanceInfo &other)
bool hasVehicle(const MSVehicle *veh) const
whether the given vehicle is part of this leaderInfo
std::vector< const MSVehicle * > myVehicles
int myFreeSublanes
the number of free sublanes
int myOffset
an extra offset for shifting the interpretation of sublane borders (default [0,myWidth])
void setSublaneOffset(int offset)
set number of sublanes by which to shift positions
bool hasStoppedVehicle() const
whether a stopped vehicle is leader
void removeOpposite(const MSLane *lane)
remove vehicles that are driving in the opposite direction (fully or partially) on the given lane
int egoRightMost
borders of the ego vehicle for filtering of free sublanes
void getSublaneBorders(int sublane, double latOffset, double &rightSide, double &leftSide) const
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0.)
virtual std::string toString() const
print a debugging representation
virtual void clear()
discard all information
MSLeaderInfo(const double laneWidth, const MSVehicle *ego=nullptr, const double latOffset=0.)
Constructor.
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.
const MSLane * getLane() const
Returns the lane the vehicle is on.
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 getPositionOnLane() const
Get the vehicle's position along the lane.
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