# mz0210/six-axis-robot-arm architecture

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

- Interactive diagram: https://gitdiagram.com/mz0210/six-axis-robot-arm
- Repository: https://github.com/mz0210/six-axis-robot-arm

## Overview

This repository is firmware for a standalone STM32F407 six-axis robot arm. The principal workflow accepts USART commands, parses motion requests, computes inverse kinematics and synchronized trajectories, then controls joints and sends Emm_V5 commands over CAN. The README also documents forward kinematics, action sequences, and periodic encoder calibration. Source excerpts are limited, so most application relationships below rely on the documented architecture; peripheral and CMSIS layers are grouped rather than mapped file by file.

Main entry points: [`机器人Freertos/Core/Src/freertos.c`](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/freertos.c) (FreeRTOS Tasks), [`机器人Freertos/Core/Src/app_robot.c`](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/app_robot.c) (Command and Actions), [`机器人Freertos/Core/Src/can.c`](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/can.c) (CAN Interface), [`机器人Freertos/Core/Src/main.c`](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/main.c) (Firmware Startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application"]
  node_app["Command and Actions<br/>[app_robot.c]"]
  node_rtos["FreeRTOS Tasks<br/>[freertos.c]"]
  node_actions["Stored Action Sequences<br/>[app_robot.c]"]
end

subgraph group_motion["Motion Control"]
  node_kinematics["DH Kinematics<br/>[robot_kinematics.c]"]
  node_ik["DLS Inverse Kinematics<br/>[robot_ik_dls.c]"]
  node_trajectory["S-Curve Trajectory"]
  node_trajectory_port["Trajectory Port"]
end

subgraph group_motors["Motor Control"]
  node_motor_control["Joint Control<br/>[MotorControl.c]"]
  node_emm["Emm_V5 Protocol<br/>[Emm_V5.c]"]
  node_encoder["Encoder Feedback<br/>[MotorControl.c]"]
end

subgraph group_platform["Embedded Platform"]
  node_main["Firmware Startup<br/>[main.c]"]
  node_can["CAN Interface<br/>[can.c]"]
  node_serial["USART Interface<br/>[usart.c]"]
  node_timer["Timer Interface<br/>[tim.c]"]
  node_interrupts["Interrupt Handlers<br/>[stm32f4xx_it.c]"]
  node_hal["STM32 HAL"]
  node_cmsis["CMSIS Device Support"]
end

node_host(("Command Host"))
node_motors_external(("Six Stepper Motors"))

node_host -->|"sends commands"| node_serial
node_serial -->|"provides input"| node_app
node_app -->|"runs in tasks"| node_rtos
node_rtos -->|"dispatches motion"| node_ik
node_app -->|"runs sequences"| node_actions
node_actions -.->|"requests joint solutions"| node_ik
node_ik -.->|"uses forward model"| node_kinematics
node_rtos -->|"schedules 20 ms task"| node_trajectory
node_app -->|"requests Cartesian motion"| node_trajectory
node_trajectory -.->|"uses port layer"| node_trajectory_port
node_rtos -->|"runs control loop"| node_motor_control
node_motor_control -->|"issues motor commands"| node_emm
node_emm -->|"transmits CAN frames"| node_can
node_can -->|"controls over CAN"| node_motors_external
node_motors_external -->|"returns CAN feedback"| node_can
node_can -.->|"signals receive events"| node_interrupts
node_serial -.->|"signals receive events"| node_interrupts
node_timer -.->|"signals timer events"| node_interrupts
node_main -->|"initializes peripherals"| node_hal
node_main -->|"starts scheduler"| node_rtos
node_rtos -->|"schedules calibration"| node_encoder
node_encoder -->|"calibrates joint control"| node_motor_control
node_main -.->|"uses device support"| node_cmsis

click node_app "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/app_robot.c"
click node_rtos "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/freertos.c"
click node_main "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/main.c"
click node_kinematics "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/robot_kinematics.c"
click node_ik "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/robot_ik_dls.c"
click node_trajectory "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/trajectory_planner.c"
click node_trajectory_port "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/trajectory_planner_port.c"
click node_motor_control "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/MotorControl.c"
click node_emm "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/Emm_V5.c"
click node_can "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/can.c"
click node_serial "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/usart.c"
click node_timer "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/tim.c"
click node_interrupts "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/stm32f4xx_it.c"
click node_hal "https://github.com/mz0210/six-axis-robot-arm/tree/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/STM32F4xx_HAL_Driver/Inc"
click node_cmsis "https://github.com/mz0210/six-axis-robot-arm/tree/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/CMSIS"
click node_actions "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/app_robot.c"
click node_encoder "https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/MotorControl.c"

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_app,node_rtos,node_actions toneBlue
class node_kinematics,node_ik,node_trajectory,node_trajectory_port toneAmber
class node_motor_control,node_emm,node_encoder toneMint
class node_main,node_can,node_serial,node_timer,node_interrupts,node_hal,node_cmsis toneRose
class node_host,node_motors_external toneIndigo
```

## Components

### Application

- [Command and Actions](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/app_robot.c): `机器人Freertos/Core/Src/app_robot.c`
- [FreeRTOS Tasks](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/freertos.c): `机器人Freertos/Core/Src/freertos.c`
- [Stored Action Sequences](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/app_robot.c): `机器人Freertos/Core/Src/app_robot.c`

### Motion Control

- [DH Kinematics](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/robot_kinematics.c): `机器人Freertos/Core/Src/robot_kinematics.c`
- [DLS Inverse Kinematics](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/robot_ik_dls.c): `机器人Freertos/Core/Src/robot_ik_dls.c`
- [S-Curve Trajectory](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/trajectory_planner.c): `机器人Freertos/Core/Src/trajectory_planner.c`
- [Trajectory Port](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/trajectory_planner_port.c): `机器人Freertos/Core/Src/trajectory_planner_port.c`

### Motor Control

- [Joint Control](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/MotorControl.c): `机器人Freertos/Core/Src/MotorControl.c`
- [Emm_V5 Protocol](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/Emm_V5.c): `机器人Freertos/Core/Src/Emm_V5.c`
- [Encoder Feedback](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/MotorControl.c): `机器人Freertos/Core/Src/MotorControl.c`

### Embedded Platform

- [Firmware Startup](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/main.c): `机器人Freertos/Core/Src/main.c`
- [CAN Interface](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/can.c): `机器人Freertos/Core/Src/can.c`
- [USART Interface](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/usart.c): `机器人Freertos/Core/Src/usart.c`
- [Timer Interface](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/tim.c): `机器人Freertos/Core/Src/tim.c`
- [Interrupt Handlers](https://github.com/mz0210/six-axis-robot-arm/blob/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/Core/Src/stm32f4xx_it.c): `机器人Freertos/Core/Src/stm32f4xx_it.c`
- [STM32 HAL](https://github.com/mz0210/six-axis-robot-arm/tree/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/STM32F4xx_HAL_Driver/Inc): `机器人Freertos/STM32F4xx_HAL_Driver/Inc`
- [CMSIS Device Support](https://github.com/mz0210/six-axis-robot-arm/tree/main/%E6%9C%BA%E5%99%A8%E4%BA%BAFreertos/CMSIS): `机器人Freertos/CMSIS`

### Other components

- **Command Host**
- **Six Stepper Motors**

## Connections

- Command Host → USART Interface: sends commands
- USART Interface → Command and Actions: provides input
- Command and Actions → FreeRTOS Tasks: runs in tasks
- FreeRTOS Tasks → DLS Inverse Kinematics: dispatches motion
- Command and Actions → Stored Action Sequences: runs sequences
- Stored Action Sequences → DLS Inverse Kinematics: requests joint solutions
- DLS Inverse Kinematics → DH Kinematics: uses forward model
- FreeRTOS Tasks → S-Curve Trajectory: schedules 20 ms task
- Command and Actions → S-Curve Trajectory: requests Cartesian motion
- S-Curve Trajectory → Trajectory Port: uses port layer
- FreeRTOS Tasks → Joint Control: runs control loop
- Joint Control → Emm_V5 Protocol: issues motor commands
- Emm_V5 Protocol → CAN Interface: transmits CAN frames
- CAN Interface → Six Stepper Motors: controls over CAN
- Six Stepper Motors → CAN Interface: returns CAN feedback
- CAN Interface → Interrupt Handlers: signals receive events
- USART Interface → Interrupt Handlers: signals receive events
- Timer Interface → Interrupt Handlers: signals timer events
- Firmware Startup → STM32 HAL: initializes peripherals
- Firmware Startup → FreeRTOS Tasks: starts scheduler (evidence: `机器人Freertos/Core/Src/main.c`)
- FreeRTOS Tasks → Encoder Feedback: schedules calibration
- Encoder Feedback → Joint Control: calibrates joint control
- Firmware Startup → CMSIS Device Support: uses device support
