diff --git a/VectoCore/Configuration/Constants.cs b/VectoCore/Configuration/Constants.cs index b155f6611a4e2ecec246ae8767e6456bd1d90c4a..a5bc06b9ce445fa7175d7bb0267fb70a7276b502 100644 --- a/VectoCore/Configuration/Constants.cs +++ b/VectoCore/Configuration/Constants.cs @@ -72,7 +72,7 @@ namespace TUGraz.VectoCore.Configuration public static Meter DriverActionDistanceTolerance = 0.25.SI<Meter>(); - public static double VehicleSpeedTolerance = 1e-3; + public static MeterPerSecond VehicleSpeedHaltTolerance = 1e-3.SI<MeterPerSecond>(); /// <summary> /// The initial search interval for the operating point search in the driver. diff --git a/VectoCore/Models/Simulation/Impl/DistanceRun.cs b/VectoCore/Models/Simulation/Impl/DistanceRun.cs index fb6c29fd0727f8082ccbee36f51b001e6ef4fb56..a4b7695ac4b36ea1e9564bd3264561e834cfce40 100644 --- a/VectoCore/Models/Simulation/Impl/DistanceRun.cs +++ b/VectoCore/Models/Simulation/Impl/DistanceRun.cs @@ -17,7 +17,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl protected override IResponse DoSimulationStep() { // estimate distance to be traveled within the next TargetTimeInterval - var ds = Container.VehicleSpeed.IsEqual(0, Constants.SimulationSettings.VehicleSpeedTolerance) + var ds = Container.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance : Constants.SimulationSettings.TargetTimeInterval * Container.VehicleSpeed; diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index eb8118aa528a33ab89c464b74ca2c703cb7a997c..102e9166a5006c8c69ccdae64c5f15f6f1f45301 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -492,7 +492,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // braking power is in the range of the exceeding delta. set searching range to 2/3 so that // the target point is approximately in the center of the second interval var searchInterval = origDelta.Abs() * 2 / 3; - + debug.Add(new { brakePower = 0.SI<Watt>(), searchInterval, delta = origDelta, operatingPoint }); var brakePower = searchInterval * -origDelta.Sign(); @@ -776,10 +776,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns></returns> public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient) { - if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0, 1e-3)) { + if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0)) { throw new NotImplementedException("TargetVelocity or VehicleVelocity is not zero!"); } - DataBus.BreakPower = Double.PositiveInfinity.SI<Watt>(); + DataBus.BreakPower = double.PositiveInfinity.SI<Watt>(); var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); retVal.Switch(). Case<ResponseGearShift>(r => { diff --git a/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index a5ac4cdc5657739facb9dc8ed99b49f72b4fe710..9d097f103a6bba40a5818986fa281825ea50c260 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -125,7 +125,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _currentState.dt = dt; _currentState.Acceleration = acceleration; _currentState.Velocity = _previousState.Velocity + acceleration * dt; - if (_currentState.Velocity.IsEqual(0, 1e-4)) { + if (_currentState.Velocity.IsEqual(0.SI<MeterPerSecond>(), Constants.SimulationSettings.VehicleSpeedHaltTolerance)) { _currentState.Velocity = 0.SI<MeterPerSecond>(); } _currentState.Distance = _previousState.Distance + dt * (_previousState.Velocity + _currentState.Velocity) / 2;