# openflex-wheeled-humanoid/motion_control_layer architecture

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

- Interactive diagram: https://gitdiagram.com/openflex-wheeled-humanoid/motion_control_layer
- Repository: https://github.com/openflex-wheeled-humanoid/motion_control_layer

## Overview

This ROS 2 control package turns chassis Twist commands into four swerve-module steering and wheel commands, while estimating and publishing wheel-based odometry. The main runtime controller receives commands and joint feedback, applies kinematics and steering/speed constraints, and publishes odometry, optional TF, and debug state. The source excerpts show inverse-kinematics and wheel-speed limiting; odometry’s forward-kinematics integration is explicit in its implementation, but the controller’s call into odometry and several slowdown details are not shown, so those links are marked unverified. Navigation, SLAM, and hardware protocols are outside this package.

Main entry points: [`swerve_controller/src/swerve_drive_controller.cpp`](https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_controller.cpp) (Swerve Controller), [`swerve_controller/src/swerve_drive_kinematics.cpp`](https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_kinematics.cpp) (Swerve Kinematics), [`swerve_controller/src/swerve_drive_odometry.cpp`](https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_odometry.cpp) (Wheel Odometry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Controller Runtime"]
  node_controller["Swerve Controller"]
end

subgraph group_motion["Motion Algorithms"]
  node_kinematics["Swerve Kinematics"]
  node_odometry["Wheel Odometry"]
end

subgraph group_outputs["Published Results"]
  node_joint_commands["Joint Commands"]
  node_odom_output["Odometry and TF"]
  node_debug_output["Debug States"]
end

node_command_source(("Velocity Source"))
node_joint_feedback(("Joint Feedback"))

node_command_source -->|"sends Twist"| node_controller
node_joint_feedback -->|"provides feedback"| node_controller
node_controller -->|"computes module states"| node_kinematics
node_kinematics -->|"returns states"| node_controller
node_controller -->|"writes commands"| node_joint_commands
node_controller -.->|"updates estimate"| node_odometry
node_odometry -->|"computes chassis speed"| node_kinematics
node_controller -->|"publishes odometry and TF"| node_odom_output
node_controller -->|"publishes debug state"| node_debug_output

click node_controller "https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_controller.cpp"
click node_kinematics "https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_kinematics.cpp"
click node_odometry "https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_odometry.cpp"

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_controller toneBlue
class node_kinematics,node_odometry toneAmber
class node_joint_commands,node_odom_output,node_debug_output toneMint
class node_command_source,node_joint_feedback toneIndigo
```

## Components

### Controller Runtime

- [Swerve Controller](https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_controller.cpp): `swerve_controller/src/swerve_drive_controller.cpp`

### Motion Algorithms

- [Swerve Kinematics](https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_kinematics.cpp): `swerve_controller/src/swerve_drive_kinematics.cpp`
- [Wheel Odometry](https://github.com/openflex-wheeled-humanoid/motion_control_layer/blob/v1.0_basic/swerve_controller/src/swerve_drive_odometry.cpp): `swerve_controller/src/swerve_drive_odometry.cpp`

### Published Results

- **Joint Commands**
- **Odometry and TF**
- **Debug States**

### Other components

- **Velocity Source**
- **Joint Feedback**

## Connections

- Velocity Source → Swerve Controller: sends Twist (evidence: `README.md`)
- Joint Feedback → Swerve Controller: provides feedback (evidence: `swerve_controller/src/swerve_drive_controller.cpp`)
- Swerve Controller → Swerve Kinematics: computes module states (evidence: `swerve_controller/src/swerve_drive_controller.cpp`)
- Swerve Kinematics → Swerve Controller: returns states (evidence: `swerve_controller/src/swerve_drive_controller.cpp`)
- Swerve Controller → Joint Commands: writes commands (evidence: `README.md`)
- Swerve Controller → Wheel Odometry: updates estimate
- Wheel Odometry → Swerve Kinematics: computes chassis speed (evidence: `swerve_controller/src/swerve_drive_odometry.cpp`)
- Swerve Controller → Odometry and TF: publishes odometry and TF (evidence: `README.md`)
- Swerve Controller → Debug States: publishes debug state (evidence: `README.md`)
