# AutoPilot¶

class AutoPilot

Provides basic auto-piloting utilities for a vessel. Created by calling Vessel.AutoPilot.

Note

If a client engages the auto-pilot and then closes its connection to the server, the auto-pilot will be disengaged and its target reference frame, direction and roll reset to default.

void Engage ()

Engage the auto-pilot.

Game Scenes: Flight
void Disengage ()

Disengage the auto-pilot.

Game Scenes: Flight
void Wait ()

Blocks until the vessel is pointing in the target direction and has the target roll (if set). Throws an exception if the auto-pilot has not been engaged.

Game Scenes: Flight
Single Error { get; }

The error, in degrees, between the direction the ship has been asked to point in and the direction it is pointing in. Throws an exception if the auto-pilot has not been engaged and SAS is not enabled or is in stability assist mode.

Game Scenes: Flight
Single PitchError { get; }

The error, in degrees, between the vessels current and target pitch. Throws an exception if the auto-pilot has not been engaged.

Game Scenes: Flight
Single HeadingError { get; }

The error, in degrees, between the vessels current and target heading. Throws an exception if the auto-pilot has not been engaged.

Game Scenes: Flight
Single RollError { get; }

The error, in degrees, between the vessels current and target roll. Throws an exception if the auto-pilot has not been engaged or no target roll is set.

Game Scenes: Flight
ReferenceFrame ReferenceFrame { get; set; }

The reference frame for the target direction (AutoPilot.TargetDirection).

Game Scenes: Flight

Note

An error will be thrown if this property is set to a reference frame that rotates with the vessel being controlled, as it is impossible to rotate the vessel in such a reference frame.

Single TargetPitch { get; set; }

The target pitch, in degrees, between -90° and +90°.

Game Scenes: Flight
Single TargetHeading { get; set; }

The target heading, in degrees, between 0° and 360°.

Game Scenes: Flight
Single TargetRoll { get; set; }

The target roll, in degrees. NaN if no target roll is set.

Game Scenes: Flight
Tuple<Double, Double, Double> TargetDirection { get; set; }

Direction vector corresponding to the target pitch and heading. This is in the reference frame specified by ReferenceFrame.

Game Scenes: Flight
void TargetPitchAndHeading (Single pitch, Single heading)

Set target pitch and heading angles.

Parameters: pitch – Target pitch angle, in degrees between -90° and +90°. heading – Target heading angle, in degrees between 0° and 360°. Flight
Boolean SAS { get; set; }

The state of SAS.

Game Scenes: Flight

Note

Equivalent to Control.SAS

SASMode SASMode { get; set; }

The current SASMode. These modes are equivalent to the mode buttons to the left of the navball that appear when SAS is enabled.

Game Scenes: Flight

Note

Equivalent to Control.SASMode

Double RollThreshold { get; set; }

The threshold at which the autopilot will try to match the target roll angle, if any. Defaults to 5 degrees.

Game Scenes: Flight
Tuple<Double, Double, Double> StoppingTime { get; set; }

The maximum amount of time that the vessel should need to come to a complete stop. This determines the maximum angular velocity of the vessel. A vector of three stopping times, in seconds, one for each of the pitch, roll and yaw axes. Defaults to 0.5 seconds for each axis.

Game Scenes: Flight
Tuple<Double, Double, Double> DecelerationTime { get; set; }

The time the vessel should take to come to a stop pointing in the target direction. This determines the angular acceleration used to decelerate the vessel. A vector of three times, in seconds, one for each of the pitch, roll and yaw axes. Defaults to 5 seconds for each axis.

Game Scenes: Flight
Tuple<Double, Double, Double> AttenuationAngle { get; set; }

The angle at which the autopilot considers the vessel to be pointing close to the target. This determines the midpoint of the target velocity attenuation function. A vector of three angles, in degrees, one for each of the pitch, roll and yaw axes. Defaults to 1° for each axis.

Game Scenes: Flight
Boolean AutoTune { get; set; }

Whether the rotation rate controllers PID parameters should be automatically tuned using the vessels moment of inertia and available torque. Defaults to true. See AutoPilot.TimeToPeak and AutoPilot.Overshoot.

Game Scenes: Flight
Tuple<Double, Double, Double> TimeToPeak { get; set; }

The target time to peak used to autotune the PID controllers. A vector of three times, in seconds, for each of the pitch, roll and yaw axes. Defaults to 3 seconds for each axis.

Game Scenes: Flight
Tuple<Double, Double, Double> Overshoot { get; set; }

The target overshoot percentage used to autotune the PID controllers. A vector of three values, between 0 and 1, for each of the pitch, roll and yaw axes. Defaults to 0.01 for each axis.

Game Scenes: Flight
Tuple<Double, Double, Double> PitchPIDGains { get; set; }

Gains for the pitch PID controller.

Game Scenes: Flight

Note

When AutoPilot.AutoTune is true, these values are updated automatically, which will overwrite any manual changes.

Tuple<Double, Double, Double> RollPIDGains { get; set; }

Gains for the roll PID controller.

Game Scenes: Flight

Note

When AutoPilot.AutoTune is true, these values are updated automatically, which will overwrite any manual changes.

Tuple<Double, Double, Double> YawPIDGains { get; set; }

Gains for the yaw PID controller.

Game Scenes: Flight

Note

When AutoPilot.AutoTune is true, these values are updated automatically, which will overwrite any manual changes.