Skip to content

Repository files navigation

I recommend to clone this repo in the same workspace you have the px4_msgs package -> Hence you would clone it in /px4_ws/src.

For Stabilized Control:

For it to work remember to use the appropiate namespace (same as the real BlueROV2 in the tank):

PX4_UXRCE_DDS_NS=itrl_rov_1 make px4_sitl_uuv gz_uuv_bluerov2_heavy

You can also try it in the KTH tank environment with:

PX4_UXRCE_DDS_NS=itrl_rov_1 PX4_GZ_WORLD=kth_marinarium make px4_sitl_uuv gz_uuv_bluerov2_heavy

There is also a version with the docking station:

PX4_GZ_WORLD=kth_marinarium_docking make px4_sitl_uuv gz_uuv_bluerov2_heavy

Remember to run the Micro-XRCE-DDS-Agent:

micro-xrce-dds-agent udp4 -p 8888

To launch the controller and the keyboard teleop, make sure you are in Offboard mode in QGC and:

cd ~/px4_ws
colcon build
source install/setup.bash

Launch the nodes (heartbeat + stabilized).

Example for a robot namespace <ns> being <splash>:

ros2 launch bluerov2_control stabilized_control.launch.py ns:=splash

In a second terminal run the custom keyboard teleop:

ros2 run bluerov2_control wasd_teleop

Or run joystick teleop for Xbox controllers where <joy_dev> is the selector between all connected controllers (i.e. 0 or 1 if two controllers are connected), and <cmd_vel_topic> is the topic we want to send the velocities to:

ros2 launch bluerov2_control teleop.launch.py joy_dev:=1 cmd_vel_topic:=/splash/cmd_vel

Also, make sure to arm the vehicle after you run the controller node.

For PID Position Control:

Same setup as Stabilized Control but run:

cd ~/px4_ws
colcon build
source install/setup.bash


# 1) Launch the nodes (heartbeat + PID)
ros2 launch bluerov2_control position_control_pid.launch.py

# 2) In a second terminal run the custom keyboard teleop 
ros2 run bluerov2_control wasd_teleop

For 6DoF MPC Holding controller:

You will need to install casadi:

pip install casadi

And then run:

cd ~/px4_ws
colcon build
source install/setup.bash


# 1) Launch the nodes (heartbeat + MPC)
ros2 launch bluerov2_control mpc_hold_position.launch.py

For 6DoF MPC Holding controller (acados):

Acados is a fast nonlinear optimization library designed for embedded applications. To use it first install it following the official documentation:

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 ..
make install -j4

pip install -e ../interfaces/acados_template

Then you also need to add environment variables (if you have it in a folder inside $HOME make sure to point to it below):

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/acados/lib
export ACADOS_SOURCE_DIR=$HOME/acados

To make them permanent, you can add those two lines to ~/.bashrc. You will also probably have to install the t_renderer, for that, download the latest one for your system here, rename it to just t_renderer and then inside your acados repository folder do:

mkdir -p bin

and place the renderer file there, then give it executable permissions:

chmod +x bin/t_renderer

and verify:

ls -l bin/t_renderer
/bin/t_renderer --help

If that last command runs, the renderer part is fixed.

Then build and launch:

cd ~/px4_ws
colcon build
source install/setup.bash

ros2 launch bluerov2_control mpc_hold_position_acados.launch.py

For 6DoF MPC Tracking controller:

Same installation instructions as the 6DoF MPC Holding controller (acados). It is currently setup for the Marinarium tank world with the docking station which is launch with:

PX4_UXRCE_DDS_NS=itrl_rov_1 PX4_GZ_WORLD=kth_marinarium_docking make px4_sitl_uuv gz_uuv_bluerov2_heavy

with the goal to dock in the station. You can build and launch it with:

cd ~/px4_ws
colcon build
source install/setup.bash

ros2 launch bluerov2_control rrt_star_mpc_docking.launch.py

About

A ROS2 package for running controllers with the PX4 BlueROV2 & the Gazebo simulator.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages