From 7df48c0a33e7ff9342ca024dc425b0aee17203b6 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <quaritsch@ivt.tugraz.at> Date: Thu, 2 Feb 2023 17:21:51 +0100 Subject: [PATCH] consider overspeed to check in the driving cycle if the target speed is already reached and we do not need to drive exactly to the next speed-change entry. reduce tolerance to check whether the targetspeed is reached --- VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs | 2 ++ .../VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs | 1 + .../VectoCore/Models/SimulationComponent/IDriverStrategy.cs | 2 ++ .../Models/SimulationComponent/Impl/DefaultDriverStrategy.cs | 2 +- .../SimulationComponent/Impl/DistanceBasedDrivingCycle.cs | 4 ++-- VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs | 1 + .../SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs | 1 + .../VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs | 1 + .../SimulationComponent/Impl/SimplePowertrainContainer.cs | 1 + .../Models/SimulationComponent/Strategies/TestPowertrain.cs | 2 ++ VectoCore/VectoCoreTest/Utils/MockDriver.cs | 1 + VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs | 1 + 12 files changed, 16 insertions(+), 3 deletions(-) diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs index 0995064cb8..9119340085 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs @@ -54,5 +54,7 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus PCCStates PCCState { get; } MeterPerSecond NextBrakeTriggerSpeed { get; } + + MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 7c05025a81..c715c37b3e 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -2297,6 +2297,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs index 73b382beeb..2a3536504c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs @@ -51,5 +51,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent void CommitSimulationStep(); DrivingBehaviorEntry BrakeTrigger { get; } + + MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index a45144c5ca..18791f0767 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -615,7 +615,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) + public virtual MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) { return (targetSpeed + GetOverspeed()).LimitTo( 0.KMPHtoMeterPerSecond(), VehicleCategory.IsBus() ? Constants.BusParameters.MaxBusSpeed : 500.KMPHtoMeterPerSecond()); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 0772429479..223a0e406f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -164,8 +164,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var distanceToSpeedChange = nextSpeedChange - PreviousState.Distance; var estimatedTimeToSpeedChange = distanceToSpeedChange / DataBus.VehicleInfo.VehicleSpeed; if (estimatedTimeToSpeedChange.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval / 2) && - DataBus.VehicleInfo.VehicleSpeed.IsSmaller(Left.VehicleTargetSpeed, 1.KMPHtoMeterPerSecond()) && - DataBus.VehicleInfo.VehicleSpeed.IsSmaller(Right.VehicleTargetSpeed, 1.KMPHtoMeterPerSecond())) { + DataBus.VehicleInfo.VehicleSpeed.IsSmaller(DataBus.DriverInfo.ApplyOverspeed(Left.VehicleTargetSpeed), 0.1.KMPHtoMeterPerSecond()) && + DataBus.VehicleInfo.VehicleSpeed.IsSmaller(DataBus.DriverInfo.ApplyOverspeed(Right.VehicleTargetSpeed), 0.1.KMPHtoMeterPerSecond())) { CurrentState.Response = DriveDistance(absTime, ds); return CurrentState.Response; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index a144bd0869..ee722f9eb5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -1460,6 +1460,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public PCCStates PCCState => DriverStrategy.PCCState; public MeterPerSecond NextBrakeTriggerSpeed => DriverStrategy.BrakeTrigger?.NextTargetSpeed; + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => DriverStrategy.ApplyOverspeed(targetSpeed); protected override bool DoUpdateFrom(object other) => false; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index bac76f3641..43a228a115 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -451,6 +451,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; public Meter Distance => CurrentState.Distance; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs index 3b9c6810b8..f714f1cf16 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs @@ -181,6 +181,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; private void DetermineDriverAction() { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs index 2696b49047..ca3134ab84 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs @@ -34,6 +34,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs index 8fcefba0d8..a56ff6fe71 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs @@ -202,6 +202,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; + #endregion #region Overrides of VectoSimulationComponent diff --git a/VectoCore/VectoCoreTest/Utils/MockDriver.cs b/VectoCore/VectoCoreTest/Utils/MockDriver.cs index e387785e4c..9de8644de9 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDriver.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDriver.cs @@ -125,6 +125,7 @@ namespace TUGraz.VectoCore.Tests.Utils public MeterPerSquareSecond DriverAcceleration { get; set; } public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; protected override bool DoUpdateFrom(object other) => false; diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index 7e29d4735d..fd9df1f477 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -239,6 +239,7 @@ namespace TUGraz.VectoCore.Tests.Utils public MeterPerSquareSecond DriverAcceleration { get; set; } public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public MeterPerSecond ApplyOverspeed(MeterPerSecond targetSpeed) => targetSpeed; public CycleData CycleData { get; set; } -- GitLab