Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

bugfix: calculation of next distance when still accelerating before brake

consider the case that 'nextTargetSpeed != 0' for computing the next simulation distance
parent 5c7dd0e8
No related branches found
No related tags found
No related merge requests found
......@@ -128,17 +128,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// estimate the distance to drive when accelerating with the current acceleration (taken from retVal) and then
// coasting with the dirver's LookaheadDeceleration.
// TriggerDistance - CurrentDistance = s_accelerate + s_lookahead
// s_coast(dt) = - (currentSpeed + a * dt)^2 / (2 * a_lookahead
// s_coast(dt) = - (currentSpeed + a * dt + nextTargetSpeed) * (nextTargetSpeed - (currentSpeed + a * dt)) / (2 * a_lookahead)
// s_acc(dt) = currentSpeed * dt + a / 2 * dt^2
// => solve for dt, compute ds = currentSpeed * dt + a / 2 * dt^2
var dtList = VectoMath.QuadraticEquationSolver(
(retVal.Acceleration / 2 -
retVal.Acceleration * retVal.Acceleration / 2 / Driver.DriverData.LookAheadCoasting.Deceleration).Value(),
(Driver.DataBus.VehicleSpeed -
Driver.DataBus.VehicleSpeed * retVal.Acceleration / Driver.DriverData.LookAheadCoasting.Deceleration)
.Value
(),
(-Driver.DataBus.VehicleSpeed * Driver.DataBus.VehicleSpeed / 2 / Driver.DriverData.LookAheadCoasting.Deceleration -
Driver.DataBus.VehicleSpeed * retVal.Acceleration / Driver.DriverData.LookAheadCoasting.Deceleration).Value(),
(nextAction.NextTargetSpeed * nextAction.NextTargetSpeed / 2 / Driver.DriverData.LookAheadCoasting.Deceleration -
Driver.DataBus.VehicleSpeed * Driver.DataBus.VehicleSpeed / 2 / Driver.DriverData.LookAheadCoasting.Deceleration -
(nextAction.TriggerDistance - Driver.DataBus.Distance)).Value());
dtList.Sort();
var dt = dtList.First(x => x > 0).SI<Second>();
......
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