Test MC_11 - Companion Computer (ROS 2 External Mode)
Objective
To test autonomous flight commanded from a companion computer using the PX4 ROS 2 Interface Library over the uXRCE-DDS or Zenoh bridge.
The test runs the library's go-to example, which registers an external flight mode named Go-to Example and flies a fixed triangular pattern (about 20 m x 30 m) relative to the position where the mode is engaged, at constant altitude. This exercises external mode registration, setpoint configuration, go-to setpoint streaming, and mode completion signalling across the bridge.
Preflight
Companion computer setup (once):
- Connect a companion computer to the flight controller and start the bridge:
- Set up a ROS 2 workspace on the companion computer with
px4_msgsand the interface library, following steps 1 to 3 of PX4 ROS 2 Control Interface > Installation and First Test (skip the SITL steps). The go-to example is built as part of the workspace (packageexample_mode_goto_cpp). - Use a recent QGroundControl (Daily), which supports dynamically updating the list of flight modes.
Before flight:
Start the example on the companion computer:
shros2 run example_mode_goto_cpp example_mode_gotoConfirm the console shows the registration succeeding (
Registering 'Go-to Example'followed byGot RegisterExtComponentReply)Confirm Go-to Example shows up in the QGC flight mode list
Confirm the airspace is clear roughly 20 m north and 30 m east of the planned engage position (the pattern is flown from wherever the mode is engaged)
Flight Tests
❏ Mode registration
❏ With the vehicle disarmed, stop and restart the example node
❏ Go-to Example disappears from and reappears in the QGC mode list
❏ Go-to Example mode
❏ Arm and take off in Position mode, climb to a safe altitude (10 m or more)
❏ Select Go-to Example in QGC (mode must engage on first attempt, no rejection message)
❏ Vehicle settles at the engage position, then flies north facing the direction of travel
❏ Vehicle flies the east leg while spinning around yaw, slowing down as it approaches the corner
❏ Vehicle returns to the engage position with the heading fixed on the first corner
❏ On completion the vehicle holds position; switch back to Position or Hold mode
❏ Re-engagement
❏ Fly to a different location and engage Go-to Example again
❏ The same pattern is flown relative to the new engage position
❏ Companion loss failsafe
❏ Engage Go-to Example once more and stop the example node (Ctrl-C) mid-pattern
❏ Vehicle triggers a failsafe and switches to Hold; QGC shows a corresponding warning
❏ Land and disarm
Expected Results
- The external mode appears in QGC while the node is running and can be engaged on the first attempt
- Transitions into and out of the mode are smooth, with no twitches or setpoint jumps
- The triangular pattern is tracked accurately at constant altitude
- Stopping the node while the mode is active triggers a failsafe into Hold
- The log shows the pattern portion of the flight in the external mode (check in Flight Review)
- Attach the flight log and the example's console output to the test report