Module 5/5 · Weeks 13–15 · 27 h

Robots and drones

DRT 344 Automation, Robotics and Intelligent Control Systems

About 90 minDraft, awaiting reviewLast updated 26 September 2026

Lesson

By the end of this module you will be able to

  1. Explain the core ROS 2 concepts of nodes, topics, services, actions and QoS
  2. Explain how ROS 2 connects to PX4 through uXRCE-DDS, and the role of MAVROS
  3. Convert coordinates between NED and ENU frames
  4. Calculate the latency budget of a data chain from sensor to flight controller
  5. Design an architecture integrating drones, robots and automation

Prerequisites: DRT 344 modules 1–4

Why this matters

Drones running complex missions, such as detecting objects with AI and following them automatically, usually split the work in two: a flight controller that keeps flight safe (PX4 or ArduPilot), and a companion computer that runs heavy work such as AI, mapping and planning. The middleware that ties these together, and connects them to ground robots, is ROS 2. Data going up to a control centre or industrial systems uses MQTT or OPC UA (module 1).

ROS 2 is like a robot’s nervous system. Each organ (node) sends signals along nerves (topics) without needing to know who receives them, so organs can be added or replaced without rebuilding the whole system.

Core ROS 2 concepts

ConceptMeaningExample in drone work
NodeOne program doing a specific jobCamera node, object-detection node, planner node
TopicA continuous publish/subscribe data channelCamera images, drone position
ServiceA one-off request and responseRequest a flight-mode change
ActionA long-running task with feedback that can be cancelledFly to a position and report progress
QoSDelivery policy, e.g. reliable or fast, how many messages to keepSensor data uses the sensor-data QoS profile

ROS 2 releases a new distribution every May. On the date checked (26 September 2026), supported distributions were Humble Hawksbill (to May 2027), Jazzy Jalisco (to May 2029), Kilted Kaiju (to December 2026) and Lyrical Luth, released 22 May 2026 (to May 2031). Long-running projects should choose a long-support distribution and pin versions to those supported by the flight stack’s documentation.

Connecting ROS 2 to the flight controller

A camera node, an AI object-detection node and a mission-planner node exchange data through ROS 2 topics, services and actions over DDS with a uXRCE-DDS agent, which links to PX4 over serial or UDP, with conversion between ENU/FLU and NED/FRD frames
Figure 1 ROS 2 linked to PX4 via uXRCE-DDS
  • PX4 uses the uXRCE-DDS middleware: a client on PX4 and an agent on the companion computer exchange data both ways over serial, UDP or TCP, so PX4’s internal topics appear directly as ROS 2 topics. The PX4 guide recommends ROS 2 Jazzy on Ubuntu 24.04, or Humble on Ubuntu 22.04
  • MAVROS bridges the MAVLink protocol and ROS 2 for any MAVLink flight controller, supporting Humble and newer
  • ArduPilot has its own ROS 2 documentation; follow the method matching your software version

Different coordinate frames

The PX4 guide states that PX4 uses a NED world frame (x north, y east, z down) and an FRD body frame (forward, right, down), while ROS uses ENU (x east, y north, z up) and FLU (forward, left, up) per REP 105. Any node talking to PX4 must convert frames every time. Forget, and the drone may fly the wrong way or descend instead of climb.

Example 1 Converting a position from NED to ENU

PX4 reports a NED position of m: 10 m north, 5 m east and 3 m up (D is negative).

In ENU: m

If a ROS 2 node wants the drone at ENU but sends those numbers to PX4 unconverted, PX4 reads N = 5, E = 10, D = 3, which is 3 m below the take-off point: the horizontal axes are swapped and the vertical direction reversed, so the drone tries to fly into the ground. This mistake is very common, so use the px4_ros_com frame-transform library and always test in SITL first.

Latency budget

A system that detects with AI and then commands the drone must add up the latency of every stage in the data chain, while the drone keeps moving.

Example 2 How far does the drone move before the command arrives?

The chain’s latencies: image into the node 5 ms, AI detection 12 ms, topic to the planner node 3 ms, and uXRCE-DDS over serial to PX4 8 ms. The drone flies at 10 m/s.

  1. ms
  2. m

That 0.28 m must be included in the avoidance margin. A much slower AI model increases it, and message queues backing up in MQTT or ROS 2 can make data stale (see the MQTT deep-dive knowledge unit on data freshness and queues).

Integration architecture

Four layers from top to bottom: control centre, cloud and dashboards linked by MQTT or OPC UA; mission computers running ROS 2 linked by DDS; flight controller, PLC and robot controller linked by MAVLink, uXRCE-DDS or fieldbus; and at the bottom drones, conveyors and chargers, and ground robots
Figure 2 Architecture for integrating drones, robots and automation

Design principles:

  1. Separate safety-critical functions from mission functions, so flight controllers and PLCs stay safe on their own even if mission computers or networks fail
  2. Choose protocols by layer: DDS/ROS 2 inside robots, MQTT or OPC UA to enterprise systems, MAVLink or uXRCE-DDS to flight controllers
  3. Secure every layer: encrypt and authenticate, especially channels that can command real equipment
  4. Design for testing: use SITL and simulation before connecting real hardware
Use caseComponents working together
Smart warehouseBarcode-reading drones, carrier robots, warehouse management system (ISA-95 level 3)
Automated dockPLC opens the lid and charges; drones fly on schedule; control centre via MQTT
Infrastructure inspectionDrones image from above, ground robots inspect up close, maps merged through ROS 2
Drone swarmsSeveral drones coordinate positions over a network (see the LoRa Mesh swarm deep-dive knowledge unit)

Class activity

Activity: Designing a warehouse system with drones and robots

Read the deep-dive knowledge unit “From embedded systems to AI robots and ROS” in the drone knowledge hub first.

  1. Draw the system’s ROS 2 graph, naming nodes, topics, services and actions.
  2. Choose how to connect to the flight controller and mark where frames must be converted.
  3. Calculate the latency budget of the obstacle-detection chain and how far the drone moves meanwhile.
  4. Place all components in the Figure 2 architecture, and state what each does to stay safe if the network fails.

Common mistakes

Watch out

  • Forgetting NED/ENU conversion between ROS 2 and PX4
  • Using an end-of-life ROS 2 distribution, or one not supported by the flight stack’s documentation
  • Making the mission computer the primary safety authority instead of the flight controller
  • Ignoring AI and network latency in safety margins
  • Leaving command channels unencrypted on networks others can reach

Summary

  • ROS 2 connects nodes through topics, services and actions over DDS, with QoS policies
  • PX4 connects to ROS 2 through uXRCE-DDS; MAVROS bridges MAVLink and ROS 2
  • PX4 uses NED/FRD while ROS uses ENU/FLU; convert position as
  • A latency budget sums every stage of the data chain; distance moved is
  • Good architecture separates safety from mission functions and chooses protocols by layer

Check your understanding

  1. To command a drone to a point with progress reports along the way, should you use a topic, a service or an action?
  2. PX4 reports NED position m. What is it in ENU?
  3. A data chain has 40 ms total latency and the drone flies at 15 m/s. How far does it move?
  4. Which ROS 2 distribution was released in May 2026?
  5. Why should the mission computer not be the primary safety authority?
Answers
  1. An action, because it is long-running, gives feedback along the way and can be cancelled
  2. m
  3. m
  4. Lyrical Luth (22 May 2026)
  5. The mission computer runs complex software that may hang or crash; the flight controller must keep the aircraft safe through its own failsafes even if the mission computer stops

Key formulas

NED to ENU vector conversion
Latency budget of a data chain

Key references

  1. Open Robotics. ROS 2 documentation. link
  2. PX4 Autopilot. ROS 2 user guide (uXRCE-DDS bridge and frame conventions). PX4 user guide (main). link
  3. MAVLink Development Team. MAVROS: MAVLink to ROS gateway (ROS 2). link
  4. MAVLink Development Team. MAVLink developer guide. link
  5. OASIS. (2019). MQTT version 5.0 (OASIS Standard, 7 March 2019). link
  6. International Electrotechnical Commission. (2025). OPC unified architecture – Part 1: Overview and concepts (IEC 62541-1:2025). link
  7. International Society of Automation. ISA-95 standard: Enterprise-control system integration (ANSI/ISA-95, IEC 62264). link
  8. Chung, S.-J., Paranjape, A. A., Dames, P., Shen, S., & Kumar, V. (2018). A survey on aerial swarm robotics. IEEE Transactions on Robotics, 34(4), 837–855.

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

AvailableD12D07

Topic 3: Robotics & autonomous systems

สรุปเนื้อหาหัวข้อที่ 3: ระบบปฏิบัติการหุ่นยนต์และการควบคุมฝูงโดรน (Swarm) อินเทอร์เน็ตของสรรพสิ่งทางทหาร (IoMT) เครือข่าย LoRa/Mesh สำหรับพื้นที่ไร้สัญญาณ และการเขียนโปรแกรม SOS Beacon–Receiver
In developmentD12D02

ROS 2 and flight-stack integration

Nodes, topics, services, actions, uXRCE-DDS/MAVROS and simulation
AvailableD04D12

Deep dive: from embedded systems to AI robots and ROS

จาก Embedded System สู่ AI Robot: เหตุผลที่ระบบฝังตัวต้องมี AI ฮาร์ดแวร์ Edge AI (Jetson, Kria, Raspberry Pi) กล้องและ Sensor Fusion แนวคิด ROS Node/Topic และสถาปัตยกรรมครบวงจรที่เชื่อมกลับสู่ MQTT
AvailableD12D07

Deep dive: coordinating drone swarms over LoRa mesh networks

เจาะลึกการประสานฝูงโดรน (Swarm Coordination) ผ่านโครงข่าย LoRa Mesh: ข้อจำกัดของ Wi-Fi Mesh สถาปัตยกรรมไฮบริด LoRa + IEEE 802.11s ระบบเฝ้าระวังฉุกเฉินด้วย LoRaWAN/GNSS และความปลอดภัยของโครงข่าย
AvailableD07

Drone communications and MAVLink

แยก message, transport และ datalink แล้วทดลอง telemetry กับ SITL อย่างเป็นลำดับ

In class / field

Lecture, case discussion and in-class problem solving

Learning evidence: Quiz results and submitted exercises

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Automation, robotics and swarms · Communications, networks and IoT · Programming and digital technology · Sensors and embedded systems · Artificial intelligence and computer vision