Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Brake gap Euler calculation

Hello,

I copied the calculation of brake gap from: https://github.com/eclipse/sumo/blob/08766930f4b3d3df95aa5cfcf92bae0358724710/src/microsim/cfmodels/MSCFModel.cpp#L89 line by line:

STEP_LENGTH = 1

def brakeGapEuler(speed, decel, headwayTime):
speedReduction = STEP_LENGTH * decel
steps = int(speed/speedReduction)
return STEP_LENGTH * (steps * speed - speedReduction * steps * (steps + 1) / 2) + speed * headwayTime

In the original definition, ACCEL2SPEED is defined in https://github.com/eclipse/sumo/blob/9bab618a12a49ae925954e23c2386dd67b7717ea/src/utils/common/SUMOTime.h#L49 where the relevant lines to calculate TS in the same file: 

// the step length in ms
extern SUMOTime DELTA_T;
// the step length in seconds as double
#define TS (static_cast<double>(DELTA_T/1000.))

would mean that if my step length is the default value of 1 second, DELTA_T will hold the same value in milliseconds (ms), that is, 1000 ms? And hence, TS will hold a value of 1000/1000 = 1s. So the first line const double speedReduction = ACCEL2SPEED(decel); will be a speedReduction = decel * 1, that is, the value of maximum deceleration ability of a vehicle?

I was told that in general, egoSpeed * tau + egoBrakeGap = secureGap + leaderBrakeGap so I am trying to verify my calculation of brake gap using that (Since there is no other way to get brakeGap using TraCI?)

# egoSpeed * tau + egoBrakeGap = secureGap + leaderBrakeGap
egoBrakeGap = brakeGapEuler(speed=speed, decel=traci.vehicle.getDecel(vh), headwayTime=1)
leaderBrakeGap = brakeGapEuler(speed=traci.vehicle.getSpeed(rel_veh), decel=traci.vehicle.getDecel(rel_veh), headwayTime=1)

print('{} * {} + {} = {} + {}'.format(speed, 1, egoBrakeGap, secureGap, leaderBrakeGap))

that prints:

3.2317 * 1 + 3.2317 = 0.15779999999999994 + 10.6478

which is False. I am not sure where I am going wrong here in this case. From my understanding headwayTime = tau = 1 second? Please advise.

Thank you.

Sincerely,
Hriday

Back to the top