UAT 322 Artificial Intelligence and Autonomous Unmanned Aircraft Systems Integration Laboratory

Worksheet 1 Connecting a companion computer to PX4 SITL

Lab 12 hAssesses CLO1, CLO3

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

  1. Install the software at the versions PX4 specifies; record every version
  2. Run MicroXRCEAgent udp4 -p 8888 and check position and status topics appear in ROS 2
  3. Write a node that streams setpoints before switching into Offboard
  4. Command a hover at an ENU target converted to NED with Example 1
  5. Stop the node mid-flight; measure from the log when PX4 left Offboard and compare with COM_OF_LOSS_T
  6. Measure the command-path latency with timestamps on both sides and record it

Record of results

Table 1 ENU targets converted to NED and the real hover position in SITL
ENU target (east, north, up) mNED setpoint sent (north, east, down) mYaw ENU and NED (deg)Real hover position from log (NED) mOn target?
Table 2 Stopping the node mid-flight
RunLast setpoint time (s)Offboard exit time (s)Time without commands (s)COM_OF_LOSS_T (s)Mode after exit
Table 3 Command-path latency against the budget
Segment measuredMedian (ms)p95 (ms)Lesson budget value (ms)Distance moved at 5 m/s (m)

Questions

  1. 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.

  2. 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?

  3. 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?

  4. 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

CLO1 Integrate control, navigation and sensors. CLO3 Test safely in simulation and the field. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack