From 653231281ba8568988b7d658aadb4fdd8044d37d Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Wed, 30 Sep 2015 15:41:27 +0200
Subject: [PATCH] driverActionBrake: only adapt deceleration if already braking
 with max. deceleration

---
 VectoCore/Models/SimulationComponent/Impl/Driver.cs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs
index af45a2cd3a..4ecc593137 100644
--- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs
+++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs
@@ -317,7 +317,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 			var operatingPoint = ComputeAcceleration(ds, nextTargetSpeed);
 
-			if (operatingPoint.Acceleration < 0) {
+			//if (operatingPoint.Acceleration.IsSmaller(0)) {
+			// if we should brake with the max. deceleration and the deceleration changes within the current interval, take the larger deceleration...
+			if (operatingPoint.Acceleration.IsEqual(DriverData.AccelerationCurve.Lookup(DataBus.VehicleSpeed).Deceleration)) {
 				var v2 = DataBus.VehicleSpeed + operatingPoint.Acceleration * operatingPoint.SimulationInterval;
 				var nextAcceleration = DriverData.AccelerationCurve.Lookup(v2).Deceleration;
 				var tmp = ComputeTimeInterval(VectoMath.Min(operatingPoint.Acceleration, nextAcceleration),
-- 
GitLab