diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 6e991caee2c7aa5ad2cbe6c7dbed8ed920276d3f..72f808622cb0a3ade553c1ba85d9ba0c78cc8ffe 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -560,7 +560,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new VectoException("IdleController can only handle idle requests, i.e. angularVelocity == null!"); } if (!outTorque.IsEqual(0)) { - throw new VectoException("Torque has to be 0 for idle requests!"); + throw new VectoException("Torque has to be 0 for idle requests! {0}", outTorque); } if (_idleStart == null) { _idleStart = absTime; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 40a03d68bdf41bb53efe40327f5d8e8536a7cdb3..7ac10086c79d50966ccfbde579f2ab46fed9b5f6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -492,8 +492,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl debug.Add(new { action = "ClutchOpen -> Roll", response }); response.Switch().Case<ResponseUnderload>( r => { - response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, r); - debug.Add(new { action = "Roll:Underload -> Brake", response }); + if (DataBus.ClutchClosed(absTime)) { + response = HandleRequestEngaged(absTime, ds, velocity, gradient, false, velocity, debug); + } else { + response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, r); + debug.Add(new { action = "Roll:Underload -> Brake", response }); + } }) .Case<ResponseSpeedLimitExceeded>( () => { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index e88ef84be88c91958a4ccb17dbb0af09fa05dff8..eeaf42f516deef4551c8c245848e36331839675b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -60,6 +60,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> protected internal bool Disengaged = true; + private bool postponeEngage; + public Second LastUpshift { get; protected internal set; } public Second LastDownshift { get; protected internal set; } @@ -71,7 +73,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override bool ClutchClosed(Second absTime) { - return _engageTime.IsSmallerOrEqual(absTime, ModelData.TractionInterruption / 20); + return _engageTime.IsSmallerOrEqual(absTime, ModelData.TractionInterruption / 20) && !postponeEngage; } public Gearbox(IVehicleContainer container, IShiftStrategy strategy, VectoRunData runData) : base(container, runData) @@ -181,9 +183,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _engageTime = absTime + dt; } + postponeEngage = false; if (ClutchClosed(absTime) && Disengaged && !outAngularVelocity.IsEqual(0)) { - ReEngageGear(absTime, dt, outTorque, outAngularVelocity); - Log.Debug("Gearbox engaged gear {0}", Gear); + if (dt.IsSmaller(Constants.SimulationSettings.TargetTimeInterval / 10)) { + Log.Debug("postponing re-engage due to small simulation interval {0}", dt); + postponeEngage = true; + } else { + ReEngageGear(absTime, dt, outTorque, outAngularVelocity); + Log.Debug("Gearbox engaged gear {0}", Gear); + } } var gear = Disengaged ? NextGear.Gear : Gear; @@ -420,6 +428,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override void DoCommitSimulationStep() { + postponeEngage = false; if (!Disengaged) { if (CurrentState.TorqueLossResult != null && CurrentState.TorqueLossResult.Extrapolated) { Log.Warn(