# dmdobrea/ros2_offboard_control architecture

> Architecture diagram of the GitHub repository dmdobrea/ros2_offboard_control, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dmdobrea/ros2_offboard_control
- Repository: https://github.com/dmdobrea/ros2_offboard_control

## Overview

This is a small ROS 2 application for manually controlling a PX4 UAV. The user moves an Xbox controller; its node publishes velocity and action topics, and the offboard-control node consumes them to manage flight and issue setpoints or vehicle commands. The README also documents position-control code and simulation with Gazebo or JMAVSim. The controller and topic connections are documented; excerpts show velocity processing and setpoint publishing, but omit some subscription and PX4 publisher setup, so those links rely on the README rather than sampled call sites.

Main entry points: [`offboard_control/offboard_control/uav_ctrl.py`](https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py) (Offboard control), [`offboard_control/offboard_control/xbox.py`](https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/xbox.py) (Xbox input node)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_teleop["Controller input"]
  node_xbox["Xbox input node<br/>[xbox.py]"]
  node_velocity_topic["Velocity topic"]
  node_action_topic["Action topic"]
end

subgraph group_flight["Flight control"]
  node_flight_control["Offboard control<br/>[uav_ctrl.py]"]
  node_flight_state["Flight state logic<br/>[uav_ctrl.py]"]
end

subgraph group_px4["PX4 integration"]
  node_setpoints["Trajectory setpoints<br/>[uav_ctrl.py]"]
end

node_user(("Xbox operator"))
node_xrce["Micro XRCE-DDS bridge"]
node_px4_autopilot["PX4 autopilot"]
node_simulator["Gazebo / JMAVSim"]
node_qgc["QGroundControl"]

node_user -->|"operates"| node_xbox
node_xbox -->|"publishes velocity"| node_velocity_topic
node_xbox -->|"publishes actions"| node_action_topic
node_velocity_topic -->|"delivers commands"| node_flight_control
node_action_topic -->|"delivers actions"| node_flight_control
node_flight_control -->|"runs mission control"| node_flight_state
node_flight_control -->|"publishes setpoints"| node_setpoints
node_flight_control -->|"sends commands"| node_xrce
node_xrce -->|"bridges commands"| node_px4_autopilot
node_px4_autopilot -.->|"returns telemetry"| node_xrce
node_xrce -.->|"delivers telemetry"| node_flight_control
node_simulator -->|"simulates vehicle"| node_px4_autopilot
node_qgc -.->|"supervises vehicle"| node_px4_autopilot

click node_xbox "https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/xbox.py"
click node_flight_control "https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py"
click node_flight_state "https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py"
click node_setpoints "https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_xbox,node_velocity_topic,node_action_topic toneBlue
class node_flight_control,node_flight_state toneAmber
class node_setpoints toneMint
class node_user,node_xrce,node_px4_autopilot,node_simulator,node_qgc toneIndigo
```

## Components

### Controller input

- [Xbox input node](https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/xbox.py): `offboard_control/offboard_control/xbox.py`
- **Velocity topic**
- **Action topic**

### Flight control

- [Offboard control](https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py): `offboard_control/offboard_control/uav_ctrl.py`
- [Flight state logic](https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py): `offboard_control/offboard_control/uav_ctrl.py`

### PX4 integration

- [Trajectory setpoints](https://github.com/dmdobrea/ros2_offboard_control/blob/main/offboard_control/offboard_control/uav_ctrl.py): `offboard_control/offboard_control/uav_ctrl.py`

### Other components

- **Xbox operator**
- **Micro XRCE-DDS bridge**
- **PX4 autopilot**
- **Gazebo / JMAVSim**
- **QGroundControl**

## Connections

- Xbox operator → Xbox input node: operates (evidence: `README.md`)
- Xbox input node → Velocity topic: publishes velocity (evidence: `offboard_control/offboard_control/xbox.py`)
- Xbox input node → Action topic: publishes actions (evidence: `offboard_control/offboard_control/xbox.py`)
- Velocity topic → Offboard control: delivers commands (evidence: `README.md`)
- Action topic → Offboard control: delivers actions (evidence: `README.md`)
- Offboard control → Flight state logic: runs mission control (evidence: `offboard_control/offboard_control/uav_ctrl.py`)
- Offboard control → Trajectory setpoints: publishes setpoints (evidence: `offboard_control/offboard_control/uav_ctrl.py`)
- Offboard control → Micro XRCE-DDS bridge: sends commands (evidence: `README.md`)
- Micro XRCE-DDS bridge → PX4 autopilot: bridges commands (evidence: `README.md`)
- PX4 autopilot → Micro XRCE-DDS bridge: returns telemetry
- Micro XRCE-DDS bridge → Offboard control: delivers telemetry
- Gazebo / JMAVSim → PX4 autopilot: simulates vehicle (evidence: `README.md`)
- QGroundControl → PX4 autopilot: supervises vehicle (evidence: `README.md`)
