Skip to content

Commit

Permalink
Tune RCS ullaging more
Browse files Browse the repository at this point in the history
Back to having the node executor ullage only for 1/4 second past
100% so that it doesn't excessively waste RCS during the LEAD time.

Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Nov 10, 2023
1 parent 50fae03 commit cd846e3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 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.25;

if (State == States.BURN && RCSOnly)
{
Vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, true);
Expand All @@ -137,6 +141,12 @@ private void DoRCS(FlightCtrlState s)
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 cd846e3

Please sign in to comment.