From bc14c4f8258dd1923ca51128a79c9473700c02f8 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Wed, 12 Jun 2019 08:13:01 +0200 Subject: [PATCH] additional condition to avoid short simulation intervals. if disengaged and the braking interval is pretty short (due to a slight decrease in target speed), start braking one simulation interval earlier instead of driving exactly to the point where braking starts and then have a pretty short interval of braking (<0.05s) --- .../Impl/DefaultDriverStrategy.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 1c926f3c48..329a280050 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -89,9 +89,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl UpdateDrivingAction(currentDistance, ds); if (NextDrivingAction != null) { var remainingDistance = NextDrivingAction.ActionDistance - currentDistance; - var estimatedNextTimestep = remainingDistance / Driver.DataBus.VehicleSpeed; - if (remainingDistance.IsEqual(0.SI<Meter>(), Constants.SimulationSettings.DriverActionDistanceTolerance) || - estimatedNextTimestep.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval)) { + var estimatedTimestep = remainingDistance / Driver.DataBus.VehicleSpeed; + + var atTriggerTistance = remainingDistance.IsEqual( + 0.SI<Meter>(), Constants.SimulationSettings.DriverActionDistanceTolerance); + var closeBeforeBraking = estimatedTimestep.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval); + var brakingIntervalTooShort = NextDrivingAction.Action == DrivingBehavior.Braking && + ((NextDrivingAction.TriggerDistance - NextDrivingAction.ActionDistance) / Driver.DataBus.VehicleSpeed) + .IsSmaller( + Constants.SimulationSettings.LowerBoundTimeInterval / 20) && !Driver.DataBus.ClutchClosed(absTime); + if ( atTriggerTistance || closeBeforeBraking || brakingIntervalTooShort) { CurrentDrivingMode = DrivingMode.DrivingModeBrake; DrivingModes[CurrentDrivingMode].ResetMode(); Log.Debug("Switching to DrivingMode BRAKE"); -- GitLab