FlightPlan 0.8.0

Flight Plan

Flight Plan GUI

Plan your (Space) Flight! Fly your Plan! Handy tools to help you set up maneuver nodes that will get you where you want to be. Making spaceflight planning easier for Kerbal Space Program 2 one mission at a time.

NOTE: This mod draws heavily on some core MechJeb2 code that has been adapted to work in KSP2, and would not be possible without the kind and generous contributions of Sarbian and the MechJeb development team! It is not the intent to replicate all MechJeb2 features and functions in this mod, but merely to make some handy maneuver planning tools available for KSP2 players. While you may be able to create some useful nodes with this mod, you'll still need to execute them accurately! Also, understanding some basic mission planning will be very usful for those employing the tools in this toolbox.

Compatibility

Installation

  1. Download and extract BepInEx mod loader with SpaceWarp 1.0.1 or later (see link above) into your game folder and run the game, then close it. If you've done this before, you can skip this step. If you've installed the game via Steam, then this is probably here: C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program 2. If you complete this step correctly you'll have a BepInEx subfolder in that directory along with the following files (in addition to what was there before): changelog.txt, doorstop_config.ini, winhttp.dll
  2. Install Node Manager 0.5.2 or later (see link above). From the NodeManager-x.x.x.zip file copy the BepInEx folder on top of your game's install folder. If done correctly, you should have the following folder structure within your KSP2 game folder: ...\Kerbal Space Program 2\BepInEx\plugins\node_manager.
  3. Download and extract this mod into the game folder. From the FlightPlan-x.x.x.zip file copy the BepInEx folder on top of your game's install folder. If done correctly, you should have the following folder structure within your KSP2 game folder: ...\Kerbal Space Program 2\BepInEx\plugins\flight_plan.

Features

Display Current Target Selection

  • Drop Down Menu for easy selection of Celestial Targets

Own Ship Maneuvers

  • Circularize at Ap
  • Circularize at Pe
  • Circularize Now
  • New Pe (user specified value) - planned for next Ap
  • New Ap (user specified value) - planned for next Pe
  • New Pe & Ap (for user specified values) - Burn ASAP
  • New Inclination (user specified value) - if e < 0: Planned for cheapest AN/DN, otherwise planned for ASAP

Maneuvers Relative to the Selected Target (only available if a target is selected)

  • Course Correction (requires being on an intercept trajectory)
  • Match planes with Target at AN
  • Match Planes with Target at DN
  • Hohmann Transfer to Target

Moon Specific Maneuvers (only available when in orbit about a moon)

  • Return from a Moon

Display Status of Last Command

  • Normal/Good results are shown in Green indicating a maneuver node was generated and it's ready for you to execute it. Don't forget to get your craft pointed in the right direction first!
  • Warnings and Cautions are shown in Yellow indicating a node was generated, but you should inspect it carefully first and may need to modify it.
  • Failures are shown in Red indicating no node has been generated with some clue as to why.

Game Input Enable/Disable Status

  • To prevent the things you type in a user input field from passing through to the game and affecting things in odd ways, the game input is automatically disabled when you click inside a text input field. This will cause the game to not respond to your mouse or to anything you type, although you can freely type what you need into the input field. Typing a "." as part of a decimal number will not increase your time warp setting, and using the 1 and 2 keys on your number pad will not mute the game or the music. To restore full functionality for keyboard and mouse inputs simply click anywhere else other than the text input field. Closing the Flight Plan GUI will also have this effect.

Integration with K2-D2, v0.8.1+

  • If K2-D2 is installed, then a "K2D2" button will be presented in the lower right part of the GUI whenever there is an executable maneuver node. If the version of K2-D2 is 0.8.0 or earlier, then pressing Flight Plan's K2-D2 button will bring up the K2-D2 GUI to assist with the precision execution of the planned maneuver. If K2-D2 0.8.1 or later is installed, then pressing the K2-D2 button will cause K2-D2 to execute the next maneuver node - this doesn't bring up the K2-D2 GUI, but if you have it up you'll be able to watch it as it executes the node.

Integration with Maneuver Node Controller, v0.8.3+

  • If Maneuver Node Controller (v0.8.3 or later) is installed then Flight Plan will present a "MNC" button in the lower right corner of the GUI. Pressing that button will bring up the Maneuver Node Controller GUI. If the Launch Maneuver Node Controller configuration setting is Enabled, then when you activate an experimental node creation function the Maneuver Node Controller mod will automatically be brought up if it is not already up. This can make it easier to evaluate and adjust nodes constructed using experimental functions (those listed under Planned Improvement below)

UI Screens

In addition to the basic UI screen above the UI will automatically asjust to offer capabilities relevant to the current orbit and selected target.

Selecting a Celestial Target with the Drop Down Menu

Flight Plan Target Selection GUI

With a Local Object Selected (selected target is orbiting the same body your vessel is)

Flight Plan Target Selected GUI - Moon

Configuration Parameters

Flight Plan Configuration Parameters

This mod includes a number of user configurable parameters which can be accessed through the SpaceWarp configuration screen. Press Alt + M to pull up the SpaceWarp Mod dialog, and select the Open Configuration Manager button at the bottom to display the list of installed mods with configurable settings. Clicking on the Flight Plan entry will display the ionterface shown above. There are tool tip strings which describe what each setting does. Using the configuration parameters you can change a variety of things such as how long a status message sticks around before it start to fade, and also how long it will take to fade.

NOTE: The following settings are dyanically managed and may be usted by the user while the game is running. All others will require exiting and restart to take effect.

  • Experimental Features: Enable/Disable
  • Launch Maneuver Node Controller: Enable/Disable
  • Status Fade Time: Seconds
  • Status Hold Time: Seconds

Planned Improvement / Experimental Functions

Flight Plan Future GUI

Work In Progress developmental features may be enabled by switching on the Experimental Features in the mod's configuration screen. You will need to restart the game for this setting to take effect, but it will allow you to play with some broken toys if you like. As these featuers mature and become realiable enough to use they will be moved up into the main feature set avaialble without turning on the Experimental Features setting.

Maneuvers Relative to the Selected Target (only available if a target is selected)

  • Intercept Target (at user specified time from now)
  • Match Velocity at Closest Approach (requires being on an intercept trajectory)
  • Match Velocity Now

Interplanetary Transfer Maneuvers (only available if a planet is the selected target)

  • Interplanetary Transfer

Example Images

Circularize at the Next Ap

Flight Plan: Circularize at Next Ap Example

Burn Timing Detail (burn brackets effective point: Ap)

Flight Plan: Circularize at Next Ap Burn Detail

Circularize at the Next Pe

Flight Plan: Circularize at Next Pe Example

Set New Pe

Flight Plan: Set New Pe Example

Set New Ap

Flight Plan: Set New Pe Example

Set Inclination to 0

Flight Plan: Set Inclination to 0 Example

Match Planes with Minmus at AN (from 20 deg inclined orbit)

Flight Plan: Match Planes with Target at AN Example

Match Planes with Minmus at DN (from 20 deg inclined orbit)

Flight Plan: Match Planes with Target at DN Example

Hohmann Transfer to Minmus (from coplanar orbit)

Flight Plan: Hohmann Transfer Example

Hohmann Transfer to Mun (from coplanar orbit)

Flight Plan: Hohmann Transfer Example

Set Inclination on Munar Flyby

Flight Plan: Set Incination to 87 in Hyperbolic Orbit

Circularize at Pe for Munar Fly By

Flight Plan: Circularize at Next Pe Example - Munar Flyby

Hohmann Transfer to Mun (from non-coplanar orbit: Inclined 20 degrees from target plane)

Flight Plan: Hohmann Transfer Example

Flight Plan as a Library

Flight Plan's orbital maneuver node creation methods are public, and so may be called from other mods. In this sense, Flight Plan can be accessed like a library whether the Flight Plan GUI is visible or not.

This mod is primarily meant as a direct aid to the player but can also be used as a service provider to other mods which can call functions in this one without needing to recreate all these functions in the base mod. Creating maneuver nodes from a KSP2 mod is not necessarily an intuitive thing to code, so having this as a resource you can call may save you time developing those capabilities internally to your mod.

Orbital Maneuver Node Capabilities

NOTE 1: All of the orbital maneuver node creation methods in Flight Plan take an optional (double) burnOffsetFactor parameter. This factor us uesd with the node's burn duration (as estimated by the game) to allow you to offset the start time of the node. By default in KSP2 nodes begin at the time you've created them for unlike in KSP1 where they would bracket the requested start time. This optional parameter allws you to plan maneuver nodes that will start earlier so that the applied Delta-v occurs centered on the intended time.

NOTE 2: All of the orbital maneuver node creation methods in Flight Plan return a boolean value which is true if the node creation was successful and false otherwise.

  • Circularize(burnUT, burnOffsetFactor): Calling this method will create a maneuver node at the specified time for the active vessel to circularize the vessel's orbit at that point. This method can be used to plan a circularization burn at the next Apoapsis, Periapsis, or any other time that suits your needs during the orbit.
  • SetNewPe(burnUT, newPeR, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to set the vessel's Periapsis (measured from center of body, not altitude above serface).
  • SetNewAp(burnUT, newApR, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to set the vessel's Apoapsis (measured from center of body, not altitude above serface).
  • Ellipticize(burnUT, newApR, newPeR, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to set the vessel's Apoapsis and Periapsis (both measured from center of body, not altitude above serface) at a time aproximately 30 seconds from now.
  • SetInclination(burnUT, newIncDeg, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to set the vessel's orbit inclination (in degrees) at either the next Ascending Node or Descending Node. Both options are evaluated and the one requireing the least Delta-v is automatically selected.
  • MatchPlanes(burnUT, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to set the vessel's orbit inclination to match that of the currently selected target at the next Ascending Node for the target.
  • HohmannTransfer(burnUT, burnOffsetFactor): Calling this method will create a maneuver node at the optimal time for a Hohmann Transfer to the currently selected target at the next available window.
  • InterceptTgt(burnUT, deltaUT, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to intercept the currently selected target at the a time of deltaUT from now.
  • CourseCorrection(burnUT, burnOffsetFactor): Calling this method will create a maneuver node at the optimal time to finetime the trajectory to intercept the currently selected target. This method may be useful after executing a Hohman Transfer or Moon Return maneuver node. Calling it prior to node execution is suboptimal and not advised.
  • MoonReturn(burnUT, burnOffsetFactor): Calling this method will create a maneuver node at the optimal time for a Hohmann Transfer to return the active vessel from a moon to the planet the moon is orbiting.
  • MatchVelocity(burnUT, burnOffsetFactor): Calling this method will create a maneuver node at the specified time to match velocity with the currently selected target at the point of closest approach.
  • PlanetaryXfer(burnUT, burnOffsetFactor): Calling this method will create a maneuver node for a Hohmann Transfer to the currently selected target planet at the next available window.

Orbital Time Prognistication Capabilities

  • Time_to_Ap
  • Time_to_Pe

To use this mod from your mod you will need to do one of the following:

Hard Dependency via Nuget Package

If core capabilities in your mod will rely on calling Flight Plan methods, then setting up a hard dependency like this is the way to go, plus it's actually easier to develop your mod this way. There are two ways to set up your mod for development with Flight Plan as a hard dependency, and this is the easiest of the two, so is the recommended way. Fundamentally, it works just like what you're already doing to reference BepInEx and SpaceWarp.

  • The advantage to this way is coding will be easier for you! Just call FlightPlanPlugin.Instance.method_name() for any public method in Flight Plan!
  • The disadvantage to this way is you've got a hard dependency and your mod will not even start up unless both Flight Plan and its hard dependency of Node Manager are installed. You may want to ship a copy of Flight Plan and Node Manager with your mod (put both the flight_plan and node_manager plugin folders with your mod's plugin folder into the BepInEx/plugins folder before zipping it up). There may be a way to do this with CKAN in some automated fashion. This guide will be updated with those details, or a link to them, at some point.

Step 1: Update your csproj file

In your csproj file you may already have an ItemGroup where BepInEx, HarmonyX, and SpaceWarp are added as PackageReferene includes. If so, all you need to do is add PackageReferences for FlightPlan and NodeManager as sown below.

    <ItemGroup>
        <PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
        <PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.0" PrivateAssets="all" />
        <PackageReference Include="BepInEx.Core" Version="5.*" />
        <PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
        <PackageReference Include="HarmonyX" Version="2.10.1" />
        <PackageReference Include="SpaceWarp" Version="1.1.1" />
        <PackageReference Include="FlightPlan" Version="0.7.3" />
        <PackageReference Include="NodeManager" Version="0.5.3" />
        <PackageReference Include="UnityEngine.Modules" Version="2020.3.33" IncludeAssets="compile" />
    </ItemGroup>

Step 2: Configure Namespace and Add Dependency

Bring in the FlightPlan namespace in the class you want to call it from, and add both Flight Plan and Node Manager as a BepInDependencies. You won't need the NodeManger namespace unless you plan to also call Node Manager directly.

    using FlightPlan;
    
    namespace MyCoolModsNameSpace;
    
    [BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
    [BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
    [BepInDependency(FlightPlanPlugin.ModGuid, FlightPlanPlugin.ModVer)]
    [BepInDependency(NodeManagerPlugin.ModGuid, NodeManagerPlugin.ModVer)]
    public class MyCoolModName : BaseSpaceWarpPlugin

Step 3: Call Flight Plan Methods from your Mod

You can now call any of Node Manager's public methods directly and easily from your code. Here are some examples:

    pass = FlightPlanPlugin.Instance.CircularizeAtAP(burnOffsetFactor) // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.CircularizeAtPe(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.CircularizeNow(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.SetNewPe(newPeR, burnOffsetFactor); // double, double (default = -0.5)
    pass = FlightPlanPlugin.Instance.SetNewAp(newApR, burnOffsetFactor); // double, double (default = -0.5)
    pass = FlightPlanPlugin.Instance.Ellipticize(newApR, newPeR, burnOffsetFactor); // double, double, double (default = -0.5)
    pass = FlightPlanPlugin.Instance.SetInclination(newIncDeg, burnOffsetFactor); // double, double (default = -0.5)
    pass = FlightPlanPlugin.Instance.MatchPlanesAtAN(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.MatchPlanesAtDN(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.HohmannTransfer(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.InterceptTgtAtUT(deltaUT, burnOffsetFactor); // double, double (default = -0.5)
    pass = FlightPlanPlugin.Instance.CourseCorrection(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.MoonReturn(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.MatchVelocityAtCA(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.MatchVelocityNow(burnOffsetFactor); // double (default = -0.5)
    pass = FlightPlanPlugin.Instance.PlanetaryXfer(burnOffsetFactor); // double (default = -0.5)

Step 4: Profit!

Hard Dependency via Local Copy of Flight Plan DLL

This way works like the method above with a few minor differences in your csproj and what you need to do in your mod's development folder.

Step 1: Configure Assemblies

Add a copy of the flight_plan.dll and node_manager.dll to your mod's list of Assemblies. Generally, this means two things. First, put copies of the flight_plan.dll and node_manager.dll in a folder where your mod can find them. You may want to put them in the same folder you have Assembly-CSharp.dll. Secondly, add them to your csproj file similarly to how you're already referencing Assembly-CSharp.dll. Your mod will need to have access to them, and know where to find them, when you compile your mod. At run time your mod will be accessing the flight_plan.dll from the flight_plan plugins folder where Flight Plan is installed, so you don't need to distribute the Flight Plan or Node Manager DLLs with your mod, but both of those mods will need to be installed in the players game for your to be able to access Flight Plan.

In your csproj file locate the ItemGroup where you have local References defined. There will be at least one for Assembly-CSharp.dll. You'll need to add one for Flight Plan and one for Node Manager like this.

    <ItemGroup>
        <Reference Include="Assembly-CSharp">
            <HintPath>..\external_dlls\Assembly-CSharp.dll</HintPath>
            <Publicize>true</Publicize>
            <Private>false</Private>
        </Reference>
        <Reference Include="flight_plan">
            <HintPath>..\external_dlls\flight_plan.dll</HintPath>
            <Private>false</Private>
        </Reference>
        <Reference Include="node_manager">
            <HintPath>..\external_dlls\node_manager.dll</HintPath>
            <Private>false</Private>
        </Reference>
    </ItemGroup>

Step 2: Configure Namespace and Add Dependency

See Step 2 above as there is no difference.

Step 3: Call Node Manager Methods from your Mod

See Step 3 above as there is no difference.

Step 4: Profit!

Soft Dependency

This is the way to go if optional capabilities in your mod will rely on functions in this Flight Plan, and you don't want your mod to have a hard dependency on Flight Plan.

  • The advantage to this way is that your mod's users don't need to have Flight Plan installed if they prefer not to have it, and you can distribute your mod without needing a hard dependency on Flight Plan - meaning you mod can launch and run yor mod without Flight Plan or its dependency Node Manager, although there may be some capabilities that aren't available to your users if they choose to pass on installing Flight Plan and Node Manager.
  • The disadvantage to this way is you'll need to do a bit more coding in your mod to be able to call Flight Plan's methods from your mod.

Step 1: configure Assemblies

This is the same as for Hard Dependency above as you'll not be able to compile without this.

Step 2: Configure Namespace and Variables

Bring in the NodeManger namespace and create some variables in the class you want to call it from. This is almost the same as above.

   using FlightPlan;
   
   private bool FPLoaded;
   PluginInfo FP;

Step 3: Check for Flight Plan

Somewhere in your mod you need to check to make sure Flight Plan is loaded before you use it (e.g., OnInitialized()). You don't need this with a hard dependency, but it's essential for a soft one.

    if (Chainloader.PluginInfos.TryGetValue(FlightPlanPlugin.ModGuid, out FP))
    {
        FPLoaded = true;
        Logger.LogInfo("Flight Plan installed and available");
        Logger.LogInfo($"FP = {FP}");
    }
    else FPLoaded = false;

Step 4: Create Reflection Method

This is where things get really different for you compared to what's needed to call Flight Plan methods using a hard dependency. For a soft dependency to work you're going to need to create a reflection calling method for each of the Flight Plan methods that you would like to call from your mod. Here's an example of one for calling Flight Plan's SetNewPe method which will pass it the new Pe you would like to have, and optionally a burn time offset. Note: Using a burn time time offset of -0.5 will cause the maneuver node to be centered on the nominal time for the burn (next Ap in this case).

    private void SetNewPe(double newPeR, double burnOffsetFactor = -0.5)
    {
        if (FPLoaded)
        {
            // Reflections method to call Node Manager methods from your mod
            var nmType = Type.GetType($"FlightPlan.FlightPlanPlugin, {FlightPlanPlugin.ModGuid}");
            Logger.LogDebug($"Type name: {nmType!.Name}");
            var instanceProperty = nmType!.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
            Logger.LogDebug($"Property name: {instanceProperty!.Name}");
            var methodInfo = instanceProperty!.PropertyType.GetMethod("SetNewPe");
            Logger.LogDebug($"Method name: {methodInfo!.Name}");
            methodInfo!.Invoke(instanceProperty.GetValue(null), new object[] { newPeR, burnOffsetFactor });
        }
    }

This example includes some (optional) debug logging that may be helpful if you are having trouble with the reflection calling method. You can safely remove those once it's working to your satisfaction.

Step 5: Call Reflection Method

Call your reflection method wherever you need to invoke the corresponding Node Manager method.

    SetNewPe(newPeR, -0.5);

Step 6: Profit!

No packages depend on FlightPlan.

.NET Standard 2.0

Version Downloads Last updated
0.10.5 122 03/19/2024
0.8.0 137 04/30/2023
0.7.4 138 04/26/2023