diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 1dfd6ed2b34196f31e4794f4c15e7e063289123b..6e0320d3b6316633d0e31f923716f8dd65226ab3 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -305,7 +305,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseSuccess>(). Case<ResponseUnderload>(). // driver limits acceleration, operating point may be below engine's //drag load resp. below 0 - //Case<ResponseOverload>(). // driver limits acceleration, operating point may be above 0 (GBX), use brakes + Case<ResponseOverload>(). // driver limits acceleration, operating point may be above 0 (GBX), use brakes Case<ResponseGearShift>(). Case<ResponseFailTimeInterval>(r => { retVal = new ResponseDrivingCycleDistanceExceeded() { @@ -769,10 +769,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)) { + if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0, 1e-3)) { 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/Gearbox.cs b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 2dafcc1493b108bba77e6fbf562100fec3713e1d..b528cbe88a3b911140c45f4167627b97a9732ed8 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -186,6 +186,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </returns> public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun) { + Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", torque, angularVelocity); if (DataBus.VehicleStopped) { _shiftTime = absTime; } @@ -293,7 +294,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (dryRun) { - if (inEngineSpeed < DataBus.EngineIdleSpeed && DataBus.VehicleSpeed < Constants.SimulationSettings.VehicleStopClutchDisengageSpeed) { + if ((DataBus.DrivingBehavior == DrivingBehavior.Braking || DataBus.DrivingBehavior == DrivingBehavior.Coasting) && + inEngineSpeed < DataBus.EngineIdleSpeed && + DataBus.VehicleSpeed < Constants.SimulationSettings.VehicleStopClutchDisengageSpeed) { _disengaged = true; _shiftTime = absTime + dt; _strategy.Disengage(absTime, dt, outTorque, outAngularVelocity); diff --git a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 7261ffba83022f26917342a65ddaeb23975cffc6..3c0cb58e8dc87154e5c444b0b6ef09f712811638 100644 --- a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -289,18 +289,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Gearbox.Gear = tryNextGear; var response = (ResponseDryRun)Gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); Gearbox.Gear = tmpGear; - - inAngularVelocity = Data.Gears[tryNextGear].Ratio * outAngularVelocity; - inTorque = response.ClutchPowerRequest / inAngularVelocity; - - // if next gear supplied enough power reserve: take it - // otherwise take - if (!IsBelowDownShiftCurve(tryNextGear, inTorque, inAngularVelocity)) { - var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad; - var reserve = 1 - (response.EnginePowerRequest / fullLoadPower).Cast<Scalar>(); - - if (reserve >= Data.TorqueReserve) { - NextGear = tryNextGear; + if (!(response is ResponseEngineSpeedTooLow)) { + inAngularVelocity = Data.Gears[tryNextGear].Ratio * outAngularVelocity; + inTorque = response.ClutchPowerRequest / inAngularVelocity; + + // if next gear supplied enough power reserve: take it + // otherwise take + if (!IsBelowDownShiftCurve(tryNextGear, inTorque, inAngularVelocity)) { + var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad; + var reserve = 1 - (response.EnginePowerRequest / fullLoadPower).Cast<Scalar>(); + + if (reserve >= Data.TorqueReserve) { + NextGear = tryNextGear; + } } } }