# Vessel¶

class Vessel

These objects are used to interact with vessels in KSP. This includes getting orbital and flight data, manipulating control inputs and managing resources. Created using active_vessel() or vessels().

std::string name()
void set_name(std::string value)

The name of the vessel.

Game Scenes: All
VesselType type()
void set_type(VesselType value)

The type of the vessel.

Game Scenes: All
VesselSituation situation()

The situation the vessel is in.

Game Scenes: All
bool recoverable()

Whether the vessel is recoverable.

Game Scenes: All
void recover()

Recover the vessel.

Game Scenes: All
double met()

The mission elapsed time in seconds.

Game Scenes: All
std::string biome()

The name of the biome the vessel is currently in.

Game Scenes: All
Flight flight(ReferenceFrame reference_frame = ReferenceFrame())

Returns a Flight object that can be used to get flight telemetry for the vessel, in the specified reference frame.

Parameters: reference_frame – Reference frame. Defaults to the vessel’s surface reference frame (Vessel::surface_reference_frame()). Flight

Note

When this is called with no arguments, the vessel’s surface reference frame is used. This reference frame moves with the vessel, therefore velocities and speeds returned by the flight object will be zero. See the reference frames tutorial for examples of getting the orbital and surface speeds of a vessel.

Orbit orbit()

The current orbit of the vessel.

Game Scenes: All
Control control()

Returns a Control object that can be used to manipulate the vessel’s control inputs. For example, its pitch/yaw/roll controls, RCS and thrust.

Game Scenes: Flight
Comms comms()

Returns a Comms object that can be used to interact with CommNet for this vessel.

Game Scenes: Flight
AutoPilot auto_pilot()

An AutoPilot object, that can be used to perform simple auto-piloting of the vessel.

Game Scenes: Flight
int32_t crew_capacity()

The number of crew that can occupy the vessel.

Game Scenes: All
int32_t crew_count()

The number of crew that are occupying the vessel.

Game Scenes: All
std::vector<CrewMember> crew()

The crew in the vessel.

Game Scenes: All
Resources resources()

A Resources object, that can used to get information about resources stored in the vessel.

Game Scenes: Flight
Resources resources_in_decouple_stage(int32_t stage, bool cumulative = true)

Returns a Resources object, that can used to get information about resources stored in a given stage.

Parameters: stage – Get resources for parts that are decoupled in this stage. cumulative – When false, returns the resources for parts decoupled in just the given stage. When true returns the resources decoupled in the given stage and all subsequent stages combined. Flight

Note

For details on stage numbering, see the discussion on Staging.

Parts parts()

A Parts object, that can used to interact with the parts that make up this vessel.

Game Scenes: Flight
float mass()

The total mass of the vessel, including resources, in kg.

Game Scenes: Flight
float dry_mass()

The total mass of the vessel, excluding resources, in kg.

Game Scenes: Flight
float thrust()

The total thrust currently being produced by the vessel’s engines, in Newtons. This is computed by summing Engine::thrust() for every engine in the vessel.

Game Scenes: Flight
float available_thrust()

Gets the total available thrust that can be produced by the vessel’s active engines, in Newtons. This is computed by summing Engine::available_thrust() for every active engine in the vessel.

Game Scenes: Flight
float max_thrust()

The total maximum thrust that can be produced by the vessel’s active engines, in Newtons. This is computed by summing Engine::max_thrust() for every active engine.

Game Scenes: Flight
float max_vacuum_thrust()

The total maximum thrust that can be produced by the vessel’s active engines when the vessel is in a vacuum, in Newtons. This is computed by summing Engine::max_vacuum_thrust() for every active engine.

Game Scenes: Flight
float specific_impulse()

The combined specific impulse of all active engines, in seconds. This is computed using the formula described here.

Game Scenes: Flight
float vacuum_specific_impulse()

The combined vacuum specific impulse of all active engines, in seconds. This is computed using the formula described here.

Game Scenes: Flight
float kerbin_sea_level_specific_impulse()

The combined specific impulse of all active engines at sea level on Kerbin, in seconds. This is computed using the formula described here.

Game Scenes: Flight
std::tuple<double, double, double> moment_of_inertia()

The moment of inertia of the vessel around its center of mass in $$kg.m^2$$. The inertia values in the returned 3-tuple are around the pitch, roll and yaw directions respectively. This corresponds to the vessels reference frame (ReferenceFrame).

Game Scenes: Flight
std::vector<double> inertia_tensor()

The inertia tensor of the vessel around its center of mass, in the vessels reference frame (ReferenceFrame). Returns the 3x3 matrix as a list of elements, in row-major order.

Game Scenes: All
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> available_torque()

The maximum torque that the vessel generates. Includes contributions from reaction wheels, RCS, gimballed engines and aerodynamic control surfaces. Returns the torques in $$N.m$$ around each of the coordinate axes of the vessels reference frame (ReferenceFrame). These axes are equivalent to the pitch, roll and yaw axes of the vessel.

Game Scenes: Flight
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> available_reaction_wheel_torque()

The maximum torque that the currently active and powered reaction wheels can generate. Returns the torques in $$N.m$$ around each of the coordinate axes of the vessels reference frame (ReferenceFrame). These axes are equivalent to the pitch, roll and yaw axes of the vessel.

Game Scenes: Flight
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> available_rcs_torque()

The maximum torque that the currently active RCS thrusters can generate. Returns the torques in $$N.m$$ around each of the coordinate axes of the vessels reference frame (ReferenceFrame). These axes are equivalent to the pitch, roll and yaw axes of the vessel.

Game Scenes: Flight
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> available_engine_torque()

The maximum torque that the currently active and gimballed engines can generate. Returns the torques in $$N.m$$ around each of the coordinate axes of the vessels reference frame (ReferenceFrame). These axes are equivalent to the pitch, roll and yaw axes of the vessel.

Game Scenes: Flight
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> available_control_surface_torque()

The maximum torque that the aerodynamic control surfaces can generate. Returns the torques in $$N.m$$ around each of the coordinate axes of the vessels reference frame (ReferenceFrame). These axes are equivalent to the pitch, roll and yaw axes of the vessel.

Game Scenes: Flight
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> available_other_torque()

The maximum torque that parts (excluding reaction wheels, gimballed engines, RCS and control surfaces) can generate. Returns the torques in $$N.m$$ around each of the coordinate axes of the vessels reference frame (ReferenceFrame). These axes are equivalent to the pitch, roll and yaw axes of the vessel.

Game Scenes: Flight
ReferenceFrame reference_frame()

The reference frame that is fixed relative to the vessel, and orientated with the vessel.

• The origin is at the center of mass of the vessel.
• The axes rotate with the vessel.
• The x-axis points out to the right of the vessel.
• The y-axis points in the forward direction of the vessel.
• The z-axis points out of the bottom off the vessel.
Game Scenes: Flight

Vessel reference frame origin and axes for the Aeris 3A aircraft

Vessel reference frame origin and axes for the Kerbal-X rocket

ReferenceFrame orbital_reference_frame()

The reference frame that is fixed relative to the vessel, and orientated with the vessels orbital prograde/normal/radial directions.

• The origin is at the center of mass of the vessel.
• The x-axis points in the orbital anti-radial direction.
• The y-axis points in the orbital prograde direction.
• The z-axis points in the orbital normal direction.
Game Scenes: Flight

Note

Be careful not to confuse this with ‘orbit’ mode on the navball.

Vessel orbital reference frame origin and axes

ReferenceFrame surface_reference_frame()

The reference frame that is fixed relative to the vessel, and orientated with the surface of the body being orbited.

• The origin is at the center of mass of the vessel.
• The axes rotate with the north and up directions on the surface of the body.
• The x-axis points in the zenith direction (upwards, normal to the body being orbited, from the center of the body towards the center of mass of the vessel).
• The y-axis points northwards towards the astronomical horizon (north, and tangential to the surface of the body – the direction in which a compass would point when on the surface).
• The z-axis points eastwards towards the astronomical horizon (east, and tangential to the surface of the body – east on a compass when on the surface).
Game Scenes: Flight

Note

Be careful not to confuse this with ‘surface’ mode on the navball.

Vessel surface reference frame origin and axes

ReferenceFrame surface_velocity_reference_frame()

The reference frame that is fixed relative to the vessel, and orientated with the velocity vector of the vessel relative to the surface of the body being orbited.

• The origin is at the center of mass of the vessel.
• The axes rotate with the vessel’s velocity vector.
• The y-axis points in the direction of the vessel’s velocity vector, relative to the surface of the body being orbited.
• The z-axis is in the plane of the astronomical horizon.
• The x-axis is orthogonal to the other two axes.
Game Scenes: Flight

Vessel surface velocity reference frame origin and axes

std::tuple<double, double, double> position(ReferenceFrame reference_frame)

The position of the center of mass of the vessel, in the given reference frame.

Parameters: reference_frame – The reference frame that the returned position vector is in. The position as a vector. Flight
std::tuple<std::tuple<double, double, double>, std::tuple<double, double, double>> bounding_box(ReferenceFrame reference_frame)

The axis-aligned bounding box of the vessel in the given reference frame.

Parameters: reference_frame – The reference frame that the returned position vectors are in. The positions of the minimum and maximum vertices of the box, as position vectors. Flight
std::tuple<double, double, double> velocity(ReferenceFrame reference_frame)

The velocity of the center of mass of the vessel, in the given reference frame.

Parameters: reference_frame – The reference frame that the returned velocity vector is in. The velocity as a vector. The vector points in the direction of travel, and its magnitude is the speed of the body in meters per second. Flight
std::tuple<double, double, double, double> rotation(ReferenceFrame reference_frame)

The rotation of the vessel, in the given reference frame.

Parameters: reference_frame – The reference frame that the returned rotation is in. The rotation as a quaternion of the form $$(x, y, z, w)$$. Flight
std::tuple<double, double, double> direction(ReferenceFrame reference_frame)

The direction in which the vessel is pointing, in the given reference frame.

Parameters: reference_frame – The reference frame that the returned direction is in. The direction as a unit vector. Flight
std::tuple<double, double, double> angular_velocity(ReferenceFrame reference_frame)

The angular velocity of the vessel, in the given reference frame.

Parameters: reference_frame – The reference frame the returned angular velocity is in. The angular velocity as a vector. The magnitude of the vector is the rotational speed of the vessel, in radians per second. The direction of the vector indicates the axis of rotation, using the right-hand rule. Flight
enum struct VesselType

The type of a vessel. See Vessel::type().

enumerator base

Base.

enumerator debris

Debris.

enumerator lander

Lander.

enumerator plane

Plane.

enumerator probe

Probe.

enumerator relay

Relay.

enumerator rover

Rover.

enumerator ship

Ship.

enumerator station

Station.

enum struct VesselSituation

The situation a vessel is in. See Vessel::situation().

enumerator docked

Vessel is docked to another.

enumerator escaping

Escaping.

enumerator flying

Vessel is flying through an atmosphere.

enumerator landed

Vessel is landed on the surface of a body.

enumerator orbiting

Vessel is orbiting a body.

enumerator pre_launch

Vessel is awaiting launch.

enumerator splashed

Vessel has splashed down in an ocean.

enumerator sub_orbital

Vessel is on a sub-orbital trajectory.

class CrewMember

Represents crew in a vessel. Can be obtained using Vessel::crew().

std::string name()
void set_name(std::string value)

The crew members name.

Game Scenes: All
CrewMemberType type()

The type of crew member.

Game Scenes: All
bool on_mission()

Whether the crew member is on a mission.

Game Scenes: All
float courage()
void set_courage(float value)

The crew members courage.

Game Scenes: All
float stupidity()
void set_stupidity(float value)

The crew members stupidity.

Game Scenes: All
float experience()
void set_experience(float value)

The crew members experience.

Game Scenes: All
bool badass()
void set_badass(bool value)

Whether the crew member is a badass.

Game Scenes: All
bool veteran()
void set_veteran(bool value)

Whether the crew member is a veteran.

Game Scenes: All
enum struct CrewMemberType

The type of a crew member. See CrewMember::type().

enumerator applicant

An applicant for crew.

enumerator crew

Rocket crew.

enumerator tourist

A tourist.

enumerator unowned

An unowned crew member.