• ⚠️ Mod Release Rules now apply to this board.

    All mods must include a license, source code (for executable mods), and proper attribution.

    Read the full rules here before posting.

Tools kRPC - Control KSA with scripts in Python, C#, C++, C, Java or Lua

djungelorm

New Member
Messages
1
Reaction score
3
kRPC v0.1.0 allows you to control the game from scripts written in Python, C#, C++, C, Java and Lua.

This a continuation of the mod of the same name for KSP, and shares the same client libraries with it. It provides a server that runs in KSA, and works with all the same client libraries that the original kRPC mod uses.

This script launches a rocket from Cape Canaveral, flies it straight up, and cuts the engines at 10 km:
Python
import krpc
conn = krpc.connect(name="Launch")
ksa = conn.ksa
vehicle = ksa.launch_vehicle("Rocket", "CCSFS LC-39A")
flight = vehicle.flight

vehicle.auto_pilot.target_pitch_and_heading(90, 90)
vehicle.auto_pilot.engage()
vehicle.control.throttle = 1
vehicle.control.activate_next_sequence()
vehicle.control.engine_on = True

event = conn.add_event(lambda: flight.mean_altitude > 10000)
with event.condition:
    event.wait()

vehicle.control.engine_on = False
print(f"{vehicle.name} reached 10 km")
Features
  • Telemetry: altitudes, speeds, attitude, pressure, g-force, thrust and specific impulse, and the delta-v of each sequence.
  • Orbits, including the orbits of bodies, the orbit after a planned burn, and the predicted trajectory through sphere of influence changes.
  • Parts, resources and part modules: engines, RCS, decouplers, parachutes and docking ports.
  • Landing: terrain height anywhere on a body, altitude above the terrain, and the time to impact.
  • Reference frames, with positions, velocities and rotations in body, vehicle, surface and orbital frames.
  • Control: throttle, engines, staging, and the flight computer as an auto-pilot, including executing planned burns.
  • Launching vehicles onto a launch pad, and time warp.
  • Server side functions: events, streams and functions that run inside the game, once per frame.
Download
SpaceDock v0.1.0

Documentation
krpc.github.io/krpc/experimental/ksa, with a getting started guide, tutorials, and the API reference for each client language.

Find us on Discord: https://discord.gg/c8c36UM

Requirements
  • Kitten Space Agency 2026.10.19.5638
  • StarMap 0.4.8 by KlaasWhite (MIT)
  • A kRPC 0.7.0 client library, for example the Python client: pip install krpc==0.7.0 See the documentation website (link above) for more details.
  • Tested on Windows and Linux.
Installation
  1. Install StarMap
  2. Copy the kRPC.KSA folder from the archive into <Documents>/My Games/Kitten Space Agency/mods.
  3. Enable the mod in <Documents>/My Games/Kitten Space Agency/manifest.toml:
    Code
    [[mods]]
    id = "kRPC.KSA"
    enabled = true
  4. Launch the game through StarMap. The server starts once the game has loaded its mods, and listens on 127.0.0.1, ports 50000 and 50001.
The archive also holds the client stubs for C#, C++, C and Java, and example scripts. Note: pre-generated stubs are *not* required for the Python and Lua clients.

Known Limitations
  • This mod is experimental and its API may change.
  • Manual pitch, yaw and roll input is not available yet. Scripts can steer using the auto-pilot.
Source and Bug Reports
Source: github.com/krpc/krpc
Bug reports and feature requests: GitHub issues

License
kRPC is licensed under the LGPL v3. It bundles Google.Protobuf (BSD 3-Clause) and System.IO.Ports (MIT), whose licenses are in the archive.
 
Last edited:
Back
Top