From a2c21f641b1dd8640b1ca562c629fb4e1f027130 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Wed, 10 Jun 2020 10:30:00 +0200 Subject: [PATCH] cause of the error: a short simulation interval occurs because braking to the next but one target speed (stop) starts slightly before the next target speed change. thus the simulation first goes to the distance where braking has to start and then simulates the short distance to the next target speed (as we do not cross target speed changes) solution: allow simulating over a target speed change if the distance to the next target speed change is short and the vehicle is already below the next target speed. --- .../Impl/DistanceBasedDrivingCycle.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index e3310f1d60..8e54430aa9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -58,6 +59,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl internal readonly DrivingCycleEnumerator CycleIntervalIterator; private bool _intervalProlonged; internal IdleControllerSwitcher IdleController; + private Meter CycleEndDistance; + private DrivingCycleData.DrivingCycleEntry Left { @@ -74,6 +77,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Data = cycle; CycleIntervalIterator = new DrivingCycleEnumerator(Data); CycleStartDistance = Data.Entries.Count > 0 ? Data.Entries.First().Distance : 0.SI<Meter>(); + CycleEndDistance = Data.Entries.Count > 0 ? Data.Entries.Last().Distance : 0.SI<Meter>(); var first = Data.Entries.First(); PreviousState = new DrivingCycleState { @@ -139,6 +143,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; return CurrentState.Response; } + + if (DataBus.VehicleSpeed.IsGreater(0) && Right.Distance.IsSmaller(CycleEndDistance)) { + var distanceToSpeedChange = nextSpeedChange - PreviousState.Distance; + var estimatedTimeToSpeedChange = distanceToSpeedChange / DataBus.VehicleSpeed; + if (estimatedTimeToSpeedChange.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval / 2) && + DataBus.VehicleSpeed.IsSmaller(Left.VehicleTargetSpeed, 1.KMPHtoMeterPerSecond()) && + DataBus.VehicleSpeed.IsSmaller(Right.VehicleTargetSpeed, 1.KMPHtoMeterPerSecond())) { + CurrentState.Response = DriveDistance(absTime, ds); + return CurrentState.Response; + } + } + // only drive until next sample point in cycle with speed change Log.Debug("Limiting distance to next sample point {0}", Right.Distance - PreviousState.Distance); -- GitLab