#simulator #px4 #ground #receive #send #send-receive #sitl

px4sim

A wrapper to simplify creating a custom PX4 SITL simulator

7 releases

new 0.1.6 Oct 15, 2024
0.1.5 Oct 15, 2024

#40 in Simulation

Download history 178/week @ 2024-10-05 553/week @ 2024-10-12

731 downloads per month

MIT/Apache

20KB
416 lines

PX4 SITL Simulation Utility

A simple Rust program that fulfills the contracts of a PX4 SITL Simulator the same way as Gazebo or jMavSim.

This library makes it simple to send and receive simulation related information to PX4 via MAVLink. It does not cover other use-cases like offboard control, ground station or remote controller, purely what is needed for PX4 to play nicely with a custom simulator.

PX4 SITL Setup

  1. Clone PX4
  2. Install dependencies
  3. Build with make px4_sitl
  4. Launch with PX4_SYS_AUTOSTART=<AIRFRAME> ./px4 -i <SYSTEM_ID>

See available airframes in px4/ROMFS/px4fmu_common/init.d-posix/airframes

The airframe value is a number, such as 10016. The instance or system ID is a unique number for each running instance of PX4. It can just be 0 if there is only one running instance.

Start PX4 as a Child Process

If the airframe value and the path to the PX4 root directory are provided to the DroneSimulator class constructor, it will start the PX4 SITL simulation in the background.

It can also be started programatically using the start_px4 function from the util module.

This way it is not necessary to start PX4 from a separate console window. The downside is that the pxh> shell will not be available to give commands to PX4 from the console window.

The child process shall be killed when exiting.

Dependencies

~3.5MB
~70K SLoC