UAT 322 Artificial Intelligence and Autonomous Unmanned Aircraft Systems Integration Laboratory
Worksheet 1 Connecting a companion computer to PX4 SITL
Objective
Link ROS 2 to PX4 over uXRCE-DDS, command an Offboard hover in the right frame, and measure behaviour on command loss and real latency
Equipment and materials
- Linux computer with PX4 SITL, Gazebo and ROS 2 at the documented versions
- MicroXRCEAgent
- Example code at /downloads/uat-322/
- Lab notebook
Safety
- Simulation only; no real flights
- Never run Offboard code on a real drone before it passes simulation
Steps
- Install the software at the versions PX4 specifies; record every version
- Run MicroXRCEAgent udp4 -p 8888 and check position and status topics appear in ROS 2
- Write a node that streams setpoints before switching into Offboard
- Command a hover at an ENU target converted to NED with Example 1
- Stop the node mid-flight; measure from the log when PX4 left Offboard and compare with COM_OF_LOSS_T
- Measure the command-path latency with timestamps on both sides and record it
Record of results
| ENU target (east, north, up) m | NED setpoint sent (north, east, down) m | Yaw ENU and NED (deg) | Real hover position from log (NED) m | On target? |
|---|---|---|---|---|
| Run | Last setpoint time (s) | Offboard exit time (s) | Time without commands (s) | COM_OF_LOSS_T (s) | Mode after exit |
|---|---|---|---|---|---|
| Segment measured | Median (ms) | p95 (ms) | Lesson budget value (ms) | Distance moved at 5 m/s (m) |
|---|---|---|---|---|
Questions
If you forgot to convert the ENU target (10, 5, 3) and sent it straight to PX4, where would the drone try to go, and why is that dangerous? Use your Table 1 results.
From Table 2, was the time without commands before PX4 left Offboard longer or shorter than COM_OF_LOSS_T, and what did the drone do in that time? If it were flying at 5 m/s, how far would it travel?
Compare the latency you measured in Table 3 with the lesson's 97 ms budget. Which stage should be shortened first, and why can SITL figures on one computer not stand in for the real board?
Why must the failsafe for lost commands live in the flight controller and not in a node on the companion computer? Refer to what you saw when you stopped the node.
Check before you hand in
What to hand in
- Lab notebook with software versions
- ROS 2 node code
- Offboard-exit timing against the parameter
- Latency against the budget