Skip to content

Servos and Linear Motors ​

Rotary servos and linear motors share ROS2 topics. Select the joint with MotorCommand.id; receive all motor states together in JointState.

Parts ​

PartJoint typeTravel rangeDefault speedRated effort
ROS2 Size-0 Axial Servorevolute-π〜π rad45°/s250 N·m
ROS2 Slim Telescoping Actuatorprismatic0〜1.6 m0.5 m/s4000 N

Attach bottom to the parent structure and moving parts to top for both. The linear actuator has a 0.3125 m mounting disk, retracted length 1.6049312 m, stroke 1.6 m, and maximum length 3.2049312 m. Relative to the fixed white LinearBase, LinearSleeve moves half the extension and LinearRod the full extension along Y. The top stack node follows extension. Adjust Travel Speed in the editor or Flight from 0.02–1.0 m/s (default 0.5 m/s). Moving components are included in the native model; no later stock-model generation is needed.

A top-mounted part with PhysicsSignificance = 1, such as a small fireworks launcher, is promoted to an independent physics body with KSP's PromoteToPhysicalPart() during Flight, and a drive connection is created. Initialization retries after the top part starts and unpacks. Saves retain actual extension and moving-side vessel coordinates as well as the target. After loading, extension is measured from the actual distance between attachment faces.

The linear drive configures every PartJoint.joints connection and restores driving after KSP resets fixed springs, such as during unpacking. Rated 4000 N converts to 4 kN in KSP physics units, shared across parallel joints.

The servo uses a dedicated two-disk model, 0.625 m diameter (size 0), 0.140 m tall. ServoBase is fixed; ServoRotor rotates about Y. An orange marker and lower scale show relative angle. Attachment faces are at Y=0 and Y=0.140 m.

Input and output topics ​

DirectionTopicTypeContent
Output/ksp_vessel/joint_statessensor_msgs/msg/JointStatePosition, velocity, effort
Output/pylon/diagnosticsdiagnostic_msgs/msg/DiagnosticArrayPower, engage, lock, estimated current
Input/ksp_vessel/actuators/servo/commandpylon_interfaces/msg/MotorCommandTyped commands selected by id
Output/ksp_vessel/actuators/servo/statepylon_interfaces/msg/MotorStateTyped state with id

By default, KSP sends state at 20 Hz to UDP 49010, and the bridge publishes to ROS2 on each reception. ROS2 commands return through the bridge to UDP 49011.

Joint names ​

If motorName is empty, it is generated from KSP partFlightId.

text
servo_<partFlightId>
linear_<partFlightId>

Check the actual name in /ksp_vessel/joint_states.name or ROS Joint in the KSP Part Action Window.

Typed commands are Reliable; state is Best Effort; both have depth 10. Topics are permanent and carry messages for multiple motors.

Units ​

jointpositionvelocityeffort
revoluteradrad/sN·m
prismaticmm/sN

estimated_current_a in /pylon/diagnostics divides estimated effort by torquePerAmpNm or forcePerAmpN. It is not measured current.

MotorCommand / MotorState ​

Command one motor through a typed topic with a lease.

MotorCommand fieldMeaning
headerNot used for command conversion by the current bridge
vessel_id / controller_id / lease_idAcquired authority identity
sequenceMonotonically increasing number within the same lease
idTarget ROS joint ID
modeMODE_POSITION=0、MODE_VELOCITY=1、MODE_EFFORT=2
enabledfalse disengages the motor
positionPosition-mode target; rotary rad, linear m
velocityVelocity-mode target; rotary rad/s, linear m/s
effortEffort-mode target; rotary N·m, linear N
timeout_secOverride duration; zero uses the bridge default
bash
ros2 topic pub --once /ksp_vessel/actuators/servo/command \
  pylon_interfaces/msg/MotorCommand \
  "{vessel_id: <vessel-id>, controller_id: manual, lease_id: <lease-id>, sequence: 2, id: servo_12345, mode: 0, enabled: true, position: 1.5708, timeout_sec: 0.5}"
MotorState fieldMeaning
headerBridge reception time, frame_id = base_link
idROS joint ID
nameROS joint name
motor_typerevolute / prismatic
enabledEngage state
modeCurrent command mode
position / velocity / effortCurrent values in the units above
targetCurrent target
currentEstimated current in A
poweredElectricCharge availability
lockedLock state
command_activeWhether a ROS override is held

Replace example identities with the lease acquired through the Vehicle Control API. Only the owner may use MotorCommand. ROS motors are not allocated by Body Wrench. After timeout, command_active becomes false; velocity mode holds the current position. Position-mode targets are retained.

DiagnosticStatus ​

ConditionLevelMessage
No powerERRORElectricCharge unavailable
disengagedWARNMotor disengaged
lockedWARNServo locked
NormalOKMotor operational

Collisions within the vessel ​

The motor body and driven parts connected to top can collide with each other during Flight.

For linear actuators, contact is excluded only between moving sleeves/rods and driven parts. Contact with the fixed tube and surroundings is retained, as is geometry for raycasts such as LiDAR.

Individual movable-fin angle control ​

Stock ModuleControlSurface parts on the active vessel—movable fins, elevons, rudders, and similar surfaces—are detected automatically and exposed as rotary joints named fin_<persistentId>_<moduleIndex>. No vessel rebuild or ModuleManager patch is needed. Fixed wings/fins and propeller/rotor blades using displaceVelocity are excluded.

Check actual IDs in the state topic's id or /ksp_vessel/joint_states.name below.

bash
ros2 topic echo /ksp_vessel/actuators/servo/state

After acquiring a lease through the Vehicle Control API, specify angles with MotorCommand. The example requests +10° (0.174533 rad). Replace identity, ID, and sequence with actual values.

bash
ros2 topic pub --once /ksp_vessel/actuators/servo/command \
  pylon_interfaces/msg/MotorCommand \
  "{vessel_id: '<vessel-id>', controller_id: manual, lease_id: '<lease-id>', sequence: 2, id: fin_12345_0, mode: 0, enabled: true, position: 0.174533, timeout_sec: 0.5}"
  • Only position mode is supported. Signs follow rotation about the surface model's local X axis; mirrored parts are commanded individually. Signs differ from vessel-wide pitch/yaw/roll.
  • Angles are limited to each part's ±ctrlSurfaceRange, using stock KSP actuator speeds and aerodynamic calculations.
  • Commands temporarily override that surface's pitch/yaw/roll input and deployment settings. Fins are not coupled.
  • Fin position commands also expire: default 0.5 seconds, range 0.05–5 seconds. To hold an angle, resend faster than the timeout with an increasing lease sequence. Renew the lease as well.
  • enabled: false, communication timeout, authority release/change/e-stop, vessel switches, and packing restore original KSP settings. Previously deployed surfaces return to their original deployment settings.
  • State position is the stock module's current angle; target is the limited target, both in rad. Velocity, torque, and current are unavailable and return zero. powered means controllable; enabled and command_active indicate a ROS override.

Guides and API references for building ROS2 applications with PyLoN