From bcb686aec7d39520ee9427c176307a968815791b Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 8 Nov 2023 13:31:40 -0800 Subject: [PATCH] Ullage in the Node Executor for at least 1/2 second Same code as the ThrustController Signed-off-by: Lamont Granquist --- MechJeb2/MechJebModuleNodeExecutor.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/MechJeb2/MechJebModuleNodeExecutor.cs b/MechJeb2/MechJebModuleNodeExecutor.cs index 48498184..5466633e 100644 --- a/MechJeb2/MechJebModuleNodeExecutor.cs +++ b/MechJeb2/MechJebModuleNodeExecutor.cs @@ -119,11 +119,15 @@ public enum States { WARPALIGN, LEAD, BURN, IDLE } private double _ignitionUT; private static bool _isLoadedPrincipia => VesselState.isLoadedPrincipia; private bool _hasNodes => Vessel.patchedConicSolver.maneuverNodes.Count > 0; + private double _ullageUntil; public override void Drive(FlightCtrlState s) => DoRCS(s); private void DoRCS(FlightCtrlState s) { + // seconds to continue to apply RCS after ullage has settled to VeryStable + const double MIN_RCS_TIME = 0.50; + if (State == States.BURN && RCSOnly) { Vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, true); @@ -134,9 +138,15 @@ private void DoRCS(FlightCtrlState s) if (State != States.LEAD || RCSOnly) return; - if (!Core.Thrust.AutoRCSUllaging || VesselState.lowestUllage >= 1.0) + if (!Core.Thrust.AutoRCSUllaging) + return; + + if (VesselState.lowestUllage >= 1.0 && VesselState.time > _ullageUntil) return; + if (VesselState.lowestUllage < 1.0) + _ullageUntil = VesselState.time + MIN_RCS_TIME; + if (!Vessel.hasEnabledRCSModules()) return;