# pvandervelde/zinger_swerve_controller architecture

> Architecture diagram of the GitHub repository pvandervelde/zinger_swerve_controller, 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/pvandervelde/zinger_swerve_controller
- Repository: https://github.com/pvandervelde/zinger_swerve_controller

## Overview

This package provides the Zinger robot’s ROS 2 swerve controller. The principal runtime path accepts body-motion commands, derives wheel-module targets, profiles their motion, and publishes joint commands; measured joint states also support body-state estimation and odometry. Its implementation separates command types, kinematics, motion profiles, module geometry/state, and the ROS node. The README documents configuration and odometry capabilities; sampled excerpts do not show all callback wiring, so some links are omitted rather than inferred.

Main entry points: [`zinger_swerve_controller/swerve_controller.py`](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/swerve_controller.py) (Swerve Node), [`zinger_swerve_controller/steering_controller.py`](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/steering_controller.py) (Steering Planner), [`zinger_swerve_controller/control_model.py`](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_model.py) (Swerve Kinematics), [`zinger_swerve_controller/drive_module.py`](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/drive_module.py) (Drive Modules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ros["ROS Integration"]
  node_ros_node["Swerve Node"]
  node_config["Controller Config<br/>[swerve.yaml]"]
  node_launch["Controller Launch"]
end

subgraph group_motion["Motion Planning"]
  node_steering["Steering Planner"]
  node_commands["Motion Commands<br/>[control.py]"]
  node_kinematics["Swerve Kinematics<br/>[control_model.py]"]
end

subgraph group_model["Robot Model"]
  node_module["Drive Modules<br/>[drive_module.py]"]
  node_states["Motion States<br/>[states.py]"]
  node_geometry["Geometry Types<br/>[geometry.py]"]
end

subgraph group_profiles["Motion Profiles"]
  node_body_profile["Body Profiles<br/>[control_profile.py]"]
  node_module_profile["Module Profiles<br/>[control_profile.py]"]
  node_variable_profile["Variable Profiles<br/>[profile.py]"]
  node_errors["Trajectory Errors<br/>[errors.py]"]
end

node_cmd(("Motion Commands"))
node_joint_state(("Joint State Publisher"))
node_joint_control["ROS Joint Controllers"]
node_odom(("Odometry Consumer"))

node_launch -->|"launches"| node_ros_node
node_launch -->|"loads"| node_config
node_cmd -.->|"publishes commands"| node_ros_node
node_joint_state -->|"publishes states"| node_ros_node
node_ros_node -->|"publishes joint commands"| node_joint_control
node_ros_node -->|"publishes odometry"| node_odom
node_ros_node -->|"delegates planning"| node_steering
node_ros_node -->|"creates modules"| node_module
node_ros_node -->|"reads joint states"| node_states
node_commands -->|"converts commands"| node_kinematics
node_steering -->|"accepts commands"| node_commands
node_steering -->|"calculates module states"| node_kinematics
node_steering -->|"profiles body motion"| node_body_profile
node_steering -->|"profiles module motion"| node_module_profile
node_body_profile -->|"uses profiles"| node_variable_profile
node_module_profile -->|"uses profiles"| node_variable_profile
node_module_profile -->|"raises errors"| node_errors
node_kinematics -->|"uses geometry"| node_module
node_kinematics -->|"returns states"| node_states
node_steering -->|"uses modules"| node_module
node_steering -->|"updates states"| node_states
node_module -->|"stores position"| node_geometry
node_states -->|"uses types"| node_geometry

click node_ros_node "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/swerve_controller.py"
click node_config "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/config/swerve.yaml"
click node_launch "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/launch/swerve_controller.launch.py"
click node_steering "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/steering_controller.py"
click node_commands "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control.py"
click node_kinematics "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_model.py"
click node_body_profile "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_profile.py"
click node_module_profile "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_profile.py"
click node_variable_profile "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/profile.py"
click node_module "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/drive_module.py"
click node_states "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/states.py"
click node_geometry "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/geometry.py"
click node_errors "https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/errors.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_ros_node,node_config,node_launch toneBlue
class node_steering,node_commands,node_kinematics toneAmber
class node_module,node_states,node_geometry toneMint
class node_body_profile,node_module_profile,node_variable_profile,node_errors toneRose
class node_cmd,node_joint_state,node_joint_control,node_odom toneIndigo
```

## Components

### ROS Integration

- [Swerve Node](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/swerve_controller.py): `zinger_swerve_controller/swerve_controller.py`
- [Controller Config](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/config/swerve.yaml): `config/swerve.yaml`
- [Controller Launch](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/launch/swerve_controller.launch.py): `launch/swerve_controller.launch.py`

### Motion Planning

- [Steering Planner](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/steering_controller.py): `zinger_swerve_controller/steering_controller.py`
- [Motion Commands](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control.py): `zinger_swerve_controller/control.py`
- [Swerve Kinematics](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_model.py): `zinger_swerve_controller/control_model.py`

### Robot Model

- [Drive Modules](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/drive_module.py): `zinger_swerve_controller/drive_module.py`
- [Motion States](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/states.py): `zinger_swerve_controller/states.py`
- [Geometry Types](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/geometry.py): `zinger_swerve_controller/geometry.py`

### Motion Profiles

- [Body Profiles](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_profile.py): `zinger_swerve_controller/control_profile.py`
- [Module Profiles](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/control_profile.py): `zinger_swerve_controller/control_profile.py`
- [Variable Profiles](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/profile.py): `zinger_swerve_controller/profile.py`
- [Trajectory Errors](https://github.com/pvandervelde/zinger_swerve_controller/blob/master/zinger_swerve_controller/errors.py): `zinger_swerve_controller/errors.py`

### Other components

- **Motion Commands**
- **Joint State Publisher**
- **ROS Joint Controllers**
- **Odometry Consumer**

## Connections

- Controller Launch → Swerve Node: launches (evidence: `launch/swerve_controller.launch.py`)
- Controller Launch → Controller Config: loads (evidence: `launch/swerve_controller.launch.py`)
- Motion Commands → Swerve Node: publishes commands
- Joint State Publisher → Swerve Node: publishes states (evidence: `zinger_swerve_controller/swerve_controller.py`)
- Swerve Node → ROS Joint Controllers: publishes joint commands (evidence: `README.md`)
- Swerve Node → Odometry Consumer: publishes odometry (evidence: `README.md`)
- Swerve Node → Steering Planner: delegates planning (evidence: `zinger_swerve_controller/swerve_controller.py`)
- Swerve Node → Drive Modules: creates modules (evidence: `zinger_swerve_controller/swerve_controller.py`)
- Swerve Node → Motion States: reads joint states (evidence: `zinger_swerve_controller/swerve_controller.py`)
- Motion Commands → Swerve Kinematics: converts commands (evidence: `zinger_swerve_controller/control.py`)
- Steering Planner → Motion Commands: accepts commands (evidence: `zinger_swerve_controller/steering_controller.py`)
- Steering Planner → Swerve Kinematics: calculates module states (evidence: `zinger_swerve_controller/steering_controller.py`)
- Steering Planner → Body Profiles: profiles body motion (evidence: `zinger_swerve_controller/steering_controller.py`)
- Steering Planner → Module Profiles: profiles module motion (evidence: `zinger_swerve_controller/steering_controller.py`)
- Body Profiles → Variable Profiles: uses profiles (evidence: `zinger_swerve_controller/control_profile.py`)
- Module Profiles → Variable Profiles: uses profiles (evidence: `zinger_swerve_controller/control_profile.py`)
- Module Profiles → Trajectory Errors: raises errors (evidence: `zinger_swerve_controller/control_profile.py`)
- Swerve Kinematics → Drive Modules: uses geometry (evidence: `zinger_swerve_controller/control_model.py`)
- Swerve Kinematics → Motion States: returns states (evidence: `zinger_swerve_controller/control_model.py`)
- Steering Planner → Drive Modules: uses modules (evidence: `zinger_swerve_controller/steering_controller.py`)
- Steering Planner → Motion States: updates states (evidence: `zinger_swerve_controller/steering_controller.py`)
- Drive Modules → Geometry Types: stores position (evidence: `zinger_swerve_controller/drive_module.py`)
- Motion States → Geometry Types: uses types (evidence: `zinger_swerve_controller/states.py`)
