Skip to content

examples: add simulated vision position feed - #820

Draft
alireza787b wants to merge 1 commit into
mavlink:mainfrom
alireza787b:add-vision-odometry-example
Draft

examples: add simulated vision position feed#820
alireza787b wants to merge 1 commit into
mavlink:mainfrom
alireza787b:add-vision-odometry-example

Conversation

@alireza787b

@alireza787b alireza787b commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a simulator-only example that feeds external-vision position data to PX4
through MAVSDK's Mocap plugin.

  • reads the simulator's ground_truth() global position stream
  • converts nearby WGS84 coordinates to a local NED frame
  • applies configurable position noise and sample delay
  • publishes VISION_POSITION_ESTIMATE at 30 Hz
  • enables only horizontal and vertical external-position fusion
  • monitors PX4 local-position validity without claiming that it proves fusion

The script does not arm, take off, change modes, or otherwise control the
vehicle. It saves and restores the existing EKF2_EV_CTRL value.

Measurement model

MAVSDK's simulator ground-truth stream provides independent position, but not
independent attitude or velocity. The example therefore sends position only.
It does not feed PX4's own EKF estimate back as a measurement, reinterpret NED
velocity as body-frame velocity, or enable yaw fusion without a yaw source.

VISION_POSITION_ESTIMATE is used because it is a documented PX4 NED input
that matches the measurements available from this source. A real VIO or motion
capture integration should replace the simulator source and provide every
enabled measurement in its documented frame.

Delay

DELAY_MS delays sample delivery. To evaluate EKF delay compensation, set
EKF2_EV_DELAY accordingly and reboot PX4 before running the example.

Validation

  • ruff format --check --line-length=100 examples
  • ruff check --select=ASYNC,RUF006,E,F --line-length=100 examples
  • ruff check --select=PERF --line-length=100 .
  • codespell .
  • Python bytecode compilation
  • WGS84-to-local-NED numerical check
  • generated MAVSDK object and protobuf serialization check
  • fake ground-truth stream integration check

The branch is rebased on current main and contains one commit.

JonasVautherin
JonasVautherin previously approved these changes Mar 10, 2026

@JonasVautherin JonasVautherin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@alireza787b

Copy link
Copy Markdown
Contributor Author

Thanks for the review Jonas! Just pushed a small update renaming qualityquality_percent to match the proto change from your feedback on #395.

julianoes
julianoes previously approved these changes Mar 30, 2026

@julianoes julianoes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to be merged? The todos in the PR description aren't ticked, so I'm not so sure.

@alireza787b

Copy link
Copy Markdown
Contributor Author

Hey Juliano, not yet. You are right that the description there was stale, thanks for flagging it. I just cleaned that up. This example is waiting on the fresh proto PR (MAVSDK-Proto#404) and then the clean replacement MAVSDK PR for the mocap wiring. After that I still want to do one final pass on the example itself before calling it merge-ready.

Convert simulator ground truth to a local NED frame and publish it through MAVSDK's vision-position API with configurable noise and delay. Fuse only the position fields supplied by the source, preserve EKF2_EV_CTRL, and leave flight control to a separate client.
@alireza787b
alireza787b force-pushed the add-vision-odometry-example branch from fc98488 to b73cd87 Compare July 31, 2026 07:53
@alireza787b alireza787b changed the title examples: add vision odometry example examples: add simulated vision position feed Jul 31, 2026
@alireza787b

Copy link
Copy Markdown
Contributor Author

The upstream mocap dependencies have landed, so I completed the final validation pass and rebased this branch on current main.

That pass found two correctness problems in the earlier example: it used PX4's estimated position_velocity_ned() as the external measurement source, and it placed NED velocity in body-frame fields. The refreshed example now reads simulator ground_truth(), sends only the independent position data available from that source through VISION_POSITION_ESTIMATE, and restores the user's original EKF2_EV_CTRL value on exit.

This is a substantive rewrite, so the earlier approval should not be treated as covering the new revision. The branch is now one commit, the local style/serialization checks listed in the description pass, and fresh CI is running. A new review would be appreciated when it completes.

@alireza787b
alireza787b marked this pull request as draft August 1, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants