Parts#
The following classes allow interaction with a vessels individual parts.
Parts#
-
class Parts#
Instances of this class are used to interact with the parts of a vessel. An instance can be obtained by calling
Vessel::parts().-
Part root()#
The vessels root part.
Note
See the discussion on Trees of Parts.
-
void set_controlling(std::optional<Part> value)#
The part from which the vessel is controlled. Returns
NULLif the vessel has no control point, in which case it is oriented by its root part.- Game Scenes:
Flight
Note
A vessel gets no control point when it is created by a decoupler or an undocking and none of its parts is a command module with crew aboard. A probe core does not give it one either. Assign this property to choose the control point, which is equivalent to “Control From Here” in game.
-
std::vector<Part> with_name(std::string name)#
A list of parts whose
Part::name()is name.- Parameters:
-
std::vector<Part> with_title(std::string title)#
A list of all parts whose
Part::title()is title.- Parameters:
-
std::vector<Part> with_tag(std::string tag)#
A list of all parts whose
Part::tag()is tag.- Parameters:
-
std::vector<Part> with_module(std::string module_name)#
A list of all parts that contain a
ModulewhoseModule::name()is module_name.- Parameters:
-
std::vector<Module> modules_with_name(std::string module_name)#
A list of modules (combined across all parts in the vessel) whose
Module::name()is module_name.- Parameters:
-
std::vector<Antenna> antennas()#
A list of all antennas in the vessel.
Note
If RemoteTech is installed, this will always return an empty list. To interact with RemoteTech antennas, use the RemoteTech service APIs.
-
std::vector<ControlSurface> control_surfaces()#
A list of all control surfaces in the vessel.
-
std::vector<DockingPort> docking_ports()#
A list of all docking ports in the vessel.
-
std::vector<Engine> engines()#
A list of all engines in the vessel.
Note
This includes any part that generates thrust. This covers many different types of engine, including liquid fuel rockets, solid rocket boosters, jet engines and RCS thrusters.
-
std::vector<Experiment> experiments()#
A list of all science experiments in the vessel.
-
std::vector<LaunchClamp> launch_clamps()#
A list of all launch clamps attached to the vessel.
-
std::vector<ResourceDrain> resource_drains()#
A list of all resource drains in the vessel.
-
std::vector<ReactionWheel> reaction_wheels()#
A list of all reaction wheels in the vessel.
-
std::vector<ResourceConverter> resource_converters()#
A list of all resource converters in the vessel.
-
std::vector<ResourceHarvester> resource_harvesters()#
A list of all resource harvesters in the vessel.
-
std::vector<RoboticController> robotic_controllers()#
A list of all robotic controllers in the vessel.
-
std::vector<RoboticHinge> robotic_hinges()#
A list of all robotic hinges in the vessel.
-
std::vector<RoboticPiston> robotic_pistons()#
A list of all robotic pistons in the vessel.
-
std::vector<RoboticRotation> robotic_rotations()#
A list of all robotic rotations in the vessel.
-
std::vector<RoboticRotor> robotic_rotors()#
A list of all robotic rotors in the vessel.
-
std::vector<SolarPanel> solar_panels()#
A list of all solar panels in the vessel.
-
Part root()#
Part#
-
class Part#
Represents an individual part. Vessels are made up of multiple parts. Instances of this class can be obtained by several methods in
Parts.-
std::string name()#
Internal name of the part, as used in part cfg files. For example “Mark1-2Pod”.
-
std::string title()#
Title of the part, as shown when the part is right clicked in-game. For example “Mk1-2 Command Pod”.
-
ConfigNode config()#
The static configuration of the part, as found in its part cfg file. This provides access to data that is not exposed elsewhere, such as the configuration of the part’s modules. Returns
NULLif the part has no associated configuration node.
-
std::string tag()#
-
void set_tag(std::string value)#
The name tag for the part. Can be set to a custom string using the in-game user interface. Throws an exception if no name tag part module is installed.
Note
The name tag part module is provided by KSPCommunityPartModules 0.5 or later, or by kOS, which shares this string.
-
std::string flag_url()#
-
void set_flag_url(std::string value)#
The asset URL for the part’s flag.
-
bool highlighted()#
-
void set_highlighted(bool value)#
Whether the part is highlighted.
- Game Scenes:
Flight
Note
The highlighting is removed when the client that enabled it disconnects.
-
void set_highlight_color(StdLib::ColorRGB value)#
The color used to highlight the part.
- Game Scenes:
Flight
-
double cost()#
The cost of the part, in units of funds.
-
std::optional<Part> parent()#
The parts parent. Returns
NULLif the part does not have a parent. This, in combination withPart::children(), can be used to traverse the vessels parts tree.Note
See the discussion on Trees of Parts.
-
std::vector<Part> children()#
The parts children. Returns an empty list if the part has no children. This, in combination with
Part::parent(), can be used to traverse the vessels parts tree.Note
See the discussion on Trees of Parts.
-
bool axially_attached()#
Whether the part is axially attached to its parent, i.e. on the top or bottom of its parent. If the part has no parent, returns
false.Note
See the discussion on Attachment Modes.
-
bool radially_attached()#
Whether the part is radially attached to its parent, i.e. on the side of its parent. If the part has no parent, returns
false.Note
See the discussion on Attachment Modes.
-
int32_t stage()#
The stage in which this part will be activated. Returns -1 if the part is not activated by staging.
Note
See the discussion on Staging.
-
int32_t decouple_stage()#
The stage in which this part will be decoupled. Returns -1 if the part is never decoupled from the vessel.
Note
See the discussion on Staging.
-
double mass()#
The current mass of the part, including resources it contains, in kilograms. Returns zero if the part is massless.
-
double dry_mass()#
The mass of the part, not including any resources it contains, in kilograms. Returns zero if the part is massless.
-
bool shielded()#
Whether the part is shielded from the exterior of the vessel, for example by a fairing.
- Game Scenes:
Flight
-
float dynamic_pressure()#
The dynamic pressure acting on the part, in Pascals.
- Game Scenes:
Flight
-
float static_pressure()#
The static pressure acting on the part, in Pascals. Below the waterline this includes the pressure of the water.
- Game Scenes:
Flight
-
double displacement()#
The volume of water the part displaces when fully submerged, in \(m^3\).
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
See
Part::displaced_volume()for the volume it is displacing now.
-
float buoyancy_multiplier()#
The multiplier applied to the buoyant force on the part. One for most parts.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
double buoyant_force_at(double density, double gravity)#
The buoyant force on the part when fully submerged in a fluid of the given density, in Newtons.
- Parameters:
density – The density of the fluid, in \(kg/m^3\).
gravity – The acceleration due to gravity, in \(m/s^2\).
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
Applies
buoyancy_scalar()andPart::buoyancy_multiplier(), so the result is what the game would do to the part rather than what Archimedes’ principle alone gives.
-
bool splashed()#
Whether the part is in contact with water.
- Game Scenes:
Flight
-
double submerged_portion()#
The fraction of the part below the waterline, between 0 and 1.
- Game Scenes:
Flight
-
double displaced_volume()#
The volume of water the part is displacing, in \(m^3\).
- Game Scenes:
Flight
-
double depth()#
The depth of the part below the waterline, in meters, measured at
Part::center_of_displacement(). Negative above the waterline. Returns zero if the body the vessel is at has no ocean.- Game Scenes:
Flight
-
double min_depth()#
The depth of the shallowest point of the part below the waterline, in meters. Returns zero if the body the vessel is at has no ocean.
- Game Scenes:
Flight
-
double max_depth()#
The depth of the deepest point of the part below the waterline, in meters. Returns zero if the body the vessel is at has no ocean.
- Game Scenes:
Flight
Note
The game ramps the buoyant force in over the first fraction of a meter of this depth.
-
float submerged_dynamic_pressure()#
The dynamic pressure of the water acting on the part, in Pascals.
- Game Scenes:
Flight
-
double submerged_drag_multiplier()#
The multiplier applied to the drag on the part while it is submerged.
- Game Scenes:
Flight
Note
The game sets this high on splashdown and eases it down as the part moves through the water. It climbs back once the part slows to a crawl, so a hull under way reads lower than one lying still.
-
double submerged_lift_multiplier()#
The multiplier applied to the lift on the part while it is submerged.
- Game Scenes:
Flight
-
float water_angular_drag_multiplier()#
The multiplier applied to the angular drag on the part while it is submerged.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
Part of the part’s configuration rather than a live readout, so it reads the same in the editor and at a body with no ocean.
-
double impact_tolerance()#
The impact tolerance of the part, in meters per second.
-
double temperature()#
Temperature of the part, in Kelvin.
- Game Scenes:
Flight
-
double skin_temperature()#
Temperature of the skin of the part, in Kelvin.
- Game Scenes:
Flight
-
double max_temperature()#
Maximum temperature that the part can survive, in Kelvin.
-
double max_skin_temperature()#
Maximum temperature that the skin of the part can survive, in Kelvin.
-
double max_pressure()#
Maximum pressure that the part can survive, in Pascals.
Note
With part pressure limits enabled in the difficulty settings, the part is destroyed when
Part::static_pressure()plusPart::dynamic_pressure()exceeds this.
-
float thermal_mass()#
A measure of how much energy it takes to increase the internal temperature of the part, in Joules per Kelvin.
- Game Scenes:
Flight
-
float thermal_skin_mass()#
A measure of how much energy it takes to increase the skin temperature of the part, in Joules per Kelvin.
- Game Scenes:
Flight
-
float thermal_resource_mass()#
A measure of how much energy it takes to increase the temperature of the resources contained in the part, in Joules per Kelvin.
- Game Scenes:
Flight
-
float thermal_conduction_flux()#
The rate at which heat energy is conducting into or out of the part via contact with other parts. Measured in energy per unit time, or power, in Watts. A positive value means the part is gaining heat energy, and negative means it is losing heat energy.
- Game Scenes:
Flight
-
float thermal_convection_flux()#
The rate at which heat energy is convecting into or out of the part from the surrounding atmosphere. Measured in energy per unit time, or power, in Watts. A positive value means the part is gaining heat energy, and negative means it is losing heat energy.
- Game Scenes:
Flight
-
float thermal_radiation_flux()#
The rate at which heat energy is radiating into or out of the part from the surrounding environment. Measured in energy per unit time, or power, in Watts. A positive value means the part is gaining heat energy, and negative means it is losing heat energy.
- Game Scenes:
Flight
-
float thermal_internal_flux()#
The rate at which heat energy is begin generated by the part. For example, some engines generate heat by combusting fuel. Measured in energy per unit time, or power, in Watts. A positive value means the part is gaining heat energy, and negative means it is losing heat energy.
- Game Scenes:
Flight
-
float thermal_skin_to_internal_flux()#
The rate at which heat energy is transferring between the part’s skin and its internals. Measured in energy per unit time, or power, in Watts. A positive value means the part’s internals are gaining heat energy, and negative means its skin is gaining heat energy.
- Game Scenes:
Flight
-
int32_t crew_capacity()#
The number of crew members that can occupy the part.
-
std::vector<CrewMember> crew()#
The crew members occupying the part.
- Game Scenes:
Flight
-
uint32_t available_seats()#
How many open seats the part has.
- Game Scenes:
Flight
-
Resources resources()#
A
Part::resources()object for the part.
-
bool crossfeed()#
Whether this part is crossfeed capable.
-
bool is_fuel_line()#
Whether this part is a fuel line.
-
std::vector<Part> fuel_lines_from()#
The parts that are connected to this part via fuel lines, where the direction of the fuel line is into this part.
- Game Scenes:
Flight
Note
See the discussion on Fuel Lines.
-
std::vector<Part> fuel_lines_to()#
The parts that are connected to this part via fuel lines, where the direction of the fuel line is out of this part.
- Game Scenes:
Flight
Note
See the discussion on Fuel Lines.
-
std::optional<Antenna> antenna()#
An
Part::antenna()if the part is an antenna, otherwiseNULL.Note
If RemoteTech is installed, this will always return
NULL. To interact with RemoteTech antennas, use the RemoteTech service APIs.
-
std::optional<CargoBay> cargo_bay()#
A
Part::cargo_bay()if the part is a cargo bay, otherwiseNULL.
-
std::optional<ControlSurface> control_surface()#
A
Part::control_surface()if the part is an aerodynamic control surface, otherwiseNULL.
-
std::optional<Decoupler> decoupler()#
A
Part::decoupler()if the part is a decoupler, otherwiseNULL.
-
std::optional<DockingPort> docking_port()#
A
Part::docking_port()if the part is a docking port, otherwiseNULL.
-
std::optional<Engine> engine()#
An
Part::engine()if the part is an engine, otherwiseNULL.
-
std::optional<Experiment> experiment()#
An
Part::experiment()if the part contains a single science experiment, otherwiseNULL.Note
Throws an exception if the part contains more than one experiment. In that case, use
Part::experiments()to get the list of experiments in the part.
-
std::optional<std::vector<Experiment>> experiments()#
A list of
Part::experiment()objects that the part contains.
-
std::optional<Fairing> fairing()#
A
Part::fairing()if the part is a fairing, otherwiseNULL.
-
std::optional<Intake> intake()#
An
Part::intake()if the part is an intake, otherwiseNULL.Note
This includes any part that generates thrust. This covers many different types of engine, including liquid fuel rockets, solid rocket boosters and jet engines. For RCS thrusters see
Part::rcs().
-
std::optional<Leg> leg()#
A
Part::leg()if the part is a landing leg, otherwiseNULL.
-
std::optional<LaunchClamp> launch_clamp()#
A
Part::launch_clamp()if the part is a launch clamp, otherwiseNULL.
-
std::optional<Light> light()#
A
Part::light()if the part is a light, otherwiseNULL.
-
std::optional<Parachute> parachute()#
A
Part::parachute()if the part is a parachute, otherwiseNULL.
-
std::optional<Radiator> radiator()#
A
Part::radiator()if the part is a radiator, otherwiseNULL.
-
std::optional<ResourceDrain> resource_drain()#
A
Part::resource_drain()if the part is a resource drain, otherwiseNULL.
-
std::optional<RCS> rcs()#
A
Part::rcs()if the part is an RCS block/thruster, otherwiseNULL.
-
std::optional<ReactionWheel> reaction_wheel()#
A
Part::reaction_wheel()if the part is a reaction wheel, otherwiseNULL.
-
std::optional<ResourceConverter> resource_converter()#
A
Part::resource_converter()if the part is a resource converter, otherwiseNULL.
-
std::optional<ResourceHarvester> resource_harvester()#
A
Part::resource_harvester()if the part is a resource harvester, otherwiseNULL.
-
std::optional<RoboticController> robotic_controller()#
A
Part::robotic_controller()if the part is a robotic controller, otherwiseNULL.
-
std::optional<RoboticHinge> robotic_hinge()#
A
Part::robotic_hinge()if the part is a robotic hinge, otherwiseNULL.
-
std::optional<RoboticPiston> robotic_piston()#
A
Part::robotic_piston()if the part is a robotic piston, otherwiseNULL.
-
std::optional<RoboticRotation> robotic_rotation()#
A
Part::robotic_rotation()if the part is a robotic rotation servo, otherwiseNULL.
-
std::optional<RoboticRotor> robotic_rotor()#
A
Part::robotic_rotor()if the part is a robotic rotor, otherwiseNULL.
-
std::optional<Sensor> sensor()#
A
Part::sensor()if the part is a sensor, otherwiseNULL.
-
std::optional<SolarPanel> solar_panel()#
A
Part::solar_panel()if the part is a solar panel, otherwiseNULL.
-
std::optional<Wheel> wheel()#
A
Part::wheel()if the part is a wheel, otherwiseNULL.
-
std::tuple<double, double, double> position(ReferenceFrame reference_frame)#
The position of the part in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
This is a fixed position in the part, defined by the parts model. It s not necessarily the same as the parts center of mass. Use
Part::center_of_mass()to get the parts center of mass.
-
std::tuple<double, double, double> center_of_mass(ReferenceFrame reference_frame)#
The position of the parts center of mass in the given reference frame. If the part is physicsless in flight, this is equivalent to
Part::position().- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
BoundingBox bounding_box(ReferenceFrame reference_frame)#
The axis-aligned bounding box of the part in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned position vectors are in.
- Returns:
The positions of the minimum and maximum vertices of the box.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
This is computed from the meshes that make up the parts model, and covers only this part - the models of any child parts are excluded. If the part has no visible model, the box has zero volume and is centered on the
Part::center_of_mass()of the part.
-
std::tuple<double, double, double> direction(ReferenceFrame reference_frame)#
The direction the part points in, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned direction is in.
- Returns:
The direction as a unit vector.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::tuple<double, double, double> velocity(ReferenceFrame reference_frame)#
The linear velocity of the part in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned velocity vector is in.
- Returns:
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.
- Game Scenes:
Flight
-
std::tuple<double, double, double, double> rotation(ReferenceFrame reference_frame)#
The rotation of the part, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned rotation is in.
- Returns:
The rotation as a quaternion of the form \((x, y, z, w)\).
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::tuple<double, double, double> lift(ReferenceFrame reference_frame)#
The aerodynamic lift currently acting on the part.
- Parameters:
reference_frame – The reference frame that the returned vector is in.
- Returns:
A vector pointing in the direction that the force acts, with its magnitude equal to the strength of the force in Newtons.
- Game Scenes:
Flight
Note
Not available when the Ferram Aerospace Research mod is installed.
-
std::tuple<double, double, double> drag(ReferenceFrame reference_frame)#
The aerodynamic drag currently acting on the part.
- Parameters:
reference_frame – The reference frame that the returned vector is in.
- Returns:
A vector pointing in the direction that the force acts, with its magnitude equal to the strength of the force in Newtons.
- Game Scenes:
Flight
Note
Not available when the Ferram Aerospace Research mod is installed.
-
std::tuple<double, double, double> center_of_buoyancy(ReferenceFrame reference_frame)#
The point the buoyant force on the part acts at, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
A submerged part reports the point the game applied the force at, which it shifts towards the submerged part of the hull. Any other part reports its configured center of buoyancy.
-
std::tuple<double, double, double> center_of_displacement(ReferenceFrame reference_frame)#
The point the depth of the part is measured at, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::tuple<double, double, double> buoyant_force(ReferenceFrame reference_frame)#
The buoyant force currently acting on the part.
- Parameters:
reference_frame – The reference frame that the returned vector is in.
- Returns:
A vector pointing in the direction that the force acts, with its magnitude equal to the strength of the force in Newtons.
- Game Scenes:
Flight
Note
The buoyant force on its own. The water drag and lift the game applies alongside it are reported by
Part::submerged_drag_multiplier()andPart::submerged_lift_multiplier().
-
std::tuple<double, double, double> moment_of_inertia()#
The moment of inertia of the part in \(kg.m^2\) around its center of mass in the parts center of mass reference frame (
Part::center_of_mass_reference_frame()).- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::vector<double> inertia_tensor()#
The inertia tensor of the part around its center of mass, in the parts center of mass reference frame (
Part::center_of_mass_reference_frame()). Returns the 3x3 matrix as a list of elements, in row-major order.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
ReferenceFrame reference_frame()#
The reference frame that is fixed relative to this part, and centered on a fixed position within the part, defined by the parts model.
The origin is at the position of the part, as returned by
Part::position().The axes rotate with the part.
The x, y and z axis directions depend on the design of the part.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
For docking port parts, this reference frame is not necessarily equivalent to the reference frame for the docking port, returned by
DockingPort::reference_frame().
Mk1 Command Pod reference frame origin and axes#
-
ReferenceFrame center_of_mass_reference_frame()#
The reference frame that is fixed relative to this part, and centered on its center of mass.
The origin is at the center of mass of the part, as returned by
Part::center_of_mass().The axes rotate with the part.
The x, y and z axis directions depend on the design of the part.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
For docking port parts, this reference frame is not necessarily equivalent to the reference frame for the docking port, returned by
DockingPort::reference_frame().
-
Force add_force(std::tuple<double, double, double> force, std::tuple<double, double, double> position, ReferenceFrame reference_frame)#
Warning
Deprecated. Use
Debug.AddForceinstead.Exert a constant force on the part, acting at the given position.
- Parameters:
force – A vector pointing in the direction that the force acts, with its magnitude equal to the strength of the force in Newtons.
position – The position at which the force acts, as a vector.
reference_frame – The reference frame that the force and position are in.
- Returns:
An object that can be used to remove or modify the force.
- Game Scenes:
Flight
Note
The force is removed when the client that added it disconnects.
-
void instantaneous_force(std::tuple<double, double, double> force, std::tuple<double, double, double> position, ReferenceFrame reference_frame)#
Warning
Deprecated. Use
Debug.InstantaneousForceinstead.Exert an instantaneous force on the part, acting at the given position.
- Parameters:
force – A vector pointing in the direction that the force acts, with its magnitude equal to the strength of the force in Newtons.
position – The position at which the force acts, as a vector.
reference_frame – The reference frame that the force and position are in.
- Game Scenes:
Flight
Note
The force is applied instantaneously in a single physics update.
-
void set_glow(bool value)#
Whether the part is glowing.
- Game Scenes:
Flight
-
AutoStrutMode auto_strut_mode()#
Auto-strut mode.
-
bool has_real_fuels_tank()#
Whether the part is a fuel tank managed by RealFuels. The remaining properties in this section are only available when it is.
-
bool highly_pressurized()#
Whether the tank is highly pressurized, which is what a pressure-fed engine needs to draw from (see
Engine::pressure_fed()). Throws an exception if the part is not a RealFuels fuel tank (seePart::has_real_fuels_tank()).
-
double boiloff_rate()#
The rate at which the tank’s cryogenic contents are boiling off, in kilograms per second of in-game time, measured over the last update RealFuels computed it in. The contents keep boiling off under time warp, where that update covers a much longer span of in-game time than a physics frame does. The rate is zero for a tank holding nothing cryogenic, for one still being fed by a launch clamp, whose temperature RealFuels holds down instead, and in the editor. Throws an exception if the part is not a RealFuels fuel tank (see
Part::has_real_fuels_tank()).
-
std::string name()#
-
enum struct AutoStrutMode#
The state of an auto-strut.
Part::auto_strut_mode()-
enumerator off#
Off
-
enumerator root#
Root
-
enumerator heaviest#
Heaviest
-
enumerator grandparent#
Grandparent
-
enumerator force_root#
ForceRoot
-
enumerator force_heaviest#
ForceHeaviest
-
enumerator force_grandparent#
ForceGrandparent
-
enumerator off#
-
class Force#
Obtained by calling
Debug.AddForce.-
std::tuple<double, double, double> force_vector()#
-
void set_force_vector(std::tuple<double, double, double> value)#
The force vector, in Newtons.
- Returns:
A vector pointing in the direction that the force acts, with its magnitude equal to the strength of the force in Newtons.
- Game Scenes:
Flight
-
std::tuple<double, double, double> position()#
-
void set_position(std::tuple<double, double, double> value)#
The position at which the force acts, in reference frame
Force::reference_frame().- Returns:
The position as a vector.
- Game Scenes:
Flight
-
ReferenceFrame reference_frame()#
-
void set_reference_frame(ReferenceFrame value)#
The reference frame of the force vector and position.
- Game Scenes:
Flight
-
void remove()#
Remove the force.
- Game Scenes:
Flight
Note
Any further use of this object throws an exception.
-
std::tuple<double, double, double> force_vector()#
Module#
-
class Module#
This can be used to interact with a specific part module. This includes part modules in stock KSP, and those added by mods.
In KSP, each part has zero or more PartModules associated with it. Each one contains some of the functionality of the part. For example, an engine has a “ModuleEngines” part module that contains all the functionality of an engine.
-
std::string name()#
Name of the PartModule. For example, “ModuleEngines”.
-
ConfigNode config()#
The static configuration of the module, as found in the part’s cfg file. This provides access to data that is not exposed as a field, such as the resources produced by a generator. Returns
NULLif the module’s configuration node cannot be found.
-
std::vector<PartField> field_list()#
A list of all the fields of the module, including those not visible in the right-click menu of the part. Filter by
PartField::visible()to get just the visible ones.
-
std::vector<PartEvent> event_list()#
A list of all the events of the module, including those not currently visible or active. Events are the clickable buttons visible in the right-click menu of the part. Filter by
PartEvent::visible()andPartEvent::active()to get just the ones shown in the menu.
-
std::vector<PartAction> action_list()#
A list of all the actions of the module. These are the parts actions that can be assigned to action groups in the in-game editor.
-
std::string name()#
-
class PartField#
A field of a part module. Obtained by calling
Module::field_list().-
std::string name()#
The identifier of the field. This is stable and does not change between game versions, unlike
PartField::gui_name().
-
std::string gui_name()#
The name of the field, as displayed in the right-click menu of the part. This may be empty for fields that are not visible in the menu.
-
bool visible()#
Whether the field is visible in the right-click menu of the part, in the current scene (flight or editor).
-
std::string value()#
-
void set_value(std::string value)#
The value of the field, as a string. This works for fields of any type, and returns the same string that is shown in the right-click menu of the part.
Note
Setting the value using this property is only permitted for string fields. Use the typed properties (
PartField::bool_value(),PartField::int_value(),PartField::float_value(),PartField::double_value()) to set fields of other types.
-
bool bool_value()#
-
void set_bool_value(bool value)#
The value of a boolean field.
Note
The getter throws an exception if the field is not a boolean field (see
PartField::type()).
-
int32_t int_value()#
-
void set_int_value(int32_t value)#
The value of an integer field.
Note
The getter throws an exception if the field is not an integer field (see
PartField::type()).
-
float float_value()#
-
void set_float_value(float value)#
The value of a single precision floating point field.
Note
The getter throws an exception if the field is not a single precision floating point field (see
PartField::type()).
-
double double_value()#
-
void set_double_value(double value)#
The value of a double precision floating point field.
Note
The getter throws an exception if the field is not a double precision floating point field (see
PartField::type()).
-
void reset()#
Set the value of the field to its original value.
Note
The original value is the value the field had when the part was loaded. Works for any field, including those not visible in the right-click menu.
-
std::string name()#
-
enum struct FieldType#
The type of a part module field. See
PartField::type().-
enumerator boolean#
A boolean field. Access using
PartField::bool_value().
-
enumerator integer#
An integer field. Access using
PartField::int_value().
-
enumerator float_#
A single precision floating point field. Access using
PartField::float_value().
-
enumerator double_#
A double precision floating point field. Access using
PartField::double_value().
-
enumerator string#
A string field. Access using
PartField::value().
-
enumerator unknown#
A field whose type is not one of the above. Its value can still be read as a string using
PartField::value().
-
enumerator boolean#
-
class PartEvent#
An event of a part module. Events are the clickable buttons visible in the right-click menu of the part. Obtained by calling
Module::event_list().-
std::string name()#
The identifier of the event. This is stable and does not change between game versions, unlike
PartEvent::gui_name().
-
std::string gui_name()#
The name of the event, as displayed in the right-click menu of the part.
-
bool visible()#
Whether the event is visible in the right-click menu of the part, in the current scene (flight or editor).
-
bool active()#
Whether the event is currently active.
-
void trigger()#
Trigger the event. Equivalent to clicking the button in the right-click menu of the part.
-
std::string name()#
-
class PartAction#
An action of a part module. These are the part actions that can be assigned to action groups in the in-game editor. Obtained by calling
Module::action_list().-
std::string name()#
The identifier of the action. This is stable and does not change between game versions, unlike
PartAction::gui_name().
-
std::string gui_name()#
The name of the action, as displayed in the in-game editor.
-
void set_activated(bool value)#
Activate or deactivate the action. Equivalent to triggering the action from an action group. Set to
trueto activate the action, orfalseto deactivate it.
-
std::string name()#
Config Node#
-
class ConfigNode#
Represents a configuration node, as found in a part’s configuration file. A node has a name, a set of named values and a set of child nodes. This is used to access the static configuration of a part or part module, for example via
Part::config()andModule::config().-
std::string name()#
The name of the configuration node. For example “MODULE”.
-
std::map<std::string, std::string> values()#
The values stored in the node, as a dictionary mapping names to values.
Note
If a name appears more than once, only the first value is included. Use
ConfigNode::get_values()to get all of the values with a given name.
-
bool has_value(std::string name)#
Returns
trueif the node has a value with the given name.- Parameters:
name – Name of the value.
-
std::string get_value(std::string name)#
Returns the value with the given name. If there is more than one value with the given name, the first is returned. Throws an exception if there is no value with the given name.
- Parameters:
name – Name of the value.
-
std::vector<std::string> get_values(std::string name)#
Returns all of the values with the given name, as a list.
- Parameters:
name – Name of the values.
-
std::vector<ConfigNode> nodes()#
The child nodes contained in this node.
-
bool has_node(std::string name)#
Returns
trueif the node has a child node with the given name.- Parameters:
name – Name of the child node.
-
ConfigNode get_node(std::string name)#
Returns the child node with the given name. If there is more than one child node with the given name, the first is returned. Throws an exception if there is no child node with the given name.
- Parameters:
name – Name of the child node.
-
std::vector<ConfigNode> get_nodes(std::string name)#
Returns all of the child nodes with the given name, as a list.
- Parameters:
name – Name of the child nodes.
-
std::string name()#
Specific Types of Part#
The following classes provide functionality for specific types of part.
Antenna#
Note
If RemoteTech is installed, use the RemoteTech service APIs to interact with antennas. This class is only for stock KSP antennas.
-
class Antenna#
An antenna. Obtained by calling
Part::antenna().-
DeployableState state()#
The current state of the antenna.
- Game Scenes:
Flight
-
bool deployable()#
Whether the antenna is deployable.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool deployed()#
-
void set_deployed(bool value)#
Whether the antenna is deployed.
- Game Scenes:
Flight
Note
Fixed antennas are always deployed. Returns an error if you try to deploy a fixed antenna.
-
bool can_transmit()#
Whether data can be transmitted by this antenna.
- Game Scenes:
Flight
-
void transmit()#
Transmit data.
- Game Scenes:
Flight
-
void cancel()#
Cancel current transmission of data.
- Game Scenes:
Flight
-
bool allow_partial()#
-
void set_allow_partial(bool value)#
Whether partial data transmission is permitted.
- Game Scenes:
Flight
-
double power()#
The power of the antenna.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool combinable()#
Whether the antenna can be combined with other antennae on the vessel to boost the power.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
double combinable_exponent()#
Exponent used to calculate the combined power of multiple antennae on a vessel.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float packet_interval()#
Interval between sending packets in seconds.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float packet_size()#
Amount of data sent per packet in Mits.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
double packet_resource_cost()#
Units of electric charge consumed per packet sent.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
DeployableState state()#
Cargo Bay#
-
class CargoBay#
A cargo bay. Obtained by calling
Part::cargo_bay().-
DeployableState state()#
The state of the cargo bay.
- Game Scenes:
Flight
Note
This describes where the bay’s doors are, which is not the same as whether the parts inside are sheltered: a bay whose open end has nothing attached to it never shelters anything, however tightly shut it is. Use
Part::shielded()for that.A cargo bay is never
DeployableState::broken, as the game does not track damage for them.
-
bool open()#
-
void set_open(bool value)#
Whether the cargo bay is open.
- Game Scenes:
Flight
-
DeployableState state()#
Control Surface#
-
class ControlSurface#
An aerodynamic control surface. Obtained by calling
Part::control_surface().-
bool pitch_enabled()#
-
void set_pitch_enabled(bool value)#
Whether the control surface has pitch control enabled.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool yaw_enabled()#
-
void set_yaw_enabled(bool value)#
Whether the control surface has yaw control enabled.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool roll_enabled()#
-
void set_roll_enabled(bool value)#
Whether the control surface has roll control enabled.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float authority_limiter()#
-
void set_authority_limiter(float value)#
The authority limiter for the control surface, which controls how far the control surface will move.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool inverted()#
-
void set_inverted(bool value)#
Whether the control surface movement is inverted.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool deployed()#
-
void set_deployed(bool value)#
Whether the control surface has been fully deployed. Throws an exception if set while
ControlSurface::deflection_override()is enabled, which holds the surface deployed.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float deploy_angle()#
-
void set_deploy_angle(float value)#
The deploy angle of the control surface, in degrees.
- Game Scenes:
Flight, Editor Vab, Editor Sph
Note
Applied when
ControlSurface::deployed()is true, and clamped to the range given byControlSurface::min_deploy_angle()andControlSurface::max_deploy_angle(). WhileControlSurface::deflection_override()is enabled,ControlSurface::deflection()drives the angle. A value set here takes effect when the override is released.
-
float min_deploy_angle()#
The minimum
ControlSurface::deploy_angle()of the control surface, in degrees.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float max_deploy_angle()#
The maximum
ControlSurface::deploy_angle()of the control surface, in degrees.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool deflection_override()#
-
void set_deflection_override(bool value)#
Whether the control surface deflection is being set directly, bypassing the vessel’s normal flight control. When enabled, the surface holds the deflection set by
ControlSurface::deflection()instead of responding to pitch, yaw and roll control inputs. The prior state is restored when the override is released, when the controlling client disconnects, or when the vessel changes.- Game Scenes:
Flight
-
float deflection()#
-
void set_deflection(float value)#
The deflection command applied when
ControlSurface::deflection_override()is enabled, as a value between -1 and 1, mapped onto the surface’s deploy angle range.- Game Scenes:
Flight
-
float surface_area()#
Surface area of the control surface in \(m^2\).
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
AxisRange available_torque()#
The available torque, in Newton meters, that can be produced by this control surface, in the positive and negative pitch, roll and yaw axes of the vessel. These axes correspond to the coordinate axes of the
Vessel::reference_frame().- Game Scenes:
Flight
-
bool pitch_enabled()#
Decoupler#
-
class Decoupler#
A decoupler. Obtained by calling
Part::decoupler()-
Vessel decouple()#
Fires the decoupler. Returns the new vessel created when the decoupler fires. Throws an exception if the decoupler has already fired.
- Game Scenes:
Flight
Note
When called, the active vessel may change. It is therefore possible that, after calling this function, the object(s) returned by previous call(s) to
active_vessel()no longer refer to the active vessel.
-
bool decoupled()#
Whether the decoupler has fired.
- Game Scenes:
Flight
-
bool staged()#
Whether the decoupler is enabled in the staging sequence.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float impulse()#
The impulse that the decoupler imparts when it is fired, in Newton seconds.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool is_omni_decoupler()#
Whether the decoupler is an omni-decoupler (e.g. stack separator)
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
Vessel decouple()#
Deployable State#
The deployment state shared by antennas, cargo bays, landing legs, radiators, resource harvesters, solar panels and wheels.
-
enum struct DeployableState#
The state of a deployable part.
Antenna::state(),CargoBay::state(),Leg::state(),Radiator::state(),ResourceHarvester::state(),SolarPanel::state(),Wheel::state()-
enumerator deployed#
The part is fully deployed. A cargo bay in this state is fully open. Parts that cannot be retracted, such as fixed radiators, solar panels, antennas, landing legs and wheels, are always in this state.
-
enumerator retracted#
The part is fully retracted. A cargo bay in this state is closed and locked.
-
enumerator deploying#
The part is being deployed. A cargo bay in this state is opening.
-
enumerator retracting#
The part is being retracted. A cargo bay in this state is closing.
-
enumerator broken#
The part is broken. Cargo bays and resource harvesters never report this state, as the game does not track damage for them.
-
enumerator deployed#
Docking Port#
-
class DockingPort#
A docking port. Obtained by calling
Part::docking_port()-
DockingPortState state()#
The current state of the docking port.
- Game Scenes:
Flight
-
std::optional<Part> docked_part()#
The part that this docking port is docked to. Returns
NULLif this docking port is not docked to anything.- Game Scenes:
Flight
-
Vessel undock()#
Undocks the docking port and returns the new
Vesselthat is created. This method can be called for either docking port in a docked pair. Throws an exception if the docking port is not docked to anything.- Game Scenes:
Flight
Note
When called, the active vessel may change. It is therefore possible that, after calling this function, the object(s) returned by previous call(s) to
active_vessel()no longer refer to the active vessel.
-
float reengage_distance()#
The distance a docking port must move away when it undocks before it becomes ready to dock with another port, in meters.
- Game Scenes:
Flight
-
bool has_shield()#
Whether the docking port has a shield.
- Game Scenes:
Flight
-
bool shielded()#
-
void set_shielded(bool value)#
The state of the docking ports shield, if it has one.
Returns
trueif the docking port has a shield, and the shield is closed. Otherwise returnsfalse. When set totrue, the shield is closed, and when set tofalsethe shield is opened. If the docking port does not have a shield, setting this attribute has no effect.- Game Scenes:
Flight
-
bool can_rotate()#
Whether the docking port can be commanded to rotate while docked.
- Game Scenes:
Flight
-
float maximum_rotation()#
Maximum rotation angle in degrees.
- Game Scenes:
Flight
-
float minimum_rotation()#
Minimum rotation angle in degrees.
- Game Scenes:
Flight
-
float rotation_target()#
-
void set_rotation_target(float value)#
Rotation target angle in degrees.
- Game Scenes:
Flight
-
bool rotation_locked()#
-
void set_rotation_locked(bool value)#
Lock rotation. When locked, allows auto-strut to work across the joint.
- Game Scenes:
Flight
-
std::tuple<double, double, double> position(ReferenceFrame reference_frame)#
The position of the docking port, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight
-
std::tuple<double, double, double> direction(ReferenceFrame reference_frame)#
The direction that docking port points in, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned direction is in.
- Returns:
The direction as a unit vector.
- Game Scenes:
Flight
-
std::tuple<double, double, double, double> rotation(ReferenceFrame reference_frame)#
The rotation of the docking port, in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned rotation is in.
- Returns:
The rotation as a quaternion of the form \((x, y, z, w)\).
- Game Scenes:
Flight
-
ReferenceFrame reference_frame()#
The reference frame that is fixed relative to this docking port, and oriented with the port.
The origin is at the position of the docking port.
The axes rotate with the docking port.
The x-axis points out to the right side of the docking port.
The y-axis points in the direction the docking port is facing.
The z-axis points out of the bottom off the docking port.
- Game Scenes:
Flight
Note
This reference frame is not necessarily equivalent to the reference frame for the part, returned by
Part::reference_frame().
Docking port reference frame origin and axes#
Inline docking port reference frame origin and axes#
-
DockingPortState state()#
-
enum struct DockingPortState#
The state of a docking port. See
DockingPort::state().-
enumerator ready#
The docking port is ready to dock to another docking port.
-
enumerator docked#
The docking port is docked to another docking port, or docked to another part (from the VAB/SPH).
-
enumerator docking#
The docking port is very close to another docking port, but has not docked. It is using magnetic force to acquire a solid dock.
-
enumerator undocking#
The docking port has just been undocked from another docking port, and is disabled until it moves away by a sufficient distance (
DockingPort::reengage_distance()).
-
enumerator shielded#
The docking port has a shield, and the shield is closed.
-
enumerator moving#
The docking ports shield is currently opening/closing.
-
enumerator ready#
Engine#
-
class Engine#
An engine, including ones of various types. For example liquid fuelled gimballed engines, solid rocket boosters and jet engines. Obtained by calling
Part::engine().Note
For RCS thrusters
Part::rcs().-
bool active()#
-
void set_active(bool value)#
Whether the engine is active. Setting this attribute may have no effect, depending on
Engine::can_shutdown()andEngine::can_restart().- Game Scenes:
Flight
-
float thrust()#
The current amount of thrust being produced by the engine, in Newtons.
- Game Scenes:
Flight
-
float available_thrust()#
The amount of thrust, in Newtons, that would be produced by the engine when activated and with its throttle set to 100%. Returns zero if the engine does not have any fuel. Takes the engine’s current
Engine::thrust_limit()and atmospheric conditions into account.- Game Scenes:
Flight
-
float available_thrust_at(double pressure)#
The amount of thrust, in Newtons, that would be produced by the engine when activated and with its throttle set to 100%. Returns zero if the engine does not have any fuel. Takes the given pressure into account.
- Parameters:
pressure – Atmospheric pressure in atmospheres
- Game Scenes:
Flight
-
float max_thrust()#
The amount of thrust, in Newtons, that would be produced by the engine when activated and fueled, with its throttle and throttle limiter set to 100%.
- Game Scenes:
Flight
-
float max_thrust_at(double pressure)#
The amount of thrust, in Newtons, that would be produced by the engine when activated and fueled, with its throttle and throttle limiter set to 100%. Takes the given pressure into account.
- Parameters:
pressure – Atmospheric pressure in atmospheres
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float max_vacuum_thrust()#
The maximum amount of thrust that can be produced by the engine in a vacuum, in Newtons. This is the amount of thrust produced by the engine when activated,
Engine::thrust_limit()is set to 100%, the main vessel’s throttle is set to 100% and the engine is in a vacuum.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float thrust_limit()#
-
void set_thrust_limit(float value)#
The thrust limiter of the engine. A value between 0 and 1. Setting this attribute may have no effect, for example the thrust limit for a solid rocket booster cannot be changed in flight.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::vector<Thruster> thrusters()#
The components of the engine that generate thrust.
- Game Scenes:
Flight
Note
For example, this corresponds to the rocket nozzel on a solid rocket booster, or the individual nozzels on a RAPIER engine. The overall thrust produced by the engine, as reported by
Engine::available_thrust(),Engine::max_thrust()and others, is the sum of the thrust generated by each thruster.
-
float specific_impulse()#
The current specific impulse of the engine, in seconds. Returns zero if the engine is not active.
- Game Scenes:
Flight
-
float specific_impulse_at(double pressure)#
The specific impulse of the engine under the given pressure, in seconds. Returns zero if the engine is not active.
- Parameters:
pressure – Atmospheric pressure in atmospheres
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float vacuum_specific_impulse()#
The vacuum specific impulse of the engine, in seconds.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float kerbin_sea_level_specific_impulse()#
The specific impulse of the engine at sea level on Kerbin, in seconds.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::vector<std::string> propellant_names()#
The names of the propellants that the engine consumes.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::map<std::string, float> propellant_ratios()#
The ratio of resources that the engine consumes. A dictionary mapping resource names to the ratio at which they are consumed by the engine.
- Game Scenes:
Flight
Note
For example, if the ratios are 0.6 for LiquidFuel and 0.4 for Oxidizer, then for every 0.6 units of LiquidFuel that the engine burns, it will burn 0.4 units of Oxidizer.
-
std::vector<Propellant> propellants()#
The propellants that the engine consumes.
- Game Scenes:
Flight
-
bool has_fuel()#
Whether the engine has any fuel available.
- Game Scenes:
Flight
-
bool flameout()#
Whether the engine has flamed out - it is active but has run out of propellant, so it is producing no thrust. This is the signal a client can use to decide when to activate the next stage. Note that on a vessel with drop tanks or asparagus staging some engines can flame out while others keep burning.
- Game Scenes:
Flight
-
float throttle()#
-
void set_throttle(float value)#
The current throttle setting for the engine. A value between 0 and 1. This is not necessarily the same as the vessel’s main throttle setting, as some engines take time to adjust their throttle (such as jet engines), or independent throttle may be enabled.
When the engine’s independent throttle is enabled (see
Engine::independent_throttle()), can be used to set the throttle percentage.- Game Scenes:
Flight
-
bool throttle_locked()#
Whether the
Control::throttle()affects the engine. For example, this istruefor liquid fueled rockets, andfalsefor solid rocket boosters.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool independent_throttle()#
-
void set_independent_throttle(bool value)#
Whether the independent throttle is enabled for the engine.
- Game Scenes:
Flight
-
bool can_restart()#
Whether the engine can be restarted once shutdown. If the engine cannot be shutdown, returns
false. For example, this istruefor liquid fueled rockets andfalsefor solid rocket boosters.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool can_shutdown()#
Whether the engine can be shutdown once activated. For example, this is
truefor liquid fueled rockets andfalsefor solid rocket boosters.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool has_modes()#
Whether the engine has multiple modes of operation.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::string mode()#
-
void set_mode(std::string value)#
The name of the current engine mode.
- Game Scenes:
Flight
-
std::map<std::string, Engine> modes()#
The available modes for the engine. A dictionary mapping mode names to
Engineobjects.- Game Scenes:
Flight
-
void toggle_mode()#
Toggle the current engine mode.
- Game Scenes:
Flight
-
bool auto_mode_switch()#
-
void set_auto_mode_switch(bool value)#
Whether the engine will automatically switch modes.
- Game Scenes:
Flight
-
bool gimballed()#
Whether the engine is gimballed.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float gimbal_range()#
The range over which the gimbal can move, in degrees. Returns 0 if the engine is not gimballed.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool gimbal_locked()#
-
void set_gimbal_locked(bool value)#
Whether the engines gimbal is locked in place. Setting this attribute has no effect if the engine is not gimballed.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float gimbal_limit()#
-
void set_gimbal_limit(float value)#
The gimbal limiter of the engine. A value between 0 and 1. Returns 0 if the gimbal is locked.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool gimbal_override()#
-
void set_gimbal_override(bool value)#
Whether the gimbal is being controlled directly, bypassing the vessel’s normal flight controls. When enabled, the gimbal deflection is set by
Engine::gimbal_actuation()instead of the normal control inputs. The override is automatically released if the controlling client disconnects or the vessel changes. Has no effect if the engine is not gimballed.- Game Scenes:
Flight
-
std::tuple<double, double, double> gimbal_actuation()#
-
void set_gimbal_actuation(std::tuple<double, double, double> value)#
The gimbal actuation command applied when
Engine::gimbal_override()is enabled, in the pitch, roll and yaw axes. Each component is a normalized control input between -1 and 1. The physical deflection is scaled byEngine::gimbal_range()andEngine::gimbal_limit(). When the gimbal is not being overridden, returns the current actuation.- Game Scenes:
Flight
-
AxisRange available_torque()#
The available torque, in Newton meters, that can be produced by this engine, in the positive and negative pitch, roll and yaw axes of the vessel. These axes correspond to the coordinate axes of the
Vessel::reference_frame(). Returns zero if the engine is inactive, or not gimballed.- Game Scenes:
Flight
-
bool can_reverse_thrust()#
Whether the engine has a recognized thrust reverser. This is
truefor stock engines with a thrust reverser (such as the J-33 “Wheesley” and J-90 “Goliath” turbofan engines) and for selected mod engines. It isfalsefor engines whose reverser is not recognized, as KSP provides no standard way to detect one.- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool thrust_reversed()#
-
void set_thrust_reversed(bool value)#
Whether the engine’s thrust reverser is engaged, reversing the direction of thrust. While the reverser is still moving, this reports the state it is moving to, so a read immediately after a set returns the value that was set and setting the same value again has no effect. Throws an exception if the engine does not have a thrust reverser (see
Engine::can_reverse_thrust()).- Game Scenes:
Flight
-
void toggle_thrust_reversal()#
Toggle the engine’s thrust reverser. Throws an exception if the engine does not have a thrust reverser (see
Engine::can_reverse_thrust()).- Game Scenes:
Flight
-
bool has_real_fuels()#
Whether the engine is managed by RealFuels. The remaining properties in this section are only available when it is.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
int32_t ignitions()#
The number of times the engine can still be ignited, or -1 if it can be ignited an unlimited number of times. Throws an exception if the engine is not managed by RealFuels (see
Engine::has_real_fuels()).- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::map<std::string, double> ignition_resources()#
The resources the engine consumes each time it ignites, keyed by resource name, with the amount of each that is required. The engine uses up an ignition and fails to light if they are not available. Throws an exception if the engine is not managed by RealFuels (see
Engine::has_real_fuels()).- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool has_ullage()#
Whether the engine’s propellant is subject to ullage, so that it must be settled before the engine will run reliably. Throws an exception if the engine is not managed by RealFuels (see
Engine::has_real_fuels()).- Game Scenes:
Flight, Editor Vab, Editor Sph
-
double propellant_stability()#
How settled the propellant feeding the engine is, from 0 (fully unsettled) to 1 (fully settled). Acceleration along the engine’s thrust axis settles it, and coasting and rotation unsettle it. Throws an exception if the engine is not managed by RealFuels (see
Engine::has_real_fuels()).- Game Scenes:
Flight
-
double propellant_reliability()#
The probability that the propellant feeding the engine behaves normally, from 0 to 1. This is
Engine::propellant_stability()scaled by the game’s ullage difficulty setting, and is the value RealFuels itself tests against when deciding whether the engine runs. Throws an exception if the engine is not managed by RealFuels (seeEngine::has_real_fuels()).- Game Scenes:
Flight
-
bool pressure_fed()#
Whether the engine is fed by tank pressure rather than by a pump, and so needs to draw from a highly pressurized tank. Throws an exception if the engine is not managed by RealFuels (see
Engine::has_real_fuels()).- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool has_feed_pressure()#
Whether the tanks feeding the engine supply the pressure it needs. Always
truefor an engine that is not pressure fed. Throws an exception if the engine is not managed by RealFuels (seeEngine::has_real_fuels()).- Game Scenes:
Flight
-
bool active()#
-
class Propellant#
A propellant for an engine. Obtains by calling
Engine::propellants().-
std::string name()#
The name of the propellant.
- Game Scenes:
Flight
-
double current_amount()#
The current amount of propellant consumed in the current physics update.
- Game Scenes:
Flight
-
double current_requirement()#
The required amount of propellant for the current physics update.
- Game Scenes:
Flight
-
double total_resource_available()#
The total amount of the underlying resource currently reachable given resource flow rules.
- Game Scenes:
Flight
-
double total_resource_capacity()#
The total vehicle capacity for the underlying propellant resource, restricted by resource flow rules.
- Game Scenes:
Flight
-
bool ignore_for_isp()#
If this propellant should be ignored when calculating required mass flow given specific impulse.
- Game Scenes:
Flight
-
bool ignore_for_thrust_curve()#
If this propellant should be ignored for thrust curve calculations.
- Game Scenes:
Flight
-
bool draw_stack_gauge()#
If this propellant has a stack gauge or not.
- Game Scenes:
Flight
-
bool is_deprived()#
If this propellant is deprived.
- Game Scenes:
Flight
-
float ratio()#
The propellant ratio.
- Game Scenes:
Flight
-
std::string name()#
Experiment#
-
class Experiment#
Obtained by calling
Part::experiment().-
std::string name()#
Internal name of the experiment, as used in part cfg files.
- Game Scenes:
Flight
-
std::string title()#
Title of the experiment, as shown on the in-game UI.
- Game Scenes:
Flight
-
void run()#
Run the experiment.
- Game Scenes:
Flight
-
void transmit()#
Transmit all experimental data contained by this part.
- Game Scenes:
Flight
-
void dump()#
Dump the experimental data contained by the experiment.
- Game Scenes:
Flight
-
void reset()#
Reset the experiment.
- Game Scenes:
Flight
-
bool deployed()#
Whether the experiment has been deployed.
- Game Scenes:
Flight
-
bool rerunnable()#
Whether the experiment can be re-run.
- Game Scenes:
Flight
-
bool inoperable()#
Whether the experiment is inoperable.
- Game Scenes:
Flight
-
bool has_data()#
Whether the experiment contains data.
- Game Scenes:
Flight
-
std::vector<ScienceData> data()#
The data contained in this experiment.
- Game Scenes:
Flight
-
std::string biome()#
The name of the biome the experiment is currently in.
- Game Scenes:
Flight
-
bool available()#
Determines if the experiment is available given the current conditions.
- Game Scenes:
Flight
-
std::optional<ScienceSubject> science_subject()#
Containing information on the corresponding specific science result for the current conditions. Returns
NULLif the experiment is unavailable.- Game Scenes:
Flight
-
std::string name()#
-
struct ScienceData#
Obtained by calling
Experiment::data().-
float data_amount#
Data amount.
-
float science_value#
Science value.
-
float transmit_value#
Transmit value.
-
float data_amount#
-
struct ScienceSubject#
Obtained by calling
Experiment::science_subject().-
std::string id#
The identifier of the subject, e.g.
crewReport@KerbinSrfLandedLaunchPad.
-
std::string title#
The title of the subject, as shown in the science archives.
-
bool is_complete#
Whether the subject has been fully researched. This is true once the science banked for the subject reaches the science cap. As the banked science (see
ScienceSubject::science) is only updated after transmission/recovery, this reflects fully mining the subject over repeated experiments, not whether a single run has produced data. To check whether a run has produced data, and how valuable it is, useExperiment::has_data()andScienceData::transmit_value.
-
float science#
Amount of science already earned from this subject, not updated until after transmission/recovery.
-
float science_cap#
Total science allowable for this subject.
-
float data_scale#
Multiply science value by this to determine data amount in mits.
-
float subject_value#
Multiplier for specific Celestial Body/Experiment Situation combination.
-
float scientific_value#
Diminishing value multiplier for decreasing the science value returned from repeated experiments.
-
std::string id#
Fairing#
-
class Fairing#
A fairing. Obtained by calling
Part::fairing(). Supports both stock fairings, and those from the ProceduralFairings mod.-
void jettison()#
Jettison the fairing. Has no effect if it has already been jettisoned.
- Game Scenes:
Flight
-
bool jettisoned()#
Whether the fairing has been jettisoned.
- Game Scenes:
Flight
-
void jettison()#
Intake#
-
class Intake#
An air intake. Obtained by calling
Part::intake().-
bool open()#
-
void set_open(bool value)#
Whether the intake is open.
- Game Scenes:
Flight
-
float speed()#
Speed of the flow into the intake, in \(m/s\).
- Game Scenes:
Flight
-
float flow()#
The rate of flow into the intake, in units of resource per second.
- Game Scenes:
Flight
-
float area()#
The area of the intake’s opening, in square meters.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool open()#
Leg#
-
class Leg#
A landing leg. Obtained by calling
Part::leg().-
DeployableState state()#
The current state of the landing leg.
- Game Scenes:
Flight
-
bool deployable()#
Whether the leg is deployable.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool deployed()#
-
void set_deployed(bool value)#
Whether the landing leg is deployed.
- Game Scenes:
Flight
Note
Fixed landing legs are always deployed. Returns an error if you try to deploy fixed landing gear.
-
bool is_grounded()#
Returns whether the leg is touching the ground.
- Game Scenes:
Flight
-
DeployableState state()#
Launch Clamp#
-
class LaunchClamp#
A launch clamp. Obtained by calling
Part::launch_clamp().-
void release()#
Releases the docking clamp. Has no effect if the clamp has already been released.
- Game Scenes:
Flight
-
void release()#
Light#
-
class Light#
A light. Obtained by calling
Part::light().-
bool active()#
-
void set_active(bool value)#
Whether the light is switched on.
- Game Scenes:
Flight
-
void set_color(StdLib::ColorRGB value)#
The color of the light.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool blink()#
-
void set_blink(bool value)#
Whether blinking is enabled.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float blink_rate()#
-
void set_blink_rate(float value)#
The blink rate of the light.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float power_usage()#
The current power usage, in units of charge per second.
- Game Scenes:
Flight
-
bool active()#
Parachute#
-
class Parachute#
A parachute. Obtained by calling
Part::parachute().-
void deploy()#
Deploys the parachute. This has no effect if the parachute has already been deployed.
- Game Scenes:
Flight
-
bool deployed()#
Whether the parachute has been deployed.
- Game Scenes:
Flight
-
void arm()#
Deploys the parachute. This has no effect if the parachute has already been armed or deployed.
- Game Scenes:
Flight
-
bool armed()#
Whether the parachute has been armed or deployed.
- Game Scenes:
Flight
-
void cut()#
Cuts the parachute.
- Game Scenes:
Flight
-
ParachuteState state()#
The current state of the parachute.
- Game Scenes:
Flight
-
float deploy_altitude()#
-
void set_deploy_altitude(float value)#
The altitude at which the parachute will full deploy, in meters. Only applicable to stock parachutes.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float deploy_min_pressure()#
-
void set_deploy_min_pressure(float value)#
The minimum pressure at which the parachute will semi-deploy, in atmospheres. Only applicable to stock parachutes.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
ParachuteSafeState safe_state()#
Whether it is currently safe to deploy the parachute, given the vessel’s flight conditions. Computed by KSP from the current airspeed, pressure and temperature. Only applicable to stock parachutes. Note that KSP reports
ParachuteSafeState::unsafefor the first second after the vessel unpacks, before its thermal data is valid.- Game Scenes:
Flight
-
void deploy()#
-
enum struct ParachuteState#
The state of a parachute. See
Parachute::state().-
enumerator stowed#
The parachute is safely tucked away inside its housing.
-
enumerator armed#
The parachute is armed for deployment.
-
enumerator semi_deployed#
The parachute has been deployed and is providing some drag, but is not fully deployed yet. (Stock parachutes only)
-
enumerator deployed#
The parachute is fully deployed.
-
enumerator cut#
The parachute has been cut.
-
enumerator stowed#
-
enum struct ParachuteSafeState#
The safety state of deploying a parachute. See
Parachute::safe_state().-
enumerator safe#
The parachute is safe to deploy.
-
enumerator risky#
Deploying the parachute is risky, and it may break off.
-
enumerator unsafe#
The parachute is unsafe to deploy, and will break off.
-
enumerator none#
The safety state is not available, because the vessel is not in an atmosphere or the parachute has already been deployed or cut.
-
enumerator safe#
Radiator#
-
class Radiator#
A radiator. Obtained by calling
Part::radiator().-
bool deployable()#
Whether the radiator is deployable.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool deployed()#
-
void set_deployed(bool value)#
For a deployable radiator,
trueif the radiator is extended. If the radiator is not deployable, this is alwaystrue.- Game Scenes:
Flight
-
DeployableState state()#
The current state of the radiator.
- Game Scenes:
Flight
Note
A fixed radiator is always
DeployableState::deployed.
-
bool deployable()#
Resource Converter#
-
class ResourceConverter#
A resource converter. Obtained by calling
Part::resource_converter().-
int32_t count()#
The number of converters in the part.
- Game Scenes:
Flight
-
std::string name(int32_t index)#
The name of the specified converter.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
bool active(int32_t index)#
True if the specified converter is active.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
void start(int32_t index)#
Start the specified converter.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
void stop(int32_t index)#
Stop the specified converter.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
ResourceConverterState state(int32_t index)#
The state of the specified converter.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
std::string status_info(int32_t index)#
Status information for the specified converter. This is the full status message shown in the in-game UI.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
std::vector<std::string> inputs(int32_t index)#
List of the names of resources consumed by the specified converter.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
std::vector<std::string> outputs(int32_t index)#
List of the names of resources produced by the specified converter.
- Parameters:
index – Index of the converter.
- Game Scenes:
Flight
-
float optimum_core_temperature()#
The core temperature at which the converter will operate with peak efficiency, in Kelvin.
- Game Scenes:
Flight
-
float core_temperature()#
The core temperature of the converter, in Kelvin.
- Game Scenes:
Flight
-
float thermal_efficiency()#
The thermal efficiency of the converter, as a percentage of its maximum.
- Game Scenes:
Flight
-
int32_t count()#
-
enum struct ResourceConverterState#
The state of a resource converter. See
ResourceConverter::state().-
enumerator running#
Converter is running.
-
enumerator idle#
Converter is idle.
-
enumerator missing_resource#
Converter is missing a required resource.
-
enumerator storage_full#
No available storage for output resource.
-
enumerator capacity#
At preset resource capacity.
-
enumerator unknown#
Unknown state. Possible with modified resource converters. In this case, check
ResourceConverter::status_info()for more information.
-
enumerator running#
Resource Harvester#
-
class ResourceHarvester#
A resource harvester (drill). Obtained by calling
Part::resource_harvester().-
DeployableState state()#
The deployment state of the harvester. Whether it is drilling is reported separately by
ResourceHarvester::active().- Game Scenes:
Flight
Note
A harvester is never
DeployableState::broken, as the game does not track damage for them.
-
bool deployed()#
-
void set_deployed(bool value)#
Whether the harvester is deployed.
- Game Scenes:
Flight
-
bool active()#
-
void set_active(bool value)#
Whether the harvester is actively drilling.
- Game Scenes:
Flight
Note
A value set while the harvester is deploying is applied when the deploy completes, so it can be set immediately after setting
ResourceHarvester::deployed()without waiting for the deploy animation. Setting it has no effect while the harvester is retracted or retracting.
-
float extraction_rate()#
The rate at which the drill is extracting ore, in units per second.
- Game Scenes:
Flight
-
float thermal_efficiency()#
The thermal efficiency of the drill, as a percentage of its maximum.
- Game Scenes:
Flight
-
float core_temperature()#
The core temperature of the drill, in Kelvin.
- Game Scenes:
Flight
-
float optimum_core_temperature()#
The core temperature at which the drill will operate with peak efficiency, in Kelvin.
- Game Scenes:
Flight
-
DeployableState state()#
Reaction Wheel#
-
class ReactionWheel#
A reaction wheel. Obtained by calling
Part::reaction_wheel().-
bool active()#
-
void set_active(bool value)#
Whether the reaction wheel is active.
- Game Scenes:
Flight
-
bool broken()#
Whether the reaction wheel is broken.
- Game Scenes:
Flight
-
AxisRange available_torque()#
The available torque, in Newton meters, that can be produced by this reaction wheel, in the positive and negative pitch, roll and yaw axes of the vessel. These axes correspond to the coordinate axes of the
Vessel::reference_frame(). Returns zero if the reaction wheel is inactive or broken.- Game Scenes:
Flight
-
AxisRange max_torque()#
The maximum torque, in Newton meters, that can be produced by this reaction wheel, when it is active, in the positive and negative pitch, roll and yaw axes of the vessel. These axes correspond to the coordinate axes of the
Vessel::reference_frame().- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float authority_limiter()#
-
void set_authority_limiter(float value)#
The authority limiter for the reaction wheel, as a percentage of maximum torque. A value between 0 and 1.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool active()#
Resource Drain#
-
class ResourceDrain#
A resource drain. Obtained by calling
Part::resource_drain().-
void set_resource(Resource resource, bool enabled)#
Whether the given resource should be drained.
- Parameters:
- Game Scenes:
Flight
-
bool check_resource(Resource resource)#
Whether the provided resource is enabled for draining.
- Parameters:
- Game Scenes:
Flight
-
float min_rate()#
Minimum possible drain rate
- Game Scenes:
Flight
-
float max_rate()#
Maximum possible drain rate.
- Game Scenes:
Flight
-
float rate()#
-
void set_rate(float value)#
Current drain rate.
- Game Scenes:
Flight
-
void start()#
Activates resource draining for all enabled parts.
- Game Scenes:
Flight
-
void stop()#
Turns off resource draining.
- Game Scenes:
Flight
-
void set_resource(Resource resource, bool enabled)#
-
enum struct DrainMode#
Resource drain mode. See
ResourceDrain::drain_mode().-
enumerator part#
Drains from the parent part.
-
enumerator vessel#
Drains from all available parts.
-
enumerator part#
Robotic Controller#
-
class RoboticController#
A robotic controller. Obtained by calling
Part::robotic_controller().-
bool enabled()#
-
void set_enabled(bool value)#
Whether the controller is enabled.
- Game Scenes:
Flight
-
bool playing()#
Whether the controller’s sequence is currently playing.
- Game Scenes:
Flight
-
float position()#
-
void set_position(float value)#
The current position along the sequence, in seconds.
- Game Scenes:
Flight
-
float length()#
The length of the sequence, in seconds.
- Game Scenes:
Flight
-
float play_speed()#
The speed at which the sequence is played back, as a multiple of normal speed.
- Game Scenes:
Flight
-
void play()#
Start playing the controller’s sequence.
- Game Scenes:
Flight
-
void stop()#
Stop playing the controller’s sequence.
- Game Scenes:
Flight
-
std::vector<RoboticAxis> axes()#
The axes for the controller.
- Game Scenes:
Flight
-
bool add_axis(Module module, std::string field_name)#
Add an axis to the controller.
- Parameters:
module – The part module that the axis belongs to.
field_name – The name of the axis field, as returned by
RoboticController::axes().
- Returns:
Returns
trueif the axis is added successfully.- Game Scenes:
Flight
-
bool add_key_frame(Module module, std::string field_name, float time, float value)#
Add key frame value for controller axis.
- Parameters:
module – The part module that the axis belongs to.
field_name – The name of the axis field, as returned by
RoboticController::axes().time – The time of the key frame.
value – The value of the key frame.
- Returns:
Returns
trueif the key frame is added successfully.- Game Scenes:
Flight
-
bool clear_axis(Module module, std::string field_name)#
Clear axis.
- Parameters:
module – The part module that the axis belongs to.
field_name – The name of the axis field, as returned by
RoboticController::axes().
- Returns:
Returns
trueif the axis is cleared successfully.- Game Scenes:
Flight
-
bool enabled()#
Robotic Hinge#
-
class RoboticHinge#
A robotic hinge. Obtained by calling
Part::robotic_hinge().-
float target_angle()#
-
void set_target_angle(float value)#
Target angle.
- Game Scenes:
Flight
-
float current_angle()#
Current angle.
- Game Scenes:
Flight
-
float min_angle()#
-
void set_min_angle(float value)#
The minimum angle the hinge can move to, in degrees.
- Game Scenes:
Flight
-
float max_angle()#
-
void set_max_angle(float value)#
The maximum angle the hinge can move to, in degrees.
- Game Scenes:
Flight
-
float rate()#
-
void set_rate(float value)#
Target movement rate in degrees per second.
- Game Scenes:
Flight
-
float damping()#
-
void set_damping(float value)#
Damping percentage.
- Game Scenes:
Flight
-
bool locked()#
-
void set_locked(bool value)#
Lock movement.
- Game Scenes:
Flight
-
bool motor_engaged()#
-
void set_motor_engaged(bool value)#
Whether the motor is engaged.
- Game Scenes:
Flight
-
bool is_moving()#
Whether the servo is currently moving.
- Game Scenes:
Flight
-
void move_home()#
Move hinge to its built position.
- Game Scenes:
Flight
-
float target_angle()#
Robotic Piston#
-
class RoboticPiston#
A robotic piston part. Obtained by calling
Part::robotic_piston().-
float target_extension()#
-
void set_target_extension(float value)#
Target extension of the piston.
- Game Scenes:
Flight
-
float current_extension()#
Current extension of the piston.
- Game Scenes:
Flight
-
float min_extension()#
-
void set_min_extension(float value)#
The minimum extension of the piston, in meters.
- Game Scenes:
Flight
-
float max_extension()#
-
void set_max_extension(float value)#
The maximum extension of the piston, in meters.
- Game Scenes:
Flight
-
float rate()#
-
void set_rate(float value)#
Target movement rate in meters per second.
- Game Scenes:
Flight
-
float damping()#
-
void set_damping(float value)#
Damping percentage.
- Game Scenes:
Flight
-
bool locked()#
-
void set_locked(bool value)#
Lock movement.
- Game Scenes:
Flight
-
bool motor_engaged()#
-
void set_motor_engaged(bool value)#
Whether the motor is engaged.
- Game Scenes:
Flight
-
bool is_moving()#
Whether the servo is currently moving.
- Game Scenes:
Flight
-
void move_home()#
Move piston to its built position.
- Game Scenes:
Flight
-
float target_extension()#
Robotic Rotation#
-
class RoboticRotation#
A robotic rotation servo. Obtained by calling
Part::robotic_rotation().-
Part part()#
The part object for this robotic rotation servo.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float target_angle()#
-
void set_target_angle(float value)#
Target angle.
- Game Scenes:
Flight
-
float current_angle()#
Current angle.
- Game Scenes:
Flight
-
float min_angle()#
-
void set_min_angle(float value)#
The minimum angle the servo can rotate to, in degrees.
- Game Scenes:
Flight
-
float max_angle()#
-
void set_max_angle(float value)#
The maximum angle the servo can rotate to, in degrees.
- Game Scenes:
Flight
-
bool allow_full_rotation()#
-
void set_allow_full_rotation(bool value)#
Whether the servo is allowed to rotate freely through a full revolution, ignoring the angle limits.
- Game Scenes:
Flight
-
float rate()#
-
void set_rate(float value)#
Target movement rate in degrees per second.
- Game Scenes:
Flight
-
float damping()#
-
void set_damping(float value)#
Damping percentage.
- Game Scenes:
Flight
-
bool locked()#
-
void set_locked(bool value)#
Lock Movement
- Game Scenes:
Flight
-
bool motor_engaged()#
-
void set_motor_engaged(bool value)#
Whether the motor is engaged.
- Game Scenes:
Flight
-
bool is_moving()#
Whether the servo is currently moving.
- Game Scenes:
Flight
-
void move_home()#
Move rotation servo to its built position.
- Game Scenes:
Flight
-
Part part()#
Robotic Rotor#
-
class RoboticRotor#
A robotic rotor. Obtained by calling
Part::robotic_rotor().-
float target_rpm()#
-
void set_target_rpm(float value)#
Target RPM.
- Game Scenes:
Flight
-
float current_rpm()#
Current RPM.
- Game Scenes:
Flight
-
bool inverted()#
-
void set_inverted(bool value)#
Whether the rotor direction is inverted.
- Game Scenes:
Flight
-
float torque_limit()#
-
void set_torque_limit(float value)#
Torque limit percentage.
- Game Scenes:
Flight
-
float max_torque()#
-
void set_max_torque(float value)#
The maximum torque the rotor can generate, in kilonewtons.
- Game Scenes:
Flight
-
float brake_percentage()#
-
void set_brake_percentage(float value)#
The percentage of braking force applied to the rotor.
- Game Scenes:
Flight
-
bool locked()#
-
void set_locked(bool value)#
Lock movement.
- Game Scenes:
Flight
-
bool motor_engaged()#
-
void set_motor_engaged(bool value)#
Whether the motor is engaged.
- Game Scenes:
Flight
-
bool is_moving()#
Whether the rotor is currently moving.
- Game Scenes:
Flight
-
float target_rpm()#
RCS#
-
class RCS#
An RCS block or thruster. Obtained by calling
Part::rcs().-
bool active()#
Whether the RCS thrusters are active. An RCS thruster is inactive if the RCS action group is disabled (
Control::rcs()), the RCS thruster itself is not enabled (RCS::enabled()), or it is covered by a fairing (Part::shielded()) and cannot thrust while shielded.- Game Scenes:
Flight
-
bool enabled()#
-
void set_enabled(bool value)#
Whether the RCS thrusters are enabled.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool pitch_enabled()#
-
void set_pitch_enabled(bool value)#
Whether the RCS thruster will fire when pitch control input is given.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool yaw_enabled()#
-
void set_yaw_enabled(bool value)#
Whether the RCS thruster will fire when yaw control input is given.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool roll_enabled()#
-
void set_roll_enabled(bool value)#
Whether the RCS thruster will fire when roll control input is given.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool forward_enabled()#
-
void set_forward_enabled(bool value)#
Whether the RCS thruster will fire when pitch control input is given.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool up_enabled()#
-
void set_up_enabled(bool value)#
Whether the RCS thruster will fire when yaw control input is given.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool right_enabled()#
-
void set_right_enabled(bool value)#
Whether the RCS thruster will fire when roll control input is given.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool input_override()#
-
void set_input_override(bool value)#
Whether the RCS control is being set directly, bypassing the vessel’s normal flight controls. When enabled, the rotation and translation demand is set by
RCS::rotation_override()andRCS::translation_override()instead of the normal control inputs. The override is automatically released if the controlling client disconnects or the vessel changes. Precision mode leaves an overridden block at full thrust.- Game Scenes:
Flight
-
std::tuple<double, double, double> rotation_override()#
-
void set_rotation_override(std::tuple<double, double, double> value)#
The rotation demand applied when
RCS::input_override()is enabled, in the pitch, roll and yaw axes. Each component is a normalized control input between -1 and 1.- Game Scenes:
Flight
-
std::tuple<double, double, double> translation_override()#
-
void set_translation_override(std::tuple<double, double, double> value)#
The translation demand applied when
RCS::input_override()is enabled, in the right, up and forward axes. Each component is a normalized control input between -1 and 1.- Game Scenes:
Flight
-
AxisRange available_torque()#
The available torque, in Newton meters, that can be produced by this RCS, in the positive and negative pitch, roll and yaw axes of the vessel. These axes correspond to the coordinate axes of the
Vessel::reference_frame(). Returns zero if RCS is disable.- Game Scenes:
Flight
Note
Precision mode weakens the block, and the available torque follows it. A block driven by
RCS::input_override()is exempt, soRCS::override_wrench()can report the larger torque an override reaches.
-
AxisRange available_force()#
The available force, in Newtons, that can be produced by this RCS, in the positive and negative x, y and z axes of the vessel. These axes correspond to the coordinate axes of the
Vessel::reference_frame(). Returns zero if RCS is disabled.- Game Scenes:
Flight
Note
Precision mode weakens the block, and the available force follows it. A block driven by
RCS::input_override()is exempt, soRCS::override_wrench()can report the larger force an override reaches.
-
std::tuple<double, double, double> force()#
The force being applied by the RCS thrusters, in Newtons. The vector is in the vessel’s reference frame (
Vessel::reference_frame()). Returns zero if the RCS is inactive.- Game Scenes:
Flight
-
std::tuple<double, double, double> torque()#
The torque being applied by the RCS thrusters about the vessel’s center of mass, in Newton meters. The vector is in the vessel’s reference frame (
Vessel::reference_frame()). Returns zero if the RCS is inactive.- Game Scenes:
Flight
-
Wrench override_wrench(std::tuple<double, double, double> rotation, std::tuple<double, double, double> translation)#
The force and torque the given demands would produce, in Newtons and Newton meters.
- Parameters:
rotation – A rotation demand, as set by
RCS::rotation_override().translation – A translation demand, as set by
RCS::translation_override().
- Returns:
The force, and the torque about the vessel’s center of mass, in the vessel’s reference frame (
Vessel::reference_frame()), or zero if the RCS is inactive.- Game Scenes:
Flight
Note
The demands do not have to be applied. The prediction leaves out full thrust, which
RCS::force()andRCS::torque()include.
-
float available_thrust()#
The amount of thrust, in Newtons, that would be produced by the thruster when activated. Returns zero if the thruster does not have any fuel. Takes the thrusters current
RCS::thrust_limit()and atmospheric conditions into account.- Game Scenes:
Flight
-
float max_thrust()#
The maximum amount of thrust that can be produced by the RCS thrusters when active, in Newtons, with the
RCS::thrust_limit()set to 100%. Takes atmospheric conditions into account.- Game Scenes:
Flight
-
float max_vacuum_thrust()#
The maximum amount of thrust that can be produced by the RCS thrusters when active in a vacuum, in Newtons.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float thrust_limit()#
-
void set_thrust_limit(float value)#
The thrust limiter of the thruster. A value between 0 and 1.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::vector<Thruster> thrusters()#
A list of thrusters, one of each nozzel in the RCS part.
- Game Scenes:
Flight
-
float specific_impulse()#
The current specific impulse of the RCS, in seconds. Returns zero if the RCS is not active.
- Game Scenes:
Flight
-
float vacuum_specific_impulse()#
The vacuum specific impulse of the RCS, in seconds.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
float kerbin_sea_level_specific_impulse()#
The specific impulse of the RCS at sea level on Kerbin, in seconds.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::vector<std::string> propellants()#
The names of resources that the RCS consumes.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
std::map<std::string, float> propellant_ratios()#
The ratios of resources that the RCS consumes. A dictionary mapping resource names to the ratios at which they are consumed by the RCS.
- Game Scenes:
Flight
-
bool has_fuel()#
Whether the RCS has fuel available.
- Game Scenes:
Flight
-
bool active()#
Sensor#
-
class Sensor#
A sensor, such as a thermometer. Obtained by calling
Part::sensor().-
bool active()#
-
void set_active(bool value)#
Whether the sensor is active.
- Game Scenes:
Flight
-
std::string value()#
The current value of the sensor.
- Game Scenes:
Flight
Note
This is the same readout string shown in the part’s right-click menu in-game, and is intended for display rather than for parsing. Both its units and the way it formats numbers follow the language the game is running in, so it is not stable across locales. For programmatic access to the underlying quantities, use
Part::temperature()(temperature sensors),Flight::g_force()(accelerometers) orFlight::static_pressure()(barometers).
-
bool active()#
Solar Panel#
-
class SolarPanel#
A solar panel. Obtained by calling
Part::solar_panel().-
bool deployable()#
Whether the solar panel is deployable.
- Game Scenes:
Flight, Editor Vab, Editor Sph
-
bool deployed()#
-
void set_deployed(bool value)#
Whether the solar panel is extended.
- Game Scenes:
Flight
-
DeployableState state()#
The current state of the solar panel.
- Game Scenes:
Flight
-
float energy_flow()#
The current amount of energy being generated by the solar panel, in units of charge per second.
- Game Scenes:
Flight
-
float sun_exposure()#
The current amount of sunlight that is incident on the solar panel, as a percentage. A value between 0 and 1.
- Game Scenes:
Flight
-
bool deployable()#
Thruster#
-
class Thruster#
The component of an
EngineorRCSpart that generates thrust. Can obtained by callingEngine::thrusters()orRCS::thrusters().Note
Engines can consist of multiple thrusters. For example, the S3 KS-25x4 “Mammoth” has four rocket nozzels, and so consists of four thrusters.
-
Part part()#
The
Thruster::part()that contains this thruster.- Game Scenes:
Flight
-
float thrust()#
The thrust being produced by the thruster, in Newtons.
- Game Scenes:
Flight
-
std::tuple<double, double, double> thrust_position(ReferenceFrame reference_frame)#
The position at which the thruster generates thrust, in the given reference frame. For gimballed engines, this takes into account the current rotation of the gimbal.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight
-
std::tuple<double, double, double> thrust_direction(ReferenceFrame reference_frame)#
The direction of the force generated by the thruster, in the given reference frame. This is opposite to the direction in which the thruster expels propellant. For gimballed engines, this takes into account the current rotation of the gimbal.
- Parameters:
reference_frame – The reference frame that the returned direction is in.
- Returns:
The direction as a unit vector.
- Game Scenes:
Flight
-
ReferenceFrame thrust_reference_frame()#
A reference frame that is fixed relative to the thruster and orientated with its thrust direction (
Thruster::thrust_direction()). For gimballed engines, this takes into account the current rotation of the gimbal.The origin is at the position of thrust for this thruster (
Thruster::thrust_position()).The axes rotate with the thrust direction. This is the direction in which the thruster expels propellant, including any gimballing.
The y-axis points along the thrust direction.
The x-axis and z-axis are perpendicular to the thrust direction.
- Game Scenes:
Flight
-
bool gimballed()#
Whether the thruster is gimballed.
- Game Scenes:
Flight
-
std::tuple<double, double, double> gimbal_position(ReferenceFrame reference_frame)#
Position around which the gimbal pivots.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight
-
std::tuple<double, double, double> gimbal_angle()#
The current gimbal angle in the pitch, roll and yaw axes, in degrees.
- Game Scenes:
Flight
-
std::tuple<double, double, double> initial_thrust_position(ReferenceFrame reference_frame)#
The position at which the thruster generates thrust, when the engine is in its initial position (no gimballing), in the given reference frame.
- Parameters:
reference_frame – The reference frame that the returned position vector is in.
- Returns:
The position as a vector.
- Game Scenes:
Flight
Note
This position can move when the gimbal rotates. This is because the thrust position and gimbal position are not necessarily the same.
-
std::tuple<double, double, double> initial_thrust_direction(ReferenceFrame reference_frame)#
The direction of the force generated by the thruster, when the engine is in its initial position (no gimballing), in the given reference frame. This is opposite to the direction in which the thruster expels propellant.
- Parameters:
reference_frame – The reference frame that the returned direction is in.
- Returns:
The direction as a unit vector.
- Game Scenes:
Flight
-
Part part()#
Wheel#
-
class Wheel#
A wheel. Includes landing gear and rover wheels. Obtained by calling
Part::wheel(). Can be used to control the motors, steering and deployment of wheels, among other things.-
DeployableState state()#
The current state of the wheel.
-
float radius()#
Radius of the wheel, in meters.
-
bool grounded()#
Whether the wheel is touching the ground.
-
bool has_brakes()#
Whether the wheel has brakes.
-
float brakes()#
-
void set_brakes(float value)#
The braking force, as a percentage of maximum, when the brakes are applied.
-
bool auto_friction_control()#
-
void set_auto_friction_control(bool value)#
Whether automatic friction control is enabled.
-
float manual_friction_control()#
-
void set_manual_friction_control(float value)#
Manual friction control value. Only has an effect if automatic friction control is disabled. A value between 0 and 5 inclusive.
-
bool deployable()#
Whether the wheel is deployable.
-
bool deployed()#
-
void set_deployed(bool value)#
Whether the wheel is deployed.
-
bool powered()#
Whether the wheel is powered by a motor.
-
bool motor_enabled()#
-
void set_motor_enabled(bool value)#
Whether the motor is enabled.
-
bool motor_inverted()#
-
void set_motor_inverted(bool value)#
Whether the direction of the motor is inverted.
-
MotorState motor_state()#
Whether the direction of the motor is inverted.
-
float motor_output()#
The output of the motor. This is the torque currently being generated, in Newton meters.
-
bool traction_control_enabled()#
-
void set_traction_control_enabled(bool value)#
Whether automatic traction control is enabled. A wheel only has traction control if it is powered.
-
float traction_control()#
-
void set_traction_control(float value)#
Setting for the traction control. Only takes effect if the wheel has automatic traction control enabled. A value between 0 and 5 inclusive.
-
float drive_limiter()#
-
void set_drive_limiter(float value)#
Manual setting for the motor limiter. Only takes effect if the wheel has automatic traction control disabled. A value between 0 and 100 inclusive.
-
bool steerable()#
Whether the wheel has steering.
-
bool steering_enabled()#
-
void set_steering_enabled(bool value)#
Whether the wheel steering is enabled.
-
bool steering_inverted()#
-
void set_steering_inverted(bool value)#
Whether the wheel steering is inverted.
-
bool steering_angle_auto()#
-
void set_steering_angle_auto(bool value)#
Whether the steering angle is automatically limited based on the vessel’s speed, reducing the maximum angle as the vessel moves faster. See also
Wheel::steering_angle_limit().
-
float steering_angle_limit()#
-
void set_steering_angle_limit(float value)#
The steering angle limit.
-
float steering_response_time()#
-
void set_steering_response_time(float value)#
Steering response time.
-
bool has_suspension()#
Whether the wheel has suspension.
-
float suspension_spring_strength()#
Suspension spring strength, as set in the editor.
-
float suspension_damper_strength()#
Suspension damper strength, as set in the editor.
-
bool broken()#
Whether the wheel is broken.
-
bool repairable()#
Whether the wheel is repairable.
-
float stress()#
Current stress on the wheel.
-
float stress_tolerance()#
Stress tolerance of the wheel.
-
float stress_percentage()#
Current stress on the wheel as a percentage of its stress tolerance.
-
float deflection()#
Current deflection of the wheel.
-
float slip()#
Current slip of the wheel.
-
DeployableState state()#
-
enum struct MotorState#
The state of the motor on a powered wheel. See
Wheel::motor_state().-
enumerator idle#
The motor is idle.
-
enumerator running#
The motor is running.
-
enumerator disabled#
The motor is disabled.
-
enumerator inoperable#
The motor is inoperable.
-
enumerator not_enough_resources#
The motor does not have enough resources to run.
-
enumerator idle#
Trees of Parts#
Vessels in KSP are comprised of a number of parts, connected to one another in a
tree structure. An example vessel is shown in Figure 1, and the corresponding
tree of parts in Figure 2. The craft file for this example can also be
downloaded here.
Figure 1 – Example parts making up a vessel.#
Figure 2 – Tree of parts for the vessel in Figure 1. Arrows point from the parent part to the child part.#
Traversing the Tree#
The tree of parts can be traversed using the attributes Parts::root(),
Part::parent() and Part::children().
The root of the tree is the same as the vessels root part (part number 1 in
the example above) and can be obtained by calling Parts::root().
A parts children can be obtained by calling Part::children().
If the part does not have any children, Part::children()
returns an empty list. A parts parent can be obtained by calling
Part::parent(). If the part does not have a parent
(as is the case for the root part), Part::parent()
returns NULL.
The following C++ example uses these attributes to perform a depth-first traversal over all of the parts in a vessel:
#include <iostream>
#include <stack>
#include <string>
#include <utility>
#include <krpc.hpp>
#include <krpc/services/space_center.hpp>
using SpaceCenter = krpc::services::SpaceCenter;
int main() {
krpc::Client conn = krpc::connect("");
SpaceCenter sc(&conn);
auto vessel = sc.active_vessel().value();
auto root = vessel.parts().root();
std::stack<std::pair<SpaceCenter::Part, int>> stack;
stack.push(std::pair<SpaceCenter::Part, int>(root, 0));
while (!stack.empty()) {
auto part = stack.top().first;
auto depth = stack.top().second;
stack.pop();
std::cout << std::string(depth, ' ') << part.title() << std::endl;
for (auto child : part.children())
stack.push(std::pair<SpaceCenter::Part, int>(child, depth+1));
}
}
When this code is execute using the craft file for the example vessel pictured above, the following is printed out:
Command Pod Mk1
TR-18A Stack Decoupler
FL-T400 Fuel Tank
LV-909 Liquid Fuel Engine
TR-18A Stack Decoupler
FL-T800 Fuel Tank
LV-909 Liquid Fuel Engine
TT-70 Radial Decoupler
FL-T400 Fuel Tank
TT18-A Launch Stability Enhancer
FTX-2 External Fuel Duct
LV-909 Liquid Fuel Engine
Aerodynamic Nose Cone
TT-70 Radial Decoupler
FL-T400 Fuel Tank
TT18-A Launch Stability Enhancer
FTX-2 External Fuel Duct
LV-909 Liquid Fuel Engine
Aerodynamic Nose Cone
LT-1 Landing Struts
LT-1 Landing Struts
Mk16 Parachute
Attachment Modes#
Parts can be attached to other parts either radially (on the side of the parent part) or axially (on the end of the parent part, to form a stack).
For example, in the vessel pictured above, the parachute (part 2) is axially connected to its parent (the command pod – part 1), and the landing leg (part 5) is radially connected to its parent (the fuel tank – part 4).
The root part of a vessel (for example the command pod – part 1) does not have a parent part, so does not have an attachment mode. However, the part is consider to be axially attached to nothing.
The following C++ example does a depth-first traversal as before, but also prints out the attachment mode used by the part:
#include <iostream>
#include <stack>
#include <string>
#include <utility>
#include <krpc.hpp>
#include <krpc/services/space_center.hpp>
using SpaceCenter = krpc::services::SpaceCenter;
int main() {
auto conn = krpc::connect();
SpaceCenter sc(&conn);
auto vessel = sc.active_vessel().value();
auto root = vessel.parts().root();
std::stack<std::pair<SpaceCenter::Part, int> > stack;
stack.push(std::pair<SpaceCenter::Part, int>(root, 0));
while (!stack.empty()) {
auto part = stack.top().first;
auto depth = stack.top().second;
stack.pop();
std::string attach_mode = part.axially_attached() ? "axial" : "radial";
std::cout << std::string(depth, ' ') << part.title() << " - " << attach_mode << std::endl;
auto children = part.children();
for (auto child : children) {
stack.push(std::pair<SpaceCenter::Part, int>(child, depth+1));
}
}
}
When this code is execute using the craft file for the example vessel pictured above, the following is printed out:
Command Pod Mk1 - axial
TR-18A Stack Decoupler - axial
FL-T400 Fuel Tank - axial
LV-909 Liquid Fuel Engine - axial
TR-18A Stack Decoupler - axial
FL-T800 Fuel Tank - axial
LV-909 Liquid Fuel Engine - axial
TT-70 Radial Decoupler - radial
FL-T400 Fuel Tank - radial
TT18-A Launch Stability Enhancer - radial
FTX-2 External Fuel Duct - radial
LV-909 Liquid Fuel Engine - axial
Aerodynamic Nose Cone - axial
TT-70 Radial Decoupler - radial
FL-T400 Fuel Tank - radial
TT18-A Launch Stability Enhancer - radial
FTX-2 External Fuel Duct - radial
LV-909 Liquid Fuel Engine - axial
Aerodynamic Nose Cone - axial
LT-1 Landing Struts - radial
LT-1 Landing Struts - radial
Mk16 Parachute - axial
Fuel Lines#
Figure 5 – Fuel lines from the example in Figure 1. Fuel flows from the parts highlighted in green, into the part highlighted in blue.#
Figure 4 – A subset of the parts tree from Figure 2 above.#
Fuel lines are considered parts, and are included in the parts tree (for example, as pictured in Figure 4). However, the parts tree does not contain information about which parts fuel lines connect to. The parent part of a fuel line is the part from which it will take fuel (as shown in Figure 4) however the part that it will send fuel to is not represented in the parts tree.
Figure 5 shows the fuel lines from the example vessel pictured earlier. Fuel line part 15 (in red) takes fuel from a fuel tank (part 11 – in green) and feeds it into another fuel tank (part 9 – in blue). The fuel line is therefore a child of part 11, but its connection to part 9 is not represented in the tree.
The attributes Part::fuel_lines_from() and
Part::fuel_lines_to() can be used to discover these
connections. In the example in Figure 5, when
Part::fuel_lines_to() is called on fuel tank part
11, it will return a list of parts containing just fuel tank part 9 (the blue
part). When Part::fuel_lines_from() is called on
fuel tank part 9, it will return a list containing fuel tank parts 11 and 17
(the parts colored green).
Staging#
For vessel-level summaries (delta-v, thrust, fuel, and resources grouped per
stage), use the Stage class via
Vessel::stages() and
Vessel::decouple_stages().
Figure 6 – Example vessel from Figure 1 with a staging sequence.#
Each part has two staging numbers associated with it: the stage in which the
part is activated and the stage in which the part is decoupled. These values
can be obtained using Part::stage() and
Part::decouple_stage() respectively. For parts that
are not activated by staging, Part::stage() returns
-1. For parts that are never decoupled,
Part::decouple_stage() returns a value of -1.
Figure 6 shows an example staging sequence for a vessel. Figure 7 shows the stages in which each part of the vessel will be activated. Figure 8 shows the stages in which each part of the vessel will be decoupled.
Figure 7 – The stage in which each part is activated.#
Figure 8 – The stage in which each part is decoupled.#