Skip to content

Commit

Permalink
Ullage in the Node Executor for at least 1/2 second
Browse files Browse the repository at this point in the history
Same code as the ThrustController

Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Nov 8, 2023
1 parent 586dc2c commit bcb686a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion MechJeb2/MechJebModuleNodeExecutor.cs
Expand Up @@ -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);
Expand All @@ -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;

Expand Down

0 comments on commit bcb686a

Please sign in to comment.