How rl-tools/px4 works
This repository adds RLtools control modules and supporting workflows to PX4. In flight, the policy consumes vehicle state and commands, produces motor outputs, and the multiplexer selects between those outputs and the original controller. The README also documents command/trajectory control, inference benchmarking, external position-reference forwarding, and system-identification analysis. The graph includes these major capabilities; some links for unsampled modules are dashed because their runtime wiring is not shown in the excerpts.
Main entry points: RLtoolsPolicy.cpp RLtools policy · actuator_motors_multiplexer.cpp Motor multiplexer · main.js Analysis UI · RLtoolsCommander.cpp RLtools commander
Components 20
Flight control
- RLtools policy
external_modules/src/modules/rl_tools_policy/RLtoolsPolicy.cpp - Policy adapter
external_modules/src/modules/rl_tools_policy/rl_tools_adapter.cpp - RL motor output
- Motor multiplexer
external_modules/src/modules/actuator_motors_multiplexer/actuator_motors_multiplexer.cpp
Control tools
- RLtools commander
external_modules/src/modules/rl_tools_commander/RLtoolsCommander.cpp - Trajectory setpoints
- Inference benchmark
external_modules/src/modules/rl_tools_benchmark/RLtoolsBenchmark.cpp - Benchmark model
external_modules/src/modules/rl_tools_benchmark/model.h
System identification
- Log analysis
sysid/analyze.py - Browser processing
sysid/process.py - ULog loader
sysid/load_ulg.py - Analysis UI
sysid/static/main.js
Position feedback
- ROS to MAVLink
tools/external_position_reference/forward_ros_to_mavlink.py - PX4 position estimate
Other components
- Pilot / QGC
- Vehicle state
- PX4 controller
- Selected motor output
- PX4 flight logs
- Motion capture
Connections 16
- Vehicle state → RLtools policy: provides state
external_modules/src/modules/rl_tools_policy/RLtoolsPolicy.cpp - RLtools policy → Policy adapter: uses adapter
- RLtools policy → RL motor output: publishes motors
external_modules/src/modules/rl_tools_policy/RLtoolsPolicy.cpp - RL motor output → Motor multiplexer: feeds motors
- PX4 controller → Motor multiplexer: provides motors
- Motor multiplexer → Selected motor output: publishes selection
external_modules/src/modules/actuator_motors_multiplexer/actuator_motors_multiplexer.cpp - Pilot / QGC → Motor multiplexer: activates policy
README.MD - Pilot / QGC → RLtools commander: issues commands
README.MD - RLtools commander → Trajectory setpoints: publishes setpoints
external_modules/src/modules/rl_tools_commander/RLtoolsCommander.cpp - Trajectory setpoints → RLtools policy: supplies commands
- Inference benchmark → Benchmark model: evaluates model
external_modules/src/modules/rl_tools_benchmark/RLtoolsBenchmark.cpp - PX4 flight logs → Log analysis: analyzes logs
- Analysis UI → Browser processing: loads processing
sysid/static/main.js - Analysis UI → ULog loader: loads ULog loader
sysid/static/main.js - Motion capture → ROS to MAVLink: sends position
README.MD - ROS to MAVLink → PX4 position estimate: forwards MAVLink
README.MD