The repository provides a Docker container with a bash scripts that can seamlessly build and run the container.
Docker container offers ROS 2 environment whare you can launch vehicles in StoneFish.
The repository provides all necessary commands and references that can boost your software's research and development process, which utilizes the ROS 2 stack.
SITL allows you to simulate the vehicle hardware and firmware ArduSub on your host directly.
There are several scripts in: /extras_rov
, /extras_boat
to communicate with vehicle using Pymavlink.
There is a simple ROS 2 interface to ArduPilot (only for BlueROV2). Check /extras_interface
.
- Install NVIDIA Container Toolkit to support Docker to access GPU (required).
- Repository has been tested on: Ubuntu 22.04, Ubuntu 24.04, ArchLinux (Kernel 6.8).
- Run these commands, so the system will use the NVIDIA GPU for rendering graphics, which is typically desired for more graphics-intensive tasks.
sudo apt install nvidia-prime
sudo prime-select nvidia
sudo reboot now
Adjust paths in run.sh
.
local_workspace="/home/markus/underwater/stonefish_ros2_marine_robotics/src"
local_stonefish="/home/markus/underwater/stonefish_ros2_marine_robotics/stonefish"
local_sf_ws="/home/markus/underwater/stonefish_ros2_marine_robotics/sf_ws"
local_gz_ws="/home/markus/underwater/stonefish_ros2_marine_robotics/gz_ws"
local_SITL_Models="/home/markus//underwater/stonefish_ros2_marine_robotics/SITL_Models"
git clone https://github.com/markusbuchholz/stonefish_ros2_marine_robotics.git
cd /stonefish_ros2_marine_robotics/docker
sudo ./build.sh
sudo ./run.sh
cd ../stonefish
# IMPORTANT. You build only once since the stonefish volume is on your HOST.
mkdir -p build && cd build
cmake ..
make -j$(nproc)
# IMPORTANT. You have to run these two commands every time you run Docker container.
# 1.
sudo make install
# 2.
export LD_LIBRARY_PATH=/home/stonefish/build/libStonefish.so:$LD_LIBRARY_PATH
cd ../../sf_ws/
colcon build --packages-select stonefish_ros2
source install/setup.bash
colcon build --packages-select cola2_msgs
source install/setup.bash
colcon build
source install/setup.bash
Connect to running Docker container,
sudo docker exec -it ros2sim /bin/bash
ros2 launch cola2_stonefish bluerov_fls_simulation.launch.py
ros2 launch cola2_stonefish blueboat_launch.py
#terminal 1
ros2 run stonefish_bluerov2 ardusim_patch.py
#terminal 2
ros2 launch stonefish_bluerov2 bluerov2_sim.launch.py
#terminal 3
sim_vehicle.py -v ArduSub -f vectored_6dof --model JSON --map -l 55.99541530863445,-3.3010225004910683,0,0 -m --streamrate=-1
#terminal 4
cd /home/sf_ws/src/extras_rov
# run example script
# check for other scripts
python3 pos_req.py
Check BlueROV2 abilities using Mavlink
(fetch status information from ArduSub),
cd /home/sf_ws/src/extras_rov
python3 print_abilities.py
Setting the ArduSub RCPassThru parameter allows setting PWM directly for individual motors with values ranging from 1100 to 1900.
BlueRobotics T200 thruster specification.
Before use, Passthrough mode must be enabled via a service; the ROS 2 Interface for StonFish does this automatically.
Complete command pipeline
#terminal 1
ros2 run stonefish_bluerov2 ardusim_patch.py
#terminal 2
ros2 launch stonefish_bluerov2 bluerov2_sim.launch.py
#terminal 3
sim_vehicle.py -v ArduSub -f vectored_6dof --model JSON --map -l 55.99541530863445,-3.3010225004910683,0,0 -m --streamrate=-1
#terminal 4
# Run ROS 2 interface for StonFish
cd /home/sf_ws/src/extras_interface
python3 ros2_simple_bluerov2_interface.py
The motor can be controlled using the topics.
Example usage,
# motor 2
ros2 topic pub /bluerov2/thruster_2_pwm_set std_msgs/msg/Int32 "{data: 1600}"
# motor 7
ros2 topic pub /bluerov2/thruster_7_pwm_set std_msgs/msg/Int32 "{data: 1640}"
#terminal 1
ros2 run stonefish_bluerov2 ardusim_patch_boat.py
#terminal 2
ros2 launch stonefish_bluerov2 blueboat_sim.launch.py
#terminal 3
sim_vehicle.py -v Rover -f boat --model JSON --map --console -l 55.99541530863445,-3.3010225004910683,0,0
#terminal 4
cd /home/sf_ws/src/extras_boat
# run example script
# check for other scripts
python3 python3 check.py
ROS 2 interface provides two common topics (ROS 2 is a function wrapper for Mavlink protocol):
cd /home/sf_ws/src/extras_boat
python3 python3 ros2_simple_blueboat_interface.py
/bluerov2/odometry
/bluerov2/cmd_vel
/bluerov2/servo_outputs
Run simple motion directly to ArduRover,
cd /home/sf_ws/src/extras_boat
python3 pwm_control.py
ROS 2 interface provides two common topics (ROS 2 is a function wrapper for Mavlink protocol):
/bluerov2/odometry
/bluerov2/cmd_vel
/bluerov2/servo_outputs
Run the motors individually.
Note. To be FIXED by fixing ardusim_patch
(it works in GazeboSim),
ros2 topic pub /blueboat/send_port_motor_0_100_thrust std_msgs/msg/Float32 "{data: 50.0}"
ros2 topic pub /blueboat/send_stbd_motor_0_100_thrust std_msgs/msg/Float32 "{data: 75.0}"
#terminal 1
ros2 run stonefish_bluerov2 ardusim_patch_ros2_interface.py
#terminal 2
ros2 launch stonefish_bluerov2 bluerov2_sim_ros2_interface.launch.py
#terminal 3
sim_vehicle.py -v Rover -f boat --model JSON --map --console -l 55.99541530863445,-3.3010225004910683,0,0
#terminal 4
cd /home/sf_ws/src/extras_interface
python3 ros2_simple_blueboat_interface
Move BlueROV2,
ros2 topic pub -r 10 /bluerov2/cmd_vel geometry_msgs/msg/Twist "linear:
x: 0.0
y: 0.0
z: -2.0
angular:
x: 0.0
y: 0.0
z: 0.0" --qos-reliability reliable --qos-durability transient_local --qos-depth 10 -1
The PWM values: /bluerov2/servo_outputs
during robot motion can be simply saved,
cd /home/sf_ws/src/extras_interface
python3 ros2_pwm_topic_recorder.py