# tongjisuperpower/sp_vision_25 architecture

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

- Interactive diagram: https://gitdiagram.com/tongjisuperpower/sp_vision_25
- Repository: https://github.com/tongjisuperpower/sp_vision_25

## Overview

This repository is a C++ robot-vision application for automatic aiming, rune targeting, and related perception. Its primary loop acquires camera frames and timestamp-aligned gimbal orientation, detects armor, estimates target motion, plans an aim trajectory, decides when to fire, and sends commands to the controller. The README also documents calibration, omnidirectional perception, and optional ROS navigation communication. The sampled application confirms camera, IMU, detection, command, and ROS interactions; some internal stage links follow the documented workflow because their call sites were not sampled.

Main entry points: [`src/sentry_debug.cpp`](https://github.com/tongjisuperpower/sp_vision_25/blob/main/src/sentry_debug.cpp) (Sentry Debug Loop), [`tasks/auto_aim/yolo.cpp`](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/yolo.cpp) (Armor Detection), [`io/cboard.cpp`](https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/cboard.cpp) (Controller and IMU), [`io/camera.cpp`](https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/camera.cpp) (Camera Capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Robot Applications"]
  node_sentry["Sentry Debug Loop<br/>[sentry_debug.cpp]"]
  node_standard["Standard Loops<br/>[standard.cpp]"]
end

subgraph group_io["Hardware and Messaging"]
  node_camera["Camera Capture<br/>[camera.cpp]"]
  node_cboard["Controller and IMU<br/>[cboard.cpp]"]
  node_gimbal["Gimbal Serial<br/>[gimbal.cpp]"]
  node_ros["ROS Navigation<br/>[ros2.cpp]"]
end

subgraph group_aim["Auto Aim"]
  node_yolo["Armor Detection<br/>[yolo.cpp]"]
  node_detector["Detection Methods<br/>[detector.cpp]"]
  node_solver["Pose and Transforms<br/>[solver.cpp]"]
  node_tracker["Target Tracking<br/>[tracker.cpp]"]
  node_target["Target State<br/>[target.cpp]"]
  node_planner["Trajectory Planner<br/>[planner.cpp]"]
  node_aimer["Aim Decision<br/>[aimer.cpp]"]
  node_shooter["Fire Decision<br/>[shooter.cpp]"]
end

subgraph group_other["Other Tasks"]
  node_buff["Rune Targeting<br/>[buff_detector.cpp]"]
  node_buffaim["Rune Prediction<br/>[buff_aimer.cpp]"]
  node_omni["Omni Perception<br/>[decider.cpp]"]
end

subgraph group_support["Calibration and Tools"]
  node_calibration["Camera Calibration"]
  node_tools["Shared Math and Filters<br/>[math_tools.cpp]"]
end

node_operator(("Robot Controller"))
node_enemy(("Enemy Targets"))
node_actuators(("Gimbal and Shooter"))
node_navigation(("Navigation System"))

node_operator -->|"selects mode"| node_sentry
node_sentry -->|"reads frames"| node_camera
node_sentry -->|"reads IMU"| node_cboard
node_sentry -->|"detects armor"| node_yolo
node_yolo -->|"runs detection"| node_detector
node_sentry -->|"sets orientation"| node_solver
node_sentry -->|"updates perception"| node_omni
node_sentry -->|"sends command"| node_cboard
node_sentry -.->|"publishes target"| node_ros
node_ros -.->|"exchanges status"| node_navigation
node_standard -->|"reads frames"| node_camera
node_standard -->|"reads and commands"| node_cboard
node_standard -->|"detects armor"| node_yolo
node_yolo -->|"provides detections"| node_solver
node_solver -->|"estimates targets"| node_tracker
node_tracker -->|"updates state"| node_target
node_target -->|"supplies motion state"| node_planner
node_planner -->|"plans trajectory"| node_aimer
node_aimer -->|"provides aim"| node_shooter
node_shooter -->|"forms fire command"| node_cboard
node_buff -->|"provides rune detection"| node_buffaim
node_omni -->|"requests detections"| node_yolo
node_calibration -->|"calibrates geometry"| node_camera
node_tracker -->|"uses filters and math"| node_tools
node_buffaim -->|"uses math utilities"| node_tools
node_cboard -->|"transmits commands"| node_actuators
node_camera -->|"captures images"| node_enemy
node_gimbal -->|"communicates state"| node_actuators

click node_sentry "https://github.com/tongjisuperpower/sp_vision_25/blob/main/src/sentry_debug.cpp"
click node_standard "https://github.com/tongjisuperpower/sp_vision_25/blob/main/src/standard.cpp"
click node_camera "https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/camera.cpp"
click node_cboard "https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/cboard.cpp"
click node_gimbal "https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/gimbal/gimbal.cpp"
click node_ros "https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/ros2/ros2.cpp"
click node_yolo "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/yolo.cpp"
click node_detector "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/detector.cpp"
click node_solver "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/solver.cpp"
click node_tracker "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/tracker.cpp"
click node_target "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/target.cpp"
click node_planner "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/planner/planner.cpp"
click node_aimer "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/aimer.cpp"
click node_shooter "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/shooter.cpp"
click node_buff "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_buff/buff_detector.cpp"
click node_buffaim "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_buff/buff_aimer.cpp"
click node_omni "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/omniperception/decider.cpp"
click node_calibration "https://github.com/tongjisuperpower/sp_vision_25/blob/main/calibration/calibrate_robotworld_handeye.cpp"
click node_tools "https://github.com/tongjisuperpower/sp_vision_25/blob/main/tools/math_tools.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_sentry,node_standard toneBlue
class node_camera,node_cboard,node_gimbal,node_ros toneAmber
class node_yolo,node_detector,node_solver,node_tracker,node_target,node_planner,node_aimer,node_shooter toneMint
class node_buff,node_buffaim,node_omni toneRose
class node_calibration,node_tools,node_operator,node_enemy,node_actuators,node_navigation toneIndigo
```

## Components

### Robot Applications

- [Sentry Debug Loop](https://github.com/tongjisuperpower/sp_vision_25/blob/main/src/sentry_debug.cpp): `src/sentry_debug.cpp`
- [Standard Loops](https://github.com/tongjisuperpower/sp_vision_25/blob/main/src/standard.cpp): `src/standard.cpp`

### Hardware and Messaging

- [Camera Capture](https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/camera.cpp): `io/camera.cpp`
- [Controller and IMU](https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/cboard.cpp): `io/cboard.cpp`
- [Gimbal Serial](https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/gimbal/gimbal.cpp): `io/gimbal/gimbal.cpp`
- [ROS Navigation](https://github.com/tongjisuperpower/sp_vision_25/blob/main/io/ros2/ros2.cpp): `io/ros2/ros2.cpp`

### Auto Aim

- [Armor Detection](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/yolo.cpp): `tasks/auto_aim/yolo.cpp`
- [Detection Methods](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/detector.cpp): `tasks/auto_aim/detector.cpp`
- [Pose and Transforms](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/solver.cpp): `tasks/auto_aim/solver.cpp`
- [Target Tracking](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/tracker.cpp): `tasks/auto_aim/tracker.cpp`
- [Target State](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/target.cpp): `tasks/auto_aim/target.cpp`
- [Trajectory Planner](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/planner/planner.cpp): `tasks/auto_aim/planner/planner.cpp`
- [Aim Decision](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/aimer.cpp): `tasks/auto_aim/aimer.cpp`
- [Fire Decision](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_aim/shooter.cpp): `tasks/auto_aim/shooter.cpp`

### Other Tasks

- [Rune Targeting](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_buff/buff_detector.cpp): `tasks/auto_buff/buff_detector.cpp`
- [Rune Prediction](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/auto_buff/buff_aimer.cpp): `tasks/auto_buff/buff_aimer.cpp`
- [Omni Perception](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tasks/omniperception/decider.cpp): `tasks/omniperception/decider.cpp`

### Calibration and Tools

- [Camera Calibration](https://github.com/tongjisuperpower/sp_vision_25/blob/main/calibration/calibrate_robotworld_handeye.cpp): `calibration/calibrate_robotworld_handeye.cpp`
- [Shared Math and Filters](https://github.com/tongjisuperpower/sp_vision_25/blob/main/tools/math_tools.cpp): `tools/math_tools.cpp`

### Other components

- **Robot Controller**
- **Enemy Targets**
- **Gimbal and Shooter**
- **Navigation System**

## Connections

- Robot Controller → Sentry Debug Loop: selects mode
- Sentry Debug Loop → Camera Capture: reads frames
- Sentry Debug Loop → Controller and IMU: reads IMU
- Sentry Debug Loop → Armor Detection: detects armor
- Armor Detection → Detection Methods: runs detection
- Sentry Debug Loop → Pose and Transforms: sets orientation
- Sentry Debug Loop → Omni Perception: updates perception
- Sentry Debug Loop → Controller and IMU: sends command
- Sentry Debug Loop → ROS Navigation: publishes target
- ROS Navigation → Navigation System: exchanges status
- Standard Loops → Camera Capture: reads frames
- Standard Loops → Controller and IMU: reads and commands
- Standard Loops → Armor Detection: detects armor
- Armor Detection → Pose and Transforms: provides detections
- Pose and Transforms → Target Tracking: estimates targets
- Target Tracking → Target State: updates state
- Target State → Trajectory Planner: supplies motion state
- Trajectory Planner → Aim Decision: plans trajectory
- Aim Decision → Fire Decision: provides aim
- Fire Decision → Controller and IMU: forms fire command
- Rune Targeting → Rune Prediction: provides rune detection
- Omni Perception → Armor Detection: requests detections
- Camera Calibration → Camera Capture: calibrates geometry
- Target Tracking → Shared Math and Filters: uses filters and math
- Rune Prediction → Shared Math and Filters: uses math utilities
- Controller and IMU → Gimbal and Shooter: transmits commands
- Camera Capture → Enemy Targets: captures images
- Gimbal Serial → Gimbal and Shooter: communicates state
