# Predictions of Flight Path¶

Note

Manipulating the maneuver nodes

To alter the maneuver nodes on a vessel’s flight plan, use the ADD and REMOVE commands as described on the maneuver node manipulation page.

Using the Add and Remove commands as described on that page, you may alter the flight plan of the CPU_vessel, however kOS does not automatically execute the nodes. You still have to write the code to decide how to successfully execute a planned maneuver node.

Warning

Be aware that a limitation of KSP makes it so that some vessels’ maneuver node systems cannot be accessed. KSP appears to limit the maneuver node system to only functioning on the current PLAYER vessel, under the presumption that its the only vessel that needs them, as ever other vessel cannot be maneuvered. kOS can maneuver a vessel that is not the player vessel, but it cannot overcome this limitation of the base game that unloads the maneuver node system for other vessels.

Be aware that the effect this has is that when you try to predict another vessel’s position, it will sometimes give you answers that presume that other vessel will be purely drifting, and not following its maneuver nodes.

The following prediction functions do take into account the future maneuver nodes planned, and operate under the assumption that they will be executed as planned.

These return predicted information about the future position and velocity of an object.

POSITIONAT(orbitable,time)
Parameters: orbitable – A Vessel, Body or other Orbitable object time – Time of prediction Orbitable TimeSpan A position Vector expressed as the coordinates in the ship-center-raw-rotation frame

Returns a prediction of where the Orbitable will be at some universal Timestamp. If the Orbitable is a Vessel, and the Vessel has planned maneuver nodes, the prediction assumes they will be executed exactly as planned.

Prerequisite: If you are in a career mode game rather than a sandbox mode game, This function requires that you have your space center’s buildings advanced to the point where you can make maneuver nodes on the map view, as described in Career:CANMAKENODES.

VELOCITYAT(orbitable,time)
Parameters: orbitable – A Vessel, Body or other Orbitable object time – Time of prediction Orbitable TimeSpan An ObitalVelocity structure.

Returns a prediction of what the Orbitable’s velocity will be at some universal Timestamp. If the Orbitable is a Vessel, and the Vessel has planned maneuver nodes, the prediction assumes they will be executed exactly as planned.

Prerequisite: If you are in a career mode game rather than a sandbox mode game, This function requires that you have your space center’s buildings advanced to the point where you can make manuever nodes on the map view, as described in Career:CANMAKENODES.

ORBITAT(orbitable,time)
Parameters: orbitable – A Vessel, Body or other Orbitable object time – Time of prediction Orbitable TimeSpan An Orbit structure.

Returns the Orbit patch where the Orbitable object is predicted to be at some universal Timestamp. If the Orbitable is a Vessel, and the Vessel has planned maneuver nodes, the prediction assumes they will be executed exactly as planned.

Prerequisite: If you are in a career mode game rather than a sandbox mode game, This function requires that you have your space center’s buildings advanced to the point where you can make maneuver nodes on the map view, as described in Career:CANMAKENODES.

Examples:

//kOS
// test the future position and velocity prediction.
// Draws a position and velocity vector at a future predicted time.

declare parameter item. // thing to predict for, i.e. SHIP.
declare parameter offset. // how much time into the future to predict.
declare parameter velScale. // how big to draw the velocity vectors.
// If they're far from the camera you should draw them bigger.

set predictUT to time + offset.
set stopProg to false.

set futurePos to positionat( item, predictUT ).
set futureVel to velocityat( item, predictUT ).

set drawPos to vecdrawargs( v(0,0,0), futurePos, green, "future position", 1, true ).
set drawVel to vecdrawargs( futurePos, velScale*futureVel:orbit, yellow, "future velocity", 1, true ).


Example Screenshot: