Johnliu/optitrack emulation#367
Draft
JohnYanxinLiu wants to merge 34 commits into
Draft
Conversation
…handlers Refactor the emulator server around a pre-packed MODELDEF wire cache and add the NAT_REQUEST_MODELDEF and NAT_KEEPALIVE handlers so libNatNet 4.4 clients complete the unicast handshake. Mock a real Motive server (server name "Motive") and move hardcoded Drone reference constants into a new defaults.py so scene semantics stay out of the wire layer. Drop the vendored NatNet SDK README that should not live in-tree. Co-authored-by: Cursor <cursoragent@cursor.com>
…defaults Cover the MODELDEF/frame serializers, the unicast handshake protocol, and the defaults/server catalog. A package-level test/conftest.py puts the extension root on sys.path and registers the `unit` marker so `pytest test/` runs the suite directly without per-file boilerplate. Co-authored-by: Cursor <cursoragent@cursor.com>
…ture Add repo_path() and reexport_unit_tests() to tests/conftest.py so the thin proxy files re-export co-located package tests without hardcoded Path(__file__).parents[N] walks or per-file sys.path boilerplate; rewrite the robot and sim proxies to use them. Register the `integration` marker and the robot_autonomy_stack bring-up fixture (gated behind --run-integration) for the new integration tier. Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce tests/integration/ as a new tier between unit and system: real components wired together (robot autonomy container + a host-side component) with no sim or GPU. Move the NatNet emulator <-> natnet_ros2 test here as the first resident (marks: integration, natnet), driven by the shared robot_autonomy_stack fixture, and remove the old tests/sim/motive_emulator location. Co-authored-by: Cursor <cursoragent@cursor.com>
Update AGENTS.md, tests/README.md, and the add-unit-tests / optitrack-development skills to describe the four test tiers (unit, integration, system), the repo_path/reexport_unit_tests proxy pattern, the --run-integration flag, and the new tests/integration/natnet location. Co-authored-by: Cursor <cursoragent@cursor.com>
NatNet emulator installation is baked into the isaac-sim image, bind-mounted for live edits, and enabled in Kit config. Co-authored-by: Cursor <cursoragent@cursor.com>
Remap vision_pose_converter to the interface/mavros namespace, install mavros_extras in the robot image, and add layered PX4_PARAM_PROFILE env files so Isaac SITL can fuse NatNet external vision (EKF2_EV_CTRL, no GPS, indoor mag disabled). Document the vision profile and provide an overrides bundle for NatNet + vision sim bring-up. Co-authored-by: Cursor <cursoragent@cursor.com>
PX4 with EKF2_GPS_CTRL=0 has valid local vision fusion but no global position, so AUTO.LOITER preflight fails until an origin is set. Add mavros_gp_origin_node to publish a one-shot set_gp_origin after MAVROS connects, skipping when a real origin already exists. Launched alongside vision_pose_converter when publish_to_mavros is enabled. Co-authored-by: Cursor <cursoragent@cursor.com>
…vertised tolerances
9a6a546 to
d6c6ef4
Compare
d6c6ef4 to
83b5929
Compare
926b715 to
9ce2bfb
Compare
23428fb to
dfe7f17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What features did you add and/or bugs did you address?
Which GitHub issue does this address?
N/A
Additional description if not fully described in the GitHub issue
Optitrack (MoCAP) NatNet protocol implementation:
robot client (natnet_ros2)
Isaac Sim Motive emulator
protocol handshake
and libNatNet 4.4 unicast mocked server behavior.
Please add videos and images to demonstrate the feature. Please upload videos to somewhere persistent (e.g. YouTube or Vimeo) for archival purposes.
N/A
How did you implement it?
How do you run and use it?
The recommended way to exercise the full feature set — multi-drone NatNet vision-pose — also covers the single-drone case.
Bring up the full stack
This starts 3 robot containers and Isaac Sim running
example_multi_px4_pegasus_natnet_launch_script.pywithLAUNCH_NATNET=trueandSITL_PARAM_PROFILE=px4-vision. Wait until Isaac Sim reaches the Pegasus "Play" state and the robot containers report ROS 2 nodes live.Verify NatNet topics are publishing
For each drone, confirm the OptiTrack rigid-body pose is being received and published:
Expected: all topics publishing at ~120 Hz (NatNet stream rate).
Step 3 — Verify local odometry is updating
Check that the
x,y,zvalues in the pose field match the spawn positions of the drones in Isaac Sim (drones spawn spaced along the X axis at the same interval). Confirm values are updating as the simulation runs.Step 4 — Takeoff all drones via Foxglove
Open Foxglove (GCS) and connect to
ws://localhost:8765. For each robot:ros2 topic echo /robot_N/odometry --oncereportsz ≈ 10.0.Step 5 — Run the random walk navigation planner
With all drones hovering, trigger the navigation task using the random walk (exploration) planner from the Foxglove GCS panel. Verify that:
status: navigatingfeedback appears in the GCS for each robot.Teardown
Testing with PyTest
What pytests were added?
robot/ros_ws/src/perception/natnet_ros2/test/test_natnet_logic.cpp— C++ unit tests for thenatnet_logic.hppstate machine (body fan-out, tracking-valid gating, covariance injection, multi-body profiles).robot/ros_ws/src/perception/natnet_ros2/test/test_natnet_ros2.py— Python unit tests forVisionPoseConverterNode(quaternion canonicalisation, configurable-topic wiring) andnatnet_ros2.launch.pyprofile-flattening helpers (env expansion, body array construction, namespacing).simulation/isaac-sim/extensions/optitrack.natnet.emulator/test/— 17 unit tests covering the emulator serializers, unicast handshake protocol, MODELDEF catalog, pose sampling, scene setup, and server lifecycle.tests/integration/natnet/test_natnet_integration.py— 3 integration tests: (1) rawNatNetUnicastServerhand-built single-body frames →natnet_ros2_nodein the robot container; (2)NatNetServerManagersampling an in-memory USD stage; (3) multi-body profile (drone + target) exercising per-body topic overrides and pose/pose_cov toggles. Metric: all body topics must publish at ≥ 5 Hz for 12 s.Exact commands:
CI system tests (GPU runner) — trigger via PR comment:
PASSED; C++ tests reported bycolcon test, Python tests by pytest.test_natnet_pose_hzvariants eachPASSED; check the per-test Hz measurement logged to stdout (should be ≥ 5 Hz).liveliness: all containers healthy,/clockactive, sentinel ROS 2 nodes present for allNUM_ROBOTS.sensors: camera, LiDAR, and (whenLAUNCH_NATNET=true)vision_posetopics all stream at expected Hz; checkmetrics.jsonHz values and the CI PR comment diff vs baseline.takeoff_hover_land: drone completes all 4 phases (PX4-ready → takeoff → hover → land) without coordinate errors; pass/fail visible in the CI PR comment.Documentation
natnet_ros2README,docker-build-profiles.md,unit_testing.md, OSMO tutorial, andtests/integration/docs to navigation.robot/ros_ws/src/perception/natnet_ros2/README.mdfor NatNet setup (sim and real hardware),docs/tutorials/airstack_on_osmo.mdfor cloud-GPU dev, anddocs/development/intermediate/testing/unit_testing.mdfor the test proxy pattern; agent skills (optitrack-development,add-unit-tests) are updated.Versioning
.envfile according to semantic versioning?Yes