Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions MechJeb2/MechJebModuleHoverslamSimulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public string Touchdown() =>
// TODO: This counts down even if you don't ignite and i'm not entirely certain what to do about it
// TODO: this doesn't account for planned vertical descent deltaV
[ValueInfoItem("#MechJeb_HoverslamDeltaV", InfoItem.Category.Hoverslam, tooltip = "#MechJeb_HoverslamDeltaV_tooltip")] //Hoverslam Δv
public string HoverslamDeltaV() =>
IsFinite(LandingUT) ? DeltaV(LandingCountdown - (IgnitionUT < VesselState.time ? 0 : IgnitionCountdown)).ToSI() + "m/s" : "N/A";
public string HoverslamDeltaV() => IsFinite(DeltaV) ? DeltaV.ToSI() + "m/s" : "N/A";

[ValueInfoItem("#MechJeb_HoverslamCoordinates", InfoItem.Category.Hoverslam, width = 90, tooltip = "#MechJeb_HoverslamCoordinates_tooltip")] //Coordinates
public string HoverslamCoordinates() => Coordinates.ToStringDMS(Lat, Lng, true);
Expand Down Expand Up @@ -111,6 +110,7 @@ public string HoverslamDeltaV() =>
public double Lng;
public double IgnitionCountdown => IgnitionUT - VesselState.time;
public double LandingCountdown => LandingUT - VesselState.time;
public double DeltaV;
public double FinalDescentSpeed; // should be positive
public Vector3d IgnitionAttitude;
// ReSharper restore MemberCanBePrivate.Global
Expand Down Expand Up @@ -150,6 +150,7 @@ private void Reset()
LandingPosition = new Vector3d(double.NaN, double.NaN, double.NaN);
IgnitionUT = double.NaN;
LandingUT = double.NaN;
DeltaV = double.NaN;
IgnitionAttitude = new Vector3d(double.NaN, double.NaN, double.NaN);
Lat = 0;
Lng = 0;
Expand All @@ -158,7 +159,7 @@ private void Reset()
_lastCycleUT = 0;
}

private double DeltaV(double burnTime)
private double CalculateDeltaV(double burnTime)
{
Core.StageStats.RequestUpdate();

Expand Down Expand Up @@ -224,6 +225,7 @@ public override void OnFixedUpdate()
MainBody.GetLatLngAltAtUT(LandingUT, LandingPosition, out Lat, out Lng, out _);
TerrainAltitude = MainBody.TerrainAltitude(Lat, Lng, true);
Slope = MainBody.GetPQSSlopeDegrees(Lat, Lng);
DeltaV = CalculateDeltaV(LandingCountdown - (IgnitionUT < VesselState.time ? 0 : IgnitionCountdown));
}

if (_hoverslam.IsFaulted && _hoverslam.ExceptionMessage != null)
Expand Down
4 changes: 4 additions & 0 deletions MechJebKos/HoverslamSimulationBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ protected override void InitializeSuffixes()
"Predicted landing latitude in degrees."));
AddSuffix("LONGITUDE", new Suffix<ScalarValue>(() => Module.Lng,
"Predicted landing longitude in degrees."));
AddSuffix("BIOME", new Suffix<StringValue>(() => Module.Biome(),
"Biome name at the predicted landing site (\"N/A\" if no solution)."));
AddSuffix("TERRAINALTITUDE", new Suffix<ScalarValue>(() => Module.TerrainAltitude,
"Terrain altitude at the predicted landing site in meters."));
AddSuffix("SLOPE", new Suffix<ScalarValue>(() => Module.Slope,
Expand All @@ -45,6 +47,8 @@ protected override void InitializeSuffixes()
"Planned final descent speed in m/s."));
AddSuffix("FINALTHRUSTACCEL", new Suffix<ScalarValue>(() => Module.FinalThrustAccel,
"Final thrust acceleration in m/s^2 (-1 if no solution)."));
AddSuffix("DELTAV", new Suffix<ScalarValue>(() => Module.DeltaV,
"Estimated hoverslam delta-v in m/s (NaN if no solution)."));

AddSuffix("MAPLANDINGPREDICTION", new SetSuffix<BooleanValue>(() => Module.MapLandingPrediction, value => Module.MapLandingPrediction = value,
"Draw the predicted landing site marker on the map."));
Expand Down
Loading