Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 21462d79 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

fix: estimating distance before brake: handle case of no positive results can be found for dt

parent 176511c7
No related branches found
No related tags found
No related merge requests found
......@@ -477,8 +477,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Driver.DataBus.VehicleSpeed * Driver.DataBus.VehicleSpeed / 2 / Driver.DriverData.LookAheadCoasting.Deceleration -
(nextAction.TriggerDistance - Driver.DataBus.Distance)).Value());
dtList.Sort();
if (!dtList.Any(x => x > 0)) {
return null;
}
var dt = dtList.First(x => x > 0).SI<Second>();
var newds = Driver.DataBus.VehicleSpeed * dt + retVal.Acceleration / 2 * dt * dt;
var newds = Driver.DataBus.VehicleSpeed * dt + (retVal.Acceleration / 2 * dt * dt);
return newds;
}
}
......@@ -566,7 +569,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Constants.SimulationSettings.DriverActionDistanceTolerance)) {
return response;
}
newds = EstimateAccelerationDistanceBeforeBrake(response, nextAction);
newds = EstimateAccelerationDistanceBeforeBrake(response, nextAction) ?? ds;
break;
case DrivingBehavior.Braking:
var brakingDistance = Driver.DriverData.AccelerationCurve.ComputeAccelerationDistance(v2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment