Skip to content

feat(drone): integrate PX4 autonomous navigation drone and SITL simulation - #3458

Open
weyne-Jiang wants to merge 13 commits into
mainfrom
weyne/feat/px4
Open

feat(drone): integrate PX4 autonomous navigation drone and SITL simulation#3458
weyne-Jiang wants to merge 13 commits into
mainfrom
weyne/feat/px4

Conversation

@weyne-Jiang

@weyne-Jiang weyne-Jiang commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Contribution path

Demonstration

PX4 real-world flight PX4 SITL simulation
PX4 hardware frontend PX4 SITL simulation frontend

Problem

DimOS did not have a dedicated PX4 drone stack. The existing drone modules were primarily DJI-specific and did not provide MAVSDK-based flight control, PX4 SITL integration, external vision input, or the camera pipeline required by the PX4 hardware and Gazebo workflows.

Solution

Added a dedicated PX4 stack while moving the existing DJI implementation into its own dji package.

The PX4 integration includes:

  • MAVSDK connection, telemetry, arming, takeoff, landing, hold, and offboard velocity control.
  • PointLIO odometry forwarding as MAVSDK external vision estimates.
  • Livox MID-360 mounting transforms and voxel-map integration.
  • A configurable GStreamer tee pipeline publishing BGR images and Annex-B H.264 typed streams.
  • px4-basic, px4-agentic, and px4-gazebo-harmonic blueprints.
  • Gazebo Harmonic SITL support using the simulated RTP camera stream.
  • PX4 hardware, simulation, remote-control, and troubleshooting documentation.
  • Focused tests for blueprint configuration, external vision conversion, camera pipelines, and mounting transforms.

The Gazebo simulation scene is based on PX4-AeroFusion-Sim, with adaptations for the camera workflow used by the DimOS PX4 blueprint.

Hardware configuration

Custom PX4 quadrotor

The PX4 integration was developed and validated on the following hardware:

  • MicroAir743 V2 PX4 flight controller
  • Custom 10-inch quadrotor frame with a 440 mm wheelbase
  • FlyingRC 4-in-1 power distribution board
  • DJI Phantom ESCs
  • 2212 brushless motors
  • EOLO 1038 self-locking propellers
  • 4S2P EVE JP40 battery pack
  • NVIDIA Jetson Orin NX 8GB with a Damiao carrier board
  • Livox MID-360 LiDAR
  • USB webcam
  • MicoAir TRS receiver and RF module
  • RadioMaster TX15 transmitter
  • No gimbal or depth camera

How to Test

Follow the hardware and simulation procedures in the PX4 Module Quick Start.

Validated on the hardware configuration listed above:

  • Flight control and remote-control responses operated in real time.
  • Video streaming remained smooth through dimos-viewer over the Wi-Fi LAN.
  • PointLIO mapping operated normally with no observable localization drift.
  • Gazebo Harmonic SITL flight control, RTP video, and viewer integration operated normally.

Automated validation:

  • PX4 tests: 18 passed.
  • Blueprint registry test: passed.
  • Ruff and mypy checks: passed.
  • Fresh frozen dependency installation: passed.
  • GStreamer H.264 encoding and decoding pipeline: passed on Ubuntu 24.04.

AI assistance

Codex with GPT-5.6 Sol was deeply involved in implementation, debugging, testing, and documentation. All changes were reviewed, understood, and validated by the contributor.

Checklist

  • I have read and approved the CLA.

weyne and others added 5 commits August 13, 2026 17:32
Flight control:
- call MAVSDK APIs directly and remove the runtime adapter layer
- move module configuration and PX4-specific errors into flight_control.py
- simplify FLU/FRD command conversion, telemetry state, lifecycle cleanup, and status RPC
- make hold enter the PX4 Hold flight mode and annotate movement skills with CAP_MOVEMENT
- keep handler binding local to FlightController so the Gazebo blueprint can omit odometry without changing core Module behavior

External vision and MID360:
- preserve the hardware-verified odom -> mid360_link -> base_link contract
- derive the body pose with the calibrated inverse mount transform before MAVSDK vision forwarding
- retain quaternion, timestamp, covariance, and frame validation including lever-arm covariance conversion
- collapse the mount publisher to the single calibrated transform implementation

GStreamer camera:
- replace the multi-layer dynamic GStreamer abstraction with one GsTeeCamera module using Gst directly
- accept trusted raw or H.264 input pipelines and always publish BGR over pSHM plus Annex-B H.264 over typed LCM
- support NVV4L2 and X264 encoder settings, reject silently ignored H.264 options, and release the pipeline deterministically
- retain focused behavior tests for pipeline construction and encoder configuration

Blueprints and visualization:
- consolidate PX4 basic and Gazebo Harmonic blueprints in px4_basic.py and remove obsolete debug blueprints
- add the px4-agentic MCP blueprint with a PX4-specific safety prompt
- inline PX4 camera and Rerun configuration, keep lidar visualization at 5 Hz, and isolate the static drone entity from TF paths
- give Gazebo a video-only Rerun layout because it has no PointLIO mapping stack
- regenerate the built-in blueprint and module registry

Cleanup, review fixes, and docs:
- remove obsolete config, frame, camera, runtime, GStreamer adapter, debug, and redundant test files
- revert the reviewed core Module change to match main and keep PX4-specific behavior within the PX4 package
- preserve the tested VisionPositionEstimate interface required by current PX4 firmware
- relocate the DJI README, add complete English and Chinese PX4 guides, and document hardware, native builds, simulation, video, frames, and full startup commands

Validation:
- uv run pytest dimos/robot/drone/px4 -q (18 passed)
- CI=1 uv run pytest dimos/robot/test_all_blueprints_generation.py -q (1 passed)
- uv run ruff check dimos/robot/drone/px4
- uv run mypy on the five changed PX4 source modules
- git diff --check
@github-actions github-actions Bot added the first-time-contributor PR opened by an author who had not previously committed to this repository label Aug 13, 2026
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.76891% with 145 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
dimos/robot/drone/dji/test_drone.py 21.79% 61 Missing ⚠️
dimos/robot/drone/px4/flight_control.py 85.57% 42 Missing and 3 partials ⚠️
...imos/robot/drone/px4/blueprints/basic/px4_basic.py 36.66% 19 Missing ⚠️
dimos/robot/drone/px4/gstreamer_tee_camera.py 91.72% 6 Missing and 6 partials ⚠️
dimos/robot/drone/px4/test_flight_control.py 98.73% 2 Missing and 1 partial ⚠️
.../robot/drone/px4/blueprints/agentic/px4_agentic.py 71.42% 2 Missing ⚠️
dimos/robot/drone/px4/test_gstreamer_tee_camera.py 98.37% 1 Missing and 1 partial ⚠️
dimos/robot/drone/px4/mid360_mount_tf.py 90.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3458      +/-   ##
==========================================
+ Coverage   74.05%   76.11%   +2.06%     
==========================================
  Files        1283     1231      -52     
  Lines      124704   119675    -5029     
  Branches    11141    10723     -418     
==========================================
- Hits        92349    91092    -1257     
+ Misses      29493    25495    -3998     
- Partials     2862     3088     +226     
Flag Coverage Δ
OS-ubuntu-24.04-arm 70.55% <84.55%> (+0.11%) ⬆️
OS-ubuntu-latest 72.32% <84.55%> (+0.10%) ⬆️
Py-3.10 72.31% <84.55%> (+0.10%) ⬆️
Py-3.11 72.32% <84.55%> (+0.10%) ⬆️
Py-3.12 72.32% <84.55%> (+0.10%) ⬆️
Py-3.13 72.32% <84.55%> (+0.10%) ⬆️
Py-3.14 72.32% <84.55%> (+0.10%) ⬆️
Py-3.14t 72.32% <84.55%> (+0.09%) ⬆️
SelfHosted-Large 29.73% <25.71%> (+0.02%) ⬆️
SelfHosted-Linux 35.76% <26.15%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
dimos/robot/all_blueprints.py 100.00% <ø> (ø)
...obot/drone/dji/blueprints/agentic/drone_agentic.py 100.00% <100.00%> (ø)
...os/robot/drone/dji/blueprints/basic/drone_basic.py 68.42% <100.00%> (ø)
dimos/robot/drone/dji/camera_module.py 27.61% <ø> (ø)
dimos/robot/drone/dji/connection_module.py 62.28% <100.00%> (ø)
dimos/robot/drone/dji/dji_video_stream.py 38.26% <ø> (ø)
dimos/robot/drone/dji/drone_tracking_module.py 23.43% <100.00%> (ø)
...obot/drone/dji/drone_visual_servoing_controller.py 76.92% <ø> (ø)
dimos/robot/drone/dji/mavlink_connection.py 44.51% <ø> (ø)
dimos/robot/test_all_blueprints.py 87.50% <100.00%> (ø)
... and 8 more

... and 84 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weyne-Jiang weyne-Jiang changed the title Weyne/feat/px4 feat(drone): add PX4 MAVSDK hardware and Gazebo stack Aug 13, 2026
Remove PyPI PyGObject from the drone extra and lockfile so CI no longer builds PyGObject and pycairo before tests.

Document the Ubuntu 24.04 python3-gi, GStreamer GIR/plugin packages, and system-site-packages uv environment required by GsTeeCamera.

Pass reset_counter=0 to MAVSDK 3.17.2 VisionPositionEstimate after reproducing the required constructor argument in a fresh locked Ubuntu 24.04 environment.
Remove the forbidden PX4 package initializer and bare underscore assignments flagged by repository checks. Add behavior-focused MAVSDK flight-control tests for commands, frame conversion, telemetry, connection timeout, and shutdown. Expand GStreamer tee coverage for raw and H.264 publication, pipeline construction, and failure cleanup, and cover non-finite external-vision samples. Keep GStreamer config enums compatible with the project's Python 3.10 lower bound.
@weyne-Jiang weyne-Jiang changed the title feat(drone): add PX4 MAVSDK hardware and Gazebo stack feat(drone): integrate PX4 autonomous navigation and SITL simulation Aug 14, 2026
@weyne-Jiang weyne-Jiang changed the title feat(drone): integrate PX4 autonomous navigation and SITL simulation feat(drone): integrate PX4 autonomous navigation drone and SITL simulation Aug 14, 2026
Reuse one real FlightController and GsTeeCamera instance per test module while resetting mocked MAVSDK and GStreamer state between cases. This preserves the default Module RPC lifecycle without repeatedly starting LCM for every test.

Consolidate the essential external-vision contracts into the flight-control suite and remove redundant blueprint and static-transform test files. The focused suite now keeps behavior coverage with fewer module constructions and less CI lifecycle churn.
Make move commands return to zero velocity when callers stop refreshing the setpoint. Repeated move calls replace the previous watchdog task, while PX4 mode-changing actions remain able to interrupt Offboard control directly. Add deterministic lifecycle and timeout tests, and document the user-visible move behavior.
@github-actions github-actions Bot added the ready-to-merge Required CI checks have passed on this PR label Aug 17, 2026
@weyne-Jiang weyne-Jiang linked an issue Aug 18, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR opened by an author who had not previously committed to this repository PlzReview ready-to-merge Required CI checks have passed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autonomous Navigation Drone Setup and DIMOS Integration Testing

1 participant