# bthek1/ros2_pi architecture

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

## Overview

ros2_pi is a ROS 2 monocular visual-odometry and dense-mapping system: a moving RGB camera supplies frames; tracking estimates camera pose while monocular inference estimates depth; mapping fuses those into a mesh viewed in a browser dashboard. The README explicitly notes there is no loop closure, pose graph, or relocalisation, so this is not a complete SLAM loop. The graph includes documented dataset replay and camera calibration capabilities. Some subsystem wiring is based on README and launch documentation because those implementation files were not sampled.

Main entry points: [`src/pimesh_bringup/launch/pimesh.launch.py`](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_bringup/launch/pimesh.launch.py) (ROS bringup), [`src/pimesh_frontend/src/odometry_node.cpp`](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/odometry_node.cpp) (Pose estimation), [`src/pimesh_mapping/src/fusion_node.cpp`](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/fusion_node.cpp) (TSDF fusion), [`src/pimesh_depth/src/depth_node.cpp`](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_depth/src/depth_node.cpp) (Depth node)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and bringup"]
  node_camera["Camera capture<br/>[camera_node.cpp]"]
  node_launch["ROS bringup<br/>[pimesh.launch.py]"]
  node_calibration["Camera calibration<br/>[calib_solve.py]"]
end

subgraph group_tracking["Visual tracking"]
  node_decode["Frame decode<br/>[decode_node.cpp]"]
  node_keypoints["ORB keypoints<br/>[keypoint_node.cpp]"]
  node_odometry["Pose estimation<br/>[odometry_node.cpp]"]
  node_keyframes[("Keyframe store<br/>[keyframe_store.cpp]")]
end

subgraph group_depth["Depth inference"]
  node_depth_node["Depth node<br/>[depth_node.cpp]"]
  node_depth_engine["Depth engine"]
end

subgraph group_mapping["Dense mapping"]
  node_fusion["TSDF fusion<br/>[fusion_node.cpp]"]
  node_volume[("TSDF volume<br/>[tsdf_volume.cpp]")]
  node_shared_volume["Shared volume<br/>[shared_volume.cpp]"]
  node_mesh["Mesh extraction<br/>[mesh_node.cpp]"]
  node_mesh_algorithms["Mesh processing<br/>[marching_cubes.cpp]"]
end

subgraph group_observability["Replay and dashboard"]
  node_dataset["Dataset replay<br/>[dataset_node.cpp]"]
  node_dataset_reader["Dataset reader<br/>[dataset_reader.cpp]"]
  node_dashboard["Dashboard node<br/>[dashboard_node.cpp]"]
  node_web_server["Web server<br/>[web_server.cpp]"]
  node_websocket["WebSocket<br/>[websocket.cpp]"]
end

node_camera_hw(("RGB camera"))
node_browser(("Browser viewer<br/>[app.js]"))
node_depth_model["ONNX model"]

node_camera_hw -->|"captures frames"| node_camera
node_camera -->|"publishes JPEG"| node_decode
node_camera -->|"publishes intrinsics"| node_odometry
node_camera -->|"publishes intrinsics"| node_fusion
node_launch -->|"loads component"| node_decode
node_launch -->|"loads component"| node_keypoints
node_launch -->|"loads component"| node_odometry
node_launch -->|"loads component"| node_depth_node
node_launch -->|"loads component"| node_fusion
node_launch -->|"loads component"| node_mesh
node_decode -->|"publishes frames"| node_keypoints
node_decode -->|"publishes frames"| node_depth_node
node_keypoints -->|"publishes tracks"| node_odometry
node_odometry -->|"updates keyframes"| node_keyframes
node_depth_node -->|"runs inference"| node_depth_engine
node_depth_model -->|"provides weights"| node_depth_engine
node_depth_node -->|"publishes depth and RGB"| node_fusion
node_odometry -->|"publishes poses"| node_fusion
node_fusion -->|"accesses volume"| node_shared_volume
node_shared_volume -->|"shares TSDF"| node_volume
node_mesh -->|"reads volume"| node_shared_volume
node_mesh -->|"extracts surface"| node_mesh_algorithms
node_mesh -->|"publishes mesh"| node_dashboard
node_depth_node -->|"publishes status and images"| node_dashboard
node_odometry -->|"publishes pose and stats"| node_dashboard
node_fusion -->|"publishes stats"| node_dashboard
node_dataset -->|"reads recordings"| node_dataset_reader
node_dataset_reader -.->|"replays frames"| node_decode
node_dashboard -->|"serves dashboard"| node_web_server
node_web_server -->|"dispatches messages"| node_websocket
node_websocket -->|"streams updates"| node_browser
node_browser -->|"requests actions"| node_web_server

click node_camera "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_camera/src/camera_node.cpp"
click node_launch "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_bringup/launch/pimesh.launch.py"
click node_decode "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/decode_node.cpp"
click node_keypoints "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/keypoint_node.cpp"
click node_odometry "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/odometry_node.cpp"
click node_keyframes "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/keyframe_store.cpp"
click node_calibration "https://github.com/bthek1/ros2_pi/blob/main/tools/calib/calib_solve.py"
click node_depth_node "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_depth/src/depth_node.cpp"
click node_depth_engine "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_depth/src/depth_engine_ort.cpp"
click node_fusion "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/fusion_node.cpp"
click node_volume "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/tsdf_volume.cpp"
click node_shared_volume "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/shared_volume.cpp"
click node_mesh "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/mesh_node.cpp"
click node_mesh_algorithms "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/marching_cubes.cpp"
click node_dataset "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dataset/src/dataset_node.cpp"
click node_dataset_reader "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dataset/src/dataset_reader.cpp"
click node_dashboard "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/src/dashboard_node.cpp"
click node_web_server "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/src/web_server.cpp"
click node_websocket "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/src/websocket.cpp"
click node_browser "https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/web/app.js"

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_camera,node_launch,node_calibration,node_browser toneBlue
class node_decode,node_keypoints,node_odometry,node_keyframes toneAmber
class node_depth_node,node_depth_engine toneMint
class node_fusion,node_volume,node_shared_volume,node_mesh,node_mesh_algorithms toneRose
class node_dataset,node_dataset_reader,node_dashboard,node_web_server,node_websocket,node_camera_hw,node_depth_model toneIndigo
```

## Components

### Capture and bringup

- [Camera capture](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_camera/src/camera_node.cpp): `src/pimesh_camera/src/camera_node.cpp`
- [ROS bringup](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_bringup/launch/pimesh.launch.py): `src/pimesh_bringup/launch/pimesh.launch.py`
- [Camera calibration](https://github.com/bthek1/ros2_pi/blob/main/tools/calib/calib_solve.py): `tools/calib/calib_solve.py`

### Visual tracking

- [Frame decode](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/decode_node.cpp): `src/pimesh_frontend/src/decode_node.cpp`
- [ORB keypoints](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/keypoint_node.cpp): `src/pimesh_frontend/src/keypoint_node.cpp`
- [Pose estimation](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/odometry_node.cpp): `src/pimesh_frontend/src/odometry_node.cpp`
- [Keyframe store](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_frontend/src/keyframe_store.cpp): `src/pimesh_frontend/src/keyframe_store.cpp`

### Depth inference

- [Depth node](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_depth/src/depth_node.cpp): `src/pimesh_depth/src/depth_node.cpp`
- [Depth engine](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_depth/src/depth_engine_ort.cpp): `src/pimesh_depth/src/depth_engine_ort.cpp`

### Dense mapping

- [TSDF fusion](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/fusion_node.cpp): `src/pimesh_mapping/src/fusion_node.cpp`
- [TSDF volume](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/tsdf_volume.cpp): `src/pimesh_mapping/src/tsdf_volume.cpp`
- [Shared volume](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/shared_volume.cpp): `src/pimesh_mapping/src/shared_volume.cpp`
- [Mesh extraction](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/mesh_node.cpp): `src/pimesh_mapping/src/mesh_node.cpp`
- [Mesh processing](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_mapping/src/marching_cubes.cpp): `src/pimesh_mapping/src/marching_cubes.cpp`

### Replay and dashboard

- [Dataset replay](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dataset/src/dataset_node.cpp): `src/pimesh_dataset/src/dataset_node.cpp`
- [Dataset reader](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dataset/src/dataset_reader.cpp): `src/pimesh_dataset/src/dataset_reader.cpp`
- [Dashboard node](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/src/dashboard_node.cpp): `src/pimesh_dashboard/src/dashboard_node.cpp`
- [Web server](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/src/web_server.cpp): `src/pimesh_dashboard/src/web_server.cpp`
- [WebSocket](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/src/websocket.cpp): `src/pimesh_dashboard/src/websocket.cpp`

### Other components

- **RGB camera**
- [Browser viewer](https://github.com/bthek1/ros2_pi/blob/main/src/pimesh_dashboard/web/app.js): `src/pimesh_dashboard/web/app.js`
- **ONNX model**

## Connections

- RGB camera → Camera capture: captures frames
- Camera capture → Frame decode: publishes JPEG
- Camera capture → Pose estimation: publishes intrinsics
- Camera capture → TSDF fusion: publishes intrinsics
- ROS bringup → Frame decode: loads component
- ROS bringup → ORB keypoints: loads component
- ROS bringup → Pose estimation: loads component
- ROS bringup → Depth node: loads component
- ROS bringup → TSDF fusion: loads component
- ROS bringup → Mesh extraction: loads component
- Frame decode → ORB keypoints: publishes frames
- Frame decode → Depth node: publishes frames
- ORB keypoints → Pose estimation: publishes tracks
- Pose estimation → Keyframe store: updates keyframes
- Depth node → Depth engine: runs inference
- ONNX model → Depth engine: provides weights
- Depth node → TSDF fusion: publishes depth and RGB
- Pose estimation → TSDF fusion: publishes poses
- TSDF fusion → Shared volume: accesses volume
- Shared volume → TSDF volume: shares TSDF
- Mesh extraction → Shared volume: reads volume
- Mesh extraction → Mesh processing: extracts surface
- Mesh extraction → Dashboard node: publishes mesh
- Depth node → Dashboard node: publishes status and images
- Pose estimation → Dashboard node: publishes pose and stats
- TSDF fusion → Dashboard node: publishes stats
- Dataset replay → Dataset reader: reads recordings
- Dataset reader → Frame decode: replays frames
- Dashboard node → Web server: serves dashboard
- Web server → WebSocket: dispatches messages
- WebSocket → Browser viewer: streams updates
- Browser viewer → Web server: requests actions
