# bvibhav/stonefish_bluerov2 architecture

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

- Interactive diagram: https://gitdiagram.com/bvibhav/stonefish_bluerov2
- Repository: https://github.com/bvibhav/stonefish_bluerov2

## Overview

#### Purpose and Runtime Model
This ROS 2 package supplies Stonefish simulation scenes for Blue Robotics vehicles, principally the BlueROV2, and bridges simulator state/actuation to ArduPilot SITL’s JSON simulator protocol. It also supports a BlueBoat/Rover simulation. The operational entry point is ROS 2 launch; ArduSub or Rover SITL runs separately, with QGroundControl or a ROS driver providing vehicle control.

#### Build and Package Boundary
The repository is a colcon/ament CMake package defined by `package.xml` and `CMakeLists.txt`. It depends materially on ROS 2 Jazzy, the Stonefish library and ROS 2 wrapper (v1.3-compatible scenes), and a local ArduPilot SITL installation. This repo contains scene and launch integration rather than ArduPilot or Stonefish implementations.

Paths: `package.xml`, `CMakeLists.txt`, `stonefish_bluerov2/__init__.py`

#### Launch Entry Points
Python ROS 2 launch files select and start simulations:
- BlueROV2: `launch/bluerov2_sim.py`
- BlueBoat/Rover: `launch/blueboat_sim.py`
- General/alternate simulation entry: `launch/bluesim.py`

These launches are the boundary between ROS graph orchestration and the Stonefish scenario definitions. SITL must be launched independently using ArduPilot’s `--model JSON` mode.

#### Scenario Layer
Stonefish `.scn` files define the simulated vehicle, physical world, and mission environment. BlueROV2 scenarios range from basic/test and tank environments to turbine/farm scenes; boat and Sonobot scenarios extend the same asset-driven simulation model.

Paths: `scenarios/bluerov2.scn`, `scenarios/bluerov2_farm.scn`, `scenarios/blueboat.scn`

#### Vehicle and Environment Assets
The `data/` hierarchy provides geometry and material inputs referenced by scenarios: BlueROV2 URDF and meshes, BlueBoat components, Sonobot, seabed/tank objects, and wind-turbine models. These assets are a runtime dependency of Stonefish scene loading, not generated build output.

Paths: `data/bluerov2.urdf`, `data/bluerov2/bluerov2.obj`, `data/turbines/turbine2.obj`

#### Primary Control and Data Flow
1. A ROS launch starts Stonefish with a selected scenario.
2. Stonefish simulates vehicle/environment dynamics and exposes ROS-facing simulation interfaces through the installed Stonefish ROS 2 wrapper.
3. The package’s simulator-side integration exchanges state/sensor and actuator information with an externally running ArduPilot JSON SITL instance.
4. ArduPilot produces vehicle control outputs; Stonefish applies them to the simulated vehicle and returns simulation data.
5. QGroundControl communicates with SITL for operator control/configuration; optionally, an external BlueROV2 ROS driver participates through ROS 2.

Key external boundaries are ROS 2/DDS, Stonefish, ArduPilot JSON SITL, and QGroundControl; none are vendored here.

#### Simulation Customization
Scenario selection is the primary extension point: use existing vehicle/world combinations or add `.scn` files referencing assets under `data/`. `scripts/ardusim_patch.py` is the repository’s explicit ArduSim-related integration utility, indicating compatibility work remains separate from launch/scene definitions.

Paths: `scripts/ardusim_patch.py`, `scenarios/bluerov2_tank.scn`, `scenarios/turbine1.scn`

Main entry points: [`scenarios/bluerov2.scn`](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2.scn) (Stonefish Scenarios), [`scenarios/bluerov2_farm.scn`](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2_farm.scn) (Farm Scenario), [`CMakeLists.txt`](https://github.com/bvibhav/stonefish_bluerov2/blob/master/CMakeLists.txt) (CMake Package Build), [`scenarios/blueboat.scn`](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/blueboat.scn) (BlueBoat Scenario)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_package["ROS 2 Package"]
  node_build["ament Build Metadata<br/>package manifest<br/>[package.xml]"]
  node_cmake["CMake Package Build<br/>build definition<br/>[CMakeLists.txt]"]
  node_python_package["Python Package<br/>ROS package module<br/>[__init__.py]"]
  node_bluerov_launch["BlueROV2 Launch<br/>ROS 2 launch<br/>[bluerov2_sim.py]"]
  node_blueboat_launch["BlueBoat/Rover Launch<br/>ROS 2 launch<br/>[blueboat_sim.py]"]
  node_alternate_launch["Alternate Simulation Launch<br/>ROS 2 launch<br/>[bluesim.py]"]
  node_ardusim_patch["ArduSim Patch Utility<br/>integration utility<br/>[ardusim_patch.py]"]
end

subgraph group_simulation["Scene Runtime"]
  node_scenarios["Stonefish Scenarios<br/>scene definitions<br/>[bluerov2.scn]"]
  node_farm_scene["Farm Scenario<br/>scene definition<br/>[bluerov2_farm.scn]"]
  node_boat_scene["BlueBoat Scenario<br/>scene definition<br/>[blueboat.scn]"]
  node_custom_scenes["Custom Scene Examples<br/>scene definitions<br/>[bluerov2_tank.scn]"]
  node_vehicle_assets["Vehicle Assets<br/>URDF and geometry<br/>[bluerov2.urdf]"]
  node_environment_assets["Environment Assets<br/>scene geometry<br/>[turbine2.obj]"]
  node_json_bridge["JSON SITL Exchange<br/>simulator integration"]
end

subgraph group_external["External Systems"]
  node_stonefish{{"Stonefish + ROS 2 Wrapper<br/>simulator runtime"}}
  node_ardupilot{{"ArduPilot SITL<br/>external flight controller"}}
  node_qgroundcontrol["QGroundControl<br/>operator station"]
  node_ros_driver["BlueROV2 ROS Driver<br/>optional ROS client"]
end

node_build -->|"package metadata"| node_cmake
node_cmake -->|"builds/installs"| node_python_package
node_bluerov_launch -->|"selects"| node_scenarios
node_blueboat_launch -->|"selects"| node_boat_scene
node_alternate_launch -->|"starts"| node_scenarios
node_scenarios -->|"loaded by"| node_stonefish
node_farm_scene -->|"loaded by"| node_stonefish
node_boat_scene -->|"loaded by"| node_stonefish
node_custom_scenes -->|"loaded by"| node_stonefish
node_scenarios -->|"references"| node_vehicle_assets
node_farm_scene -->|"references"| node_environment_assets
node_stonefish -->|"simulation state and sensors"| node_json_bridge
node_json_bridge -->|"actuator commands"| node_stonefish
node_json_bridge -->|"JSON protocol"| node_ardupilot
node_ardupilot -->|"vehicle control/configuration"| node_qgroundcontrol
node_ros_driver -.->|"optional ROS 2 interaction"| node_stonefish
node_ardusim_patch -.->|"compatibility support"| node_ardupilot

click node_build "https://github.com/bvibhav/stonefish_bluerov2/blob/master/package.xml"
click node_cmake "https://github.com/bvibhav/stonefish_bluerov2/blob/master/CMakeLists.txt"
click node_python_package "https://github.com/bvibhav/stonefish_bluerov2/blob/master/stonefish_bluerov2/__init__.py"
click node_bluerov_launch "https://github.com/bvibhav/stonefish_bluerov2/blob/master/launch/bluerov2_sim.py"
click node_blueboat_launch "https://github.com/bvibhav/stonefish_bluerov2/blob/master/launch/blueboat_sim.py"
click node_alternate_launch "https://github.com/bvibhav/stonefish_bluerov2/blob/master/launch/bluesim.py"
click node_ardusim_patch "https://github.com/bvibhav/stonefish_bluerov2/blob/master/scripts/ardusim_patch.py"
click node_scenarios "https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2.scn"
click node_farm_scene "https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2_farm.scn"
click node_boat_scene "https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/blueboat.scn"
click node_custom_scenes "https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2_tank.scn"
click node_vehicle_assets "https://github.com/bvibhav/stonefish_bluerov2/blob/master/data/bluerov2.urdf"
click node_environment_assets "https://github.com/bvibhav/stonefish_bluerov2/blob/master/data/turbines/turbine2.obj"

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_build,node_cmake,node_python_package,node_bluerov_launch,node_blueboat_launch,node_alternate_launch,node_ardusim_patch toneBlue
class node_scenarios,node_farm_scene,node_boat_scene,node_custom_scenes,node_vehicle_assets,node_environment_assets,node_json_bridge toneAmber
class node_stonefish,node_ardupilot,node_qgroundcontrol,node_ros_driver toneMint
```

## Components

### ROS 2 Package

- [ament Build Metadata](https://github.com/bvibhav/stonefish_bluerov2/blob/master/package.xml): package manifest · Defines the colcon/ament package and runtime dependencies. · `package.xml`
- [CMake Package Build](https://github.com/bvibhav/stonefish_bluerov2/blob/master/CMakeLists.txt): build definition · `CMakeLists.txt`
- [Python Package](https://github.com/bvibhav/stonefish_bluerov2/blob/master/stonefish_bluerov2/__init__.py): ROS package module · `stonefish_bluerov2/__init__.py`
- [BlueROV2 Launch](https://github.com/bvibhav/stonefish_bluerov2/blob/master/launch/bluerov2_sim.py): ROS 2 launch · `launch/bluerov2_sim.py`
- [BlueBoat/Rover Launch](https://github.com/bvibhav/stonefish_bluerov2/blob/master/launch/blueboat_sim.py): ROS 2 launch · `launch/blueboat_sim.py`
- [Alternate Simulation Launch](https://github.com/bvibhav/stonefish_bluerov2/blob/master/launch/bluesim.py): ROS 2 launch · `launch/bluesim.py`
- [ArduSim Patch Utility](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scripts/ardusim_patch.py): integration utility · Applies separate ArduSim compatibility work. · `scripts/ardusim_patch.py`

### Scene Runtime

- [Stonefish Scenarios](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2.scn): scene definitions · Select vehicle, world, and mission environment. · `scenarios/bluerov2.scn`
- [Farm Scenario](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2_farm.scn): scene definition · `scenarios/bluerov2_farm.scn`
- [BlueBoat Scenario](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/blueboat.scn): scene definition · `scenarios/blueboat.scn`
- [Custom Scene Examples](https://github.com/bvibhav/stonefish_bluerov2/blob/master/scenarios/bluerov2_tank.scn): scene definitions · `scenarios/bluerov2_tank.scn`
- [Vehicle Assets](https://github.com/bvibhav/stonefish_bluerov2/blob/master/data/bluerov2.urdf): URDF and geometry · Runtime vehicle inputs loaded by scenarios. · `data/bluerov2.urdf`
- [Environment Assets](https://github.com/bvibhav/stonefish_bluerov2/blob/master/data/turbines/turbine2.obj): scene geometry · Turbine, seabed, and tank models support mission worlds. · `data/turbines/turbine2.obj`
- **JSON SITL Exchange**: simulator integration · Transfers simulated state, sensors, and actuator commands.

### External Systems

- **Stonefish + ROS 2 Wrapper**: simulator runtime · Loads scenes, simulates dynamics, and exposes ROS interfaces.
- **ArduPilot SITL**: external flight controller · Runs independently in JSON model mode.
- **QGroundControl**: operator station
- **BlueROV2 ROS Driver**: optional ROS client

## Connections

- ament Build Metadata → CMake Package Build: package metadata
- CMake Package Build → Python Package: builds/installs
- BlueROV2 Launch → Stonefish Scenarios: selects
- BlueBoat/Rover Launch → BlueBoat Scenario: selects
- Alternate Simulation Launch → Stonefish Scenarios: starts
- Stonefish Scenarios → Stonefish + ROS 2 Wrapper: loaded by
- Farm Scenario → Stonefish + ROS 2 Wrapper: loaded by
- BlueBoat Scenario → Stonefish + ROS 2 Wrapper: loaded by
- Custom Scene Examples → Stonefish + ROS 2 Wrapper: loaded by
- Stonefish Scenarios → Vehicle Assets: references
- Farm Scenario → Environment Assets: references
- Stonefish + ROS 2 Wrapper → JSON SITL Exchange: simulation state and sensors
- JSON SITL Exchange → Stonefish + ROS 2 Wrapper: actuator commands
- JSON SITL Exchange → ArduPilot SITL: JSON protocol
- ArduPilot SITL → QGroundControl: vehicle control/configuration
- BlueROV2 ROS Driver → Stonefish + ROS 2 Wrapper: optional ROS 2 interaction
- ArduSim Patch Utility → ArduPilot SITL: compatibility support
