maneatingape / rsvp

kOS library that enables scripted orbital transfer window planning and vessel rendezvous for the the game Kerbal Space Program
GNU General Public License v3.0
40 stars 5 forks source link
kerbal-operating-system kerbal-space-program kerboscript kos ksp ksp-kos ksp-scripts lambert orbital-dynamics orbital-mechanics

RSVP version-badge download-badge

RSVP is a kOS library that finds orbital launch windows in the game Kerbal Space Program. The acronym stands for "Rendezvous s’il vous plaît", a playful pun on the regular meaning of the phrase.

This library enables players to make automated low delta-v transfers between two planets or vessels in-game, either directly from their own kOS scripts or from the kOS console. It provides a scriptable alternative to existing tools, such as the excellent web based Launch Window Planner or the snazzy MechJeb Maneuver Planner.

Features

This short video shows these features in action: Demo Video

Quickstart

  1. Go to the Releases tab, then download latest version of rsvp.zip.
  2. Unzip into <KSP install location>/Ships/Script directory. This step adds the library to the kOS archive volume, making it available to all vessels.
  3. Launch a craft into a stable orbit of Kerbin.
  4. Run this script from the craft:
    set config:ipu to 2000.
    runoncepath("0:/rsvp/main").
    local options is lexicon("create_maneuver_nodes", "both", "verbose", true).
    rsvp:goto(duna, options).

    This will find the next transfer window from Kerbin to Duna then create the corresponding maneuver nodes necessary to make the journey. Additionally it will print details to the console during the search.


Configuration

The following options allow players to customize and tweak the desired transfer orbit. The general philosophy is that sensible defaults are provided for each option so that only custom values need to be provided. Specify options by adding them as key/value pairs to the options lexicon parameter.

Verbose

Prints comprehensive details to the kOS console if set to "True".

Key Default value Accepted values
verbose False Boolean

Create Maneuver Nodes

Whether or not to create maneuver nodes that will execute the desired journey. The value "none" can be used for planning, the script will return details of the next transfer window.

Key Default value Accepted values
create_maneuver_nodes None One of String values "none", "first" or "both"

Cleanup Maneuver Nodes

If any problems are enountered when creating the transfer then remove and cleanup any maneuver nodes that have been created. Defaults to true but can be disabled for debugging purposes.

Key Default value Accepted values
cleanup_maneuver_nodes True Boolean

Earliest Departure

When to start searching for transfer windows. Time can be in the vessel's past, present or future. The only restriction is that the time must be greater than the epoch time (Year 1, Day 1, 0:00:00)

Key Default value Accepted values
earliest_departure Current universal time of CPU vessel plus 2 minutes Seconds from epoch as Scalar

Search Duration

Only search for transfer windows within the specified duration from earliest departure. Restricting the search duration can come in handy when time is of the essence. Increasing the duration may reveal a lower cost delta-v transfer to patient players.

Key Default value Accepted values
search_duration Maximum of origin orbital period, destination orbital period or their synodic period Duration in seconds as Scalar

Search Interval

How frequently new sub-searches are started within the search duration. Lower values may result in better delta-v values being discovered, however the search will take longer to complete.

Key Default value Accepted values
search_interval Half the minimum of origin orbital period and destination orbital period Duration in seconds as Scalar

Maximum time of flight

Maximum duration of the transfer orbit between origin and destination. Some reasons it may come in useful to adjust this are life support mods, challenge requirements and career mode contract deadlines.

Key Default value Accepted values
max_time_of_flight Twice the time of a idealized Hohmann transfer between origin and destination Duration in seconds as Scalar

Final Orbit Periapsis*

Sets desired destination orbit periapsis in meters.

Key Default value Accepted values
final_orbit_periapsis 100,000m Altitude in meters as Scalar

Final Orbit Type*

The insertion orbit can be one of three types:

Key Default value Accepted values
final_orbit_type Circular One of String values "none", "circular" or "elliptical"

Final Orbit Orientation*

The orbit orientation can be one of three types:

Key Default value Accepted values
final_orbit_orientation Prograde One of String values "prograde", "polar" or "retrograde"

Note on Vessel rendezvous

Vessel destinations are treated slightly differently to Celestial body destinations. Setting a vessel as the destination disables the final_orbit_periapsis, final_orbit_type and final_orbit_orientation options.


Integrating with your scripts

RSVP is designed with some quality of life features to make it as straightforward as possible to use within your own scripts.

Technical Details

The source code readme contains detailed descriptions of the under-the-hood mechanisms. Each script file is thoroughly commented to describe both what the code is doing, but also more importantly why.

Suggest a feature or report a bug

If you have an idea for a feature or have found a bug then you can create an issue here. Before you do so, please check that the issue doesn't already exist in the isses list.