# sharminrahman/svin2 architecture

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

- Interactive diagram: https://gitdiagram.com/sharminrahman/svin2
- Repository: https://github.com/sharminrahman/svin2

## Overview

SVIn2 is a real-time underwater sonar–visual–inertial–depth SLAM system. Sensor measurements enter through the ROS adapter and are synchronized by the threaded processing layer; visual matching and triangulation feed a tightly coupled estimator, whose state and landmarks are published to ROS and files. A separate pose-graph module detects loops from keyframes and optimizes their poses. The graph reflects README capabilities and the sampled implementation; some ROS-node wiring and unsampled subsystem details are shown only where documented, not inferred.

Main entry points: [`okvis_ros/okvis/okvis_multisensor_processing/src/ThreadedKFVio.cpp`](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/ThreadedKFVio.cpp) (Threaded VIO), [`okvis_ros/okvis/okvis_frontend/src/Frontend.cpp`](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_frontend/src/Frontend.cpp) (Visual Frontend), [`pose-graph/src/LoopClosing.cpp`](https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/LoopClosing.cpp) (Loop Detection), [`okvis_ros/okvis/okvis_ceres/src/Estimator.cpp`](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/Estimator.cpp) (State Estimator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ros["ROS Integration"]
  node_rosinput["ROS Input<br/>[Subscriber.cpp]"]
  node_config["Configuration"]
  node_rosparams["ROS Parameters"]
  node_publisher["State Publisher<br/>[Publisher.cpp]"]
end

subgraph group_processing["Sensor Processing"]
  node_sync["Frame Synchronizers"]
  node_depthsync["Depth Synchronizer"]
  node_sonarsync["Sonar Synchronizer"]
  node_imusync["IMU Synchronizer"]
  node_threaded["Threaded VIO<br/>[ThreadedKFVio.cpp]"]
end

subgraph group_estimation["Visual-Inertial Estimation"]
  node_frontend["Visual Frontend<br/>[Frontend.cpp]"]
  node_matcher["Feature Matching"]
  node_triangulation["Stereo Triangulation"]
  node_estimator["State Estimator<br/>[Estimator.cpp]"]
  node_ceresmap["Optimization Map<br/>[Map.cpp]"]
  node_sensorerrors["Sensor Residuals<br/>[ImuError.cpp]"]
end

subgraph group_loop["Loop Closure"]
  node_keyframes["Keyframe Matcher<br/>[KFMatcher.cpp]"]
  node_loopclosing["Loop Detection<br/>[LoopClosing.cpp]"]
  node_bowdb[("Word Database")]
  node_posegraphnode["Pose Graph Node"]
  node_visualization["Pose Visualization"]
end

node_sensors(("Sensor Topics"))
node_rosoutputs(("ROS Outputs"))

node_sensors -->|"publish measurements"| node_rosinput
node_rosinput -->|"deliver measurements"| node_threaded
node_rosparams -->|"provide parameters"| node_config
node_config -->|"configure processing"| node_threaded
node_threaded -->|"synchronize frames"| node_sync
node_threaded -->|"synchronize IMU"| node_imusync
node_threaded -->|"synchronize depth"| node_depthsync
node_threaded -->|"synchronize sonar"| node_sonarsync
node_threaded -->|"process frames"| node_frontend
node_frontend -->|"match features"| node_matcher
node_frontend -->|"triangulate landmarks"| node_triangulation
node_threaded -->|"add measurements"| node_estimator
node_frontend -->|"add visual constraints"| node_estimator
node_estimator -->|"optimize states"| node_ceresmap
node_estimator -->|"add IMU residuals"| node_sensorerrors
node_threaded -->|"publish state callbacks"| node_publisher
node_publisher -->|"publish state and landmarks"| node_rosoutputs
node_posegraphnode -->|"manage keyframes"| node_keyframes
node_posegraphnode -->|"run loop closure"| node_loopclosing
node_loopclosing -->|"query descriptors"| node_bowdb
node_loopclosing -->|"compare keyframes"| node_keyframes
node_loopclosing -->|"draw optimized poses"| node_visualization
node_visualization -->|"publish markers"| node_rosoutputs

click node_rosinput "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/src/Subscriber.cpp"
click node_config "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_common/src/VioParametersReader.cpp"
click node_rosparams "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/src/RosParametersReader.cpp"
click node_sync "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/FrameSynchronizer.cpp"
click node_depthsync "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/DepthFrameSynchronizer.cpp"
click node_sonarsync "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/SonarFrameSynchronizer.cpp"
click node_imusync "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/ImuFrameSynchronizer.cpp"
click node_threaded "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/ThreadedKFVio.cpp"
click node_frontend "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_frontend/src/Frontend.cpp"
click node_matcher "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_matcher/src/MatchingAlgorithm.cpp"
click node_triangulation "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_frontend/src/ProbabilisticStereoTriangulator.cpp"
click node_estimator "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/Estimator.cpp"
click node_ceresmap "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/Map.cpp"
click node_sensorerrors "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/ImuError.cpp"
click node_publisher "https://github.com/sharminrahman/svin2/blob/master/okvis_ros/src/Publisher.cpp"
click node_keyframes "https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/KFMatcher.cpp"
click node_loopclosing "https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/LoopClosing.cpp"
click node_bowdb "https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/ThirdParty/DBoW/TemplatedDatabase.h"
click node_posegraphnode "https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/pose_graph_node.cpp"
click node_visualization "https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/utility/CameraPoseVisualization.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_rosinput,node_config,node_rosparams,node_publisher toneBlue
class node_sync,node_depthsync,node_sonarsync,node_imusync,node_threaded toneAmber
class node_frontend,node_matcher,node_triangulation,node_estimator,node_ceresmap,node_sensorerrors toneMint
class node_keyframes,node_loopclosing,node_bowdb,node_posegraphnode,node_visualization toneRose
class node_sensors,node_rosoutputs toneIndigo
```

## Components

### ROS Integration

- [ROS Input](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/src/Subscriber.cpp): `okvis_ros/src/Subscriber.cpp`
- [Configuration](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_common/src/VioParametersReader.cpp): `okvis_ros/okvis/okvis_common/src/VioParametersReader.cpp`
- [ROS Parameters](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/src/RosParametersReader.cpp): `okvis_ros/src/RosParametersReader.cpp`
- [State Publisher](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/src/Publisher.cpp): `okvis_ros/src/Publisher.cpp`

### Sensor Processing

- [Frame Synchronizers](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/FrameSynchronizer.cpp): `okvis_ros/okvis/okvis_multisensor_processing/src/FrameSynchronizer.cpp`
- [Depth Synchronizer](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/DepthFrameSynchronizer.cpp): `okvis_ros/okvis/okvis_multisensor_processing/src/DepthFrameSynchronizer.cpp`
- [Sonar Synchronizer](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/SonarFrameSynchronizer.cpp): `okvis_ros/okvis/okvis_multisensor_processing/src/SonarFrameSynchronizer.cpp`
- [IMU Synchronizer](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/ImuFrameSynchronizer.cpp): `okvis_ros/okvis/okvis_multisensor_processing/src/ImuFrameSynchronizer.cpp`
- [Threaded VIO](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_multisensor_processing/src/ThreadedKFVio.cpp): `okvis_ros/okvis/okvis_multisensor_processing/src/ThreadedKFVio.cpp`

### Visual-Inertial Estimation

- [Visual Frontend](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_frontend/src/Frontend.cpp): `okvis_ros/okvis/okvis_frontend/src/Frontend.cpp`
- [Feature Matching](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_matcher/src/MatchingAlgorithm.cpp): `okvis_ros/okvis/okvis_matcher/src/MatchingAlgorithm.cpp`
- [Stereo Triangulation](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_frontend/src/ProbabilisticStereoTriangulator.cpp): `okvis_ros/okvis/okvis_frontend/src/ProbabilisticStereoTriangulator.cpp`
- [State Estimator](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/Estimator.cpp): `okvis_ros/okvis/okvis_ceres/src/Estimator.cpp`
- [Optimization Map](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/Map.cpp): `okvis_ros/okvis/okvis_ceres/src/Map.cpp`
- [Sensor Residuals](https://github.com/sharminrahman/svin2/blob/master/okvis_ros/okvis/okvis_ceres/src/ImuError.cpp): `okvis_ros/okvis/okvis_ceres/src/ImuError.cpp`

### Loop Closure

- [Keyframe Matcher](https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/KFMatcher.cpp): `pose-graph/src/KFMatcher.cpp`
- [Loop Detection](https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/LoopClosing.cpp): `pose-graph/src/LoopClosing.cpp`
- [Word Database](https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/ThirdParty/DBoW/TemplatedDatabase.h): `pose-graph/src/ThirdParty/DBoW/TemplatedDatabase.h`
- [Pose Graph Node](https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/pose_graph_node.cpp): `pose-graph/src/pose_graph_node.cpp`
- [Pose Visualization](https://github.com/sharminrahman/svin2/blob/master/pose-graph/src/utility/CameraPoseVisualization.cpp): `pose-graph/src/utility/CameraPoseVisualization.cpp`

### Other components

- **Sensor Topics**
- **ROS Outputs**

## Connections

- Sensor Topics → ROS Input: publish measurements
- ROS Input → Threaded VIO: deliver measurements
- ROS Parameters → Configuration: provide parameters
- Configuration → Threaded VIO: configure processing
- Threaded VIO → Frame Synchronizers: synchronize frames
- Threaded VIO → IMU Synchronizer: synchronize IMU
- Threaded VIO → Depth Synchronizer: synchronize depth
- Threaded VIO → Sonar Synchronizer: synchronize sonar
- Threaded VIO → Visual Frontend: process frames
- Visual Frontend → Feature Matching: match features
- Visual Frontend → Stereo Triangulation: triangulate landmarks
- Threaded VIO → State Estimator: add measurements
- Visual Frontend → State Estimator: add visual constraints
- State Estimator → Optimization Map: optimize states
- State Estimator → Sensor Residuals: add IMU residuals
- Threaded VIO → State Publisher: publish state callbacks
- State Publisher → ROS Outputs: publish state and landmarks
- Pose Graph Node → Keyframe Matcher: manage keyframes
- Pose Graph Node → Loop Detection: run loop closure
- Loop Detection → Word Database: query descriptors
- Loop Detection → Keyframe Matcher: compare keyframes
- Loop Detection → Pose Visualization: draw optimized poses
- Pose Visualization → ROS Outputs: publish markers
