This work implements a NMPC controller for BlueROV2 with ROS.
This repository contains the robot description and necessary launch files to simulate the BlueROV2 (unmanned underwater vehicle) on Unmanned Underwater Vehicle Simulator (UUV Simulator). Additional it's possible run BlueROV2 in SITL using mavros, joystick interaction and video streaming capture with opencv based on bluerov_ros_playground package from BlueRobotics.
This work is developed based on Ingeniarius, Lda. and Instituite of Systems and Robotics University of Coimbra within the scope of MS thesis "Localization of an unmanned underwater vehicle using multiple water surface robots, multilateration, and sensor data fusion".
- Python 3.7
- ROS (ROS noetic recommended)
- uuv simulator
- MAVROS
- Acados
We also provide its docker image to save you some time.
-
Install python 3.7 and its dependencies
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install -y python3.7 apt-get install -y python3-pip pip3 install numpy matplotlib scipy future-fstrings casadi>=3.5.1 setuptools sudo apt-get install -y python3.7-tk
-
Install Acados
git clone https://github.com/acados/acados.git cd acados git submodule update --recursive --init mkdir -p build cd build cmake -DACADOS_WITH_QPOASES=ON -DACADOS_WITH_OSQP=OFF/ON -DACADOS_INSTALL_DIR=<path_to_acados_installation_folder> .. make install -j4 pip install -e ~/acados/interfaces/acados_template echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/root/acados/lib"' >> ~/.bashrc echo 'export ACADOS_SOURCE_DIR="/root/acados"' >> ~/.bashrc source ~/.bashrc
-
Install ros uuv-simulator packages
sudo apt-get install -y ros-noetic-geodesy mkdir -p ~/catkin_ws/src && \ cd ~/catkin_ws/src && \ git clone --branch noetic https://github.com/arturmiller/uuv_simulator.git
-
Install then compile this package
cd ~/catkin_ws/src && \ git clone https://github.com/HKPolyU-UAV/bluerov2.git
Please edit CMakelists.txt here and here if you put your acados in otherwise directory. Modify the line
set(acados_include "~/acados/include")
andset(acados_lib "~/acados/lib")
Then do
cd ~/catkin_ws/src/bluerov2/bluerov2_dobmpc/scripts && \ yes | python3 generate_c_code.py
and
cd ~/catkin_ws/src/bluerov2/bluerov2_mpc/scripts && \ yes | python3 generate_c_code.py
The last commands basically run generate_c_code.py at here and here.
Finally, do
cd ~/catkin_ws && catkin_make
Ocean_waves in uuv simulator is set as default world.
Quick start to initialize the Gazebo world and add blueROV2 vehicle
roslaunch bluerov2_gazebo quick_start.launch
Or start with thruster manager
roslaunch bluerov2_gazebo start_with_thruster_manager.launch
With thruster manager, forces and moments can be published to topic /bluerov2/thruster_manager/input.
Start PID controller with teleop (using joystick)
roslaunch bluerov2_gazebo start_pid_demo_with_teleop.launch
Or start PID Controller without teleop
roslaunch bluerov2_gazebo start_pid_demo.launch
Further trajectory tracking tasks can be done with uuv_control_utils package, such as following linear trajectory
roslaunch uuv_control_utils send_waypoints_file.launch uuv_name:=bluerov2 interpolator:=linear
Or following helical trajectory
roslaunch uuv_control_utils start_helical_trajectory.launch uuv_name:=bluerov2 n_turns:=2
A demonstration of starting MPC controler to follow circular trajectory can be launched by
roslaunch bluerov2_gazebo start_mpc_demo.launch
The bluerov2_mpc package also includes more trajectory following tasks such as following leminscate path and self defined waypoints.
A demonstration of starting MPC controler to follow circular trajectory can be launched by
roslaunch bluerov2_dobmpc start_dobmpc_demo.launch
The generated disturbances can be adjusted at here or here.
This repository contains the research code for our paper: https://doi.org/10.3390/jmse12010094.