Skip to content

rust(feat): add a MAVLink tlog replay example to sift_stream - #895

Open
Mattbusel wants to merge 1 commit into
sift-stack:mainfrom
Mattbusel:use-mavlink-tlog
Open

Mattbusel wants to merge 1 commit into
sift-stack:mainfrom
Mattbusel:use-mavlink-tlog

Conversation

@Mattbusel

Copy link
Copy Markdown

Sift's import examples cover CSV, HDF5, MCAP and Parquet, but nothing for MAVLink, which is what PX4 and ArduPilot vehicles speak. The usual drone flight record is a .tlog from QGroundControl, Mission Planner or MAVProxy: every MAVLink frame behind the microsecond time the ground station got it. Today a Sift user with one of those has to write their own MAVLink framer before they can stream anything.

This adds rust/crates/sift_stream/examples/mavlink-tlog/main.rs:

  • reads the tlog with mavlink-tlog and decodes frames with the mavlink crate (common dialect only)
  • sends GLOBAL_POSITION_INT, ATTITUDE and SYS_STATUS as three flows, in degrees, metres, m/s, volts, amps and percent, each with the frame's recorded timestamp, not TimeValue::now()
  • fields the vehicle marks as unknown (heading 65535, battery -1) are left empty instead of being sent as junk
  • a fourth link flow sends received / lost / duplicate frame counts and loss % once per second of log time, worked out from MAVLink sequence numbers, so link health shows up next to the flight data
  • MAVLINK_SYSTEM_ID picks the vehicle (default 1), SIFT_ASSET_NAME names the asset

mavlink and mavlink-tlog are added as dev-dependencies of sift_stream only (and to [workspace.dependencies]), so nothing changes for anyone depending on sift_stream.

How I checked it: I ran the example's replay function against the mock server in tests/common with a recording IngestService, on three logs:

log frames requests sent = received by server link result
rust-mavlink log.tlog (real recording, 11.5 s) 1,426 121 0 lost; last timestamp 1632843981.303145 s, same as pymavlink reads it
ArduPilot SITL, GPS glitch 25k from the vehicle 2,756 31 lost (0.12%), 2 duplicates
ArduPilot SITL, GCS failsafe 150k from the vehicle 17,073 0 lost, 3 duplicates

cargo test -p sift_stream --all-features passes, and cargo clippy -p sift_stream --all-targets --all-features and cargo fmt --check --all are clean.

I maintain mavlink-tlog (MIT, MSRV 1.70, no dependencies). It checks the CRC of every message in MAVLink's all.xml, recovers from damaged logs, and its counts are tested against pymavlink. I'll keep it current.

I saw CONTRIBUTING says outside PRs get closed. If you'd rather re-land this yourselves the way #469 went in as #474, that's completely fine with me.

This branch has not been deployed

No deployments
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.

1 participant