# axedelubac/mcu_robot architecture

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

- Interactive diagram: https://gitdiagram.com/axedelubac/mcu_robot
- Repository: https://github.com/axedelubac/mcu_robot

## Overview

This is Zephyr-based MCU robot firmware. Its principal control path receives velocity commands over micro-ROS, converts them into wheel setpoints, compares them with encoder measurements, and updates mecanum odometry. Separate runtime tasks collect IMU, pressure/temperature, and GNSS data; the micro-ROS client publishes telemetry. The README also describes UART status output. Several listed serial framing and motor-controller modules are not shown wired into the sampled runtime, so they are represented only as documented capabilities or omitted from the active control flow.

Main entry points: [`src/RTOS.c`](https://github.com/axedelubac/mcu_robot/blob/main/src/RTOS.c) (Zephyr tasks), [`src/DataCommunication/MicroRosNode.c`](https://github.com/axedelubac/mcu_robot/blob/main/src/DataCommunication/MicroRosNode.c) (micro-ROS client), [`src/speedControlSystem/GlobalControl.c`](https://github.com/axedelubac/mcu_robot/blob/main/src/speedControlSystem/GlobalControl.c) (Global speed control), [`src/positionManagement/PositionOrientation.c`](https://github.com/axedelubac/mcu_robot/blob/main/src/positionManagement/PositionOrientation.c) (Orientation update)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_rtos_tasks["Zephyr tasks<br/>[RTOS.c]"]
end

subgraph group_control["Motion control"]
  node_speed_measurement["Wheel speed measurement<br/>[GlobalSpeed.c]"]
  node_encoder["Rotary encoders<br/>[rotaryEncoder.c]"]
  node_kinematics["Forward kinematics"]
  node_speed_control["Global speed control<br/>[GlobalControl.c]"]
  node_pid["PID control"]
  node_odometry["Mecanum odometry<br/>[mecanumOdometrie.c]"]
end

subgraph group_sensing["Sensing and state"]
  node_imu["IMU acquisition<br/>[Imu.c]"]
  node_orientation["Orientation update"]
  node_pressure_sensor["Pressure and temperature<br/>[lps22dfSensor.c]"]
  node_gnss["GNSS sample handling<br/>[RTOS.c]"]
end

subgraph group_communication["Robot communication"]
  node_microros["micro-ROS client<br/>[MicroRosNode.c]"]
  node_serial_protocol["Serial packet format"]
end

node_ros_operator(("ROS 2 operator"))
node_micro_ros_agent["micro-ROS agent"]

node_ros_operator -.->|"sends commands"| node_micro_ros_agent
node_micro_ros_agent -.->|"exchanges ROS data"| node_microros
node_rtos_tasks -->|"runs client"| node_microros
node_rtos_tasks -->|"updates orientation"| node_orientation
node_orientation -->|"uses IMU"| node_imu
node_rtos_tasks -->|"initializes sensor"| node_pressure_sensor
node_rtos_tasks -->|"measures wheel speed"| node_speed_measurement
node_rtos_tasks -->|"computes wheel setpoints"| node_kinematics
node_rtos_tasks -->|"updates regulation"| node_speed_control
node_rtos_tasks -->|"updates odometry"| node_odometry
node_microros -->|"reads telemetry"| node_imu
node_microros -->|"reads measurements"| node_pressure_sensor
node_microros -->|"reads GNSS and speeds"| node_rtos_tasks
node_speed_control -.->|"uses PID loops"| node_pid

click node_rtos_tasks "https://github.com/axedelubac/mcu_robot/blob/main/src/RTOS.c"
click node_imu "https://github.com/axedelubac/mcu_robot/blob/main/src/positionManagement/Imu.c"
click node_orientation "https://github.com/axedelubac/mcu_robot/blob/main/src/positionManagement/PositionOrientation.c"
click node_pressure_sensor "https://github.com/axedelubac/mcu_robot/blob/main/src/sensorManagement/lps22dfSensor.c"
click node_gnss "https://github.com/axedelubac/mcu_robot/blob/main/src/RTOS.c"
click node_speed_measurement "https://github.com/axedelubac/mcu_robot/blob/main/src/speedMesurement/GlobalSpeed.c"
click node_encoder "https://github.com/axedelubac/mcu_robot/blob/main/src/speedMesurement/rotaryEncoder.c"
click node_kinematics "https://github.com/axedelubac/mcu_robot/blob/main/src/navigation/forwardKinematics.c"
click node_speed_control "https://github.com/axedelubac/mcu_robot/blob/main/src/speedControlSystem/GlobalControl.c"
click node_pid "https://github.com/axedelubac/mcu_robot/blob/main/src/speedControlSystem/closedLoopControl.c"
click node_odometry "https://github.com/axedelubac/mcu_robot/blob/main/src/navigation/mecanumOdometrie.c"
click node_microros "https://github.com/axedelubac/mcu_robot/blob/main/src/DataCommunication/MicroRosNode.c"
click node_serial_protocol "https://github.com/axedelubac/mcu_robot/blob/main/src/DataCommunication/SerialDataStructure.h"

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_rtos_tasks toneBlue
class node_speed_measurement,node_encoder,node_kinematics,node_speed_control,node_pid,node_odometry toneAmber
class node_imu,node_orientation,node_pressure_sensor,node_gnss toneMint
class node_microros,node_serial_protocol toneRose
class node_ros_operator,node_micro_ros_agent toneIndigo
```

## Components

### Runtime orchestration

- [Zephyr tasks](https://github.com/axedelubac/mcu_robot/blob/main/src/RTOS.c): `src/RTOS.c`

### Motion control

- [Wheel speed measurement](https://github.com/axedelubac/mcu_robot/blob/main/src/speedMesurement/GlobalSpeed.c): `src/speedMesurement/GlobalSpeed.c`
- [Rotary encoders](https://github.com/axedelubac/mcu_robot/blob/main/src/speedMesurement/rotaryEncoder.c): `src/speedMesurement/rotaryEncoder.c`
- [Forward kinematics](https://github.com/axedelubac/mcu_robot/blob/main/src/navigation/forwardKinematics.c): `src/navigation/forwardKinematics.c`
- [Global speed control](https://github.com/axedelubac/mcu_robot/blob/main/src/speedControlSystem/GlobalControl.c): `src/speedControlSystem/GlobalControl.c`
- [PID control](https://github.com/axedelubac/mcu_robot/blob/main/src/speedControlSystem/closedLoopControl.c): `src/speedControlSystem/closedLoopControl.c`
- [Mecanum odometry](https://github.com/axedelubac/mcu_robot/blob/main/src/navigation/mecanumOdometrie.c): `src/navigation/mecanumOdometrie.c`

### Sensing and state

- [IMU acquisition](https://github.com/axedelubac/mcu_robot/blob/main/src/positionManagement/Imu.c): `src/positionManagement/Imu.c`
- [Orientation update](https://github.com/axedelubac/mcu_robot/blob/main/src/positionManagement/PositionOrientation.c): `src/positionManagement/PositionOrientation.c`
- [Pressure and temperature](https://github.com/axedelubac/mcu_robot/blob/main/src/sensorManagement/lps22dfSensor.c): `src/sensorManagement/lps22dfSensor.c`
- [GNSS sample handling](https://github.com/axedelubac/mcu_robot/blob/main/src/RTOS.c): `src/RTOS.c`

### Robot communication

- [micro-ROS client](https://github.com/axedelubac/mcu_robot/blob/main/src/DataCommunication/MicroRosNode.c): `src/DataCommunication/MicroRosNode.c`
- [Serial packet format](https://github.com/axedelubac/mcu_robot/blob/main/src/DataCommunication/SerialDataStructure.h): `src/DataCommunication/SerialDataStructure.h`

### Other components

- **ROS 2 operator**
- **micro-ROS agent**

## Connections

- ROS 2 operator → micro-ROS agent: sends commands (evidence: `README.md`)
- micro-ROS agent → micro-ROS client: exchanges ROS data (evidence: `README.md`)
- Zephyr tasks → micro-ROS client: runs client (evidence: `src/RTOS.c`)
- Zephyr tasks → Orientation update: updates orientation (evidence: `src/RTOS.c`)
- Orientation update → IMU acquisition: uses IMU
- Zephyr tasks → Pressure and temperature: initializes sensor (evidence: `src/RTOS.c`)
- Zephyr tasks → Wheel speed measurement: measures wheel speed (evidence: `src/RTOS.c`)
- Zephyr tasks → Forward kinematics: computes wheel setpoints (evidence: `src/RTOS.c`)
- Zephyr tasks → Global speed control: updates regulation (evidence: `src/RTOS.c`)
- Zephyr tasks → Mecanum odometry: updates odometry (evidence: `src/RTOS.c`)
- micro-ROS client → IMU acquisition: reads telemetry (evidence: `src/DataCommunication/MicroRosNode.c`)
- micro-ROS client → Pressure and temperature: reads measurements (evidence: `src/DataCommunication/MicroRosNode.c`)
- micro-ROS client → Zephyr tasks: reads GNSS and speeds (evidence: `src/DataCommunication/MicroRosNode.c`)
- Global speed control → PID control: uses PID loops
