From 288fac1cd5d6789d8825994f7d9a458b258d9381 Mon Sep 17 00:00:00 2001
From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at>
Date: Fri, 3 Mar 2023 08:26:27 +0100
Subject: [PATCH] in case the vehicle is driving and the engine is off, keep
 the speed virtually at Max(gearboxSpeed, Idlespeed)

---
 .../SimulationComponent/Impl/StopStartCombustionEngine.cs    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs
index 767422c91a..5825c20600 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs
@@ -84,7 +84,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 				//throw new VectoSimulationException("Combustion engine cannot supply outtorque when switched off (T_out: {0})", outTorque);
 			}
 			CurrentState.EngineOn = false;
-			CurrentState.EngineSpeed = DataBus.VehicleInfo.VehicleStopped || outAngularVelocity.IsEqual(0) ? ModelData.IdleSpeed : outAngularVelocity; //ModelData.IdleSpeed;
+			CurrentState.EngineSpeed = DataBus.VehicleInfo.VehicleStopped || outAngularVelocity.IsEqual(0) 
+				? ModelData.IdleSpeed 
+				: VectoMath.Max(outAngularVelocity, ModelData.IdleSpeed);
+
 			CurrentState.EngineTorque = 0.SI<NewtonMeter>();
 			CurrentState.EngineTorqueOut = 0.SI<NewtonMeter>();
 			CurrentState.EnginePower = 0.SI<Watt>();
-- 
GitLab