Skip to content

teleop_roboboat_tutorial

Carlos Agüero edited this page Jan 12, 2024 · 6 revisions

This page provides a description of how to drive the spawned USV. It assumes you've gone through the preceding tutorials regarding installation, and spawning. It also assumes a basic familiarity with Gazebo.

Thruster Setup

The actuators for the boat we spawned in the previous tutorial are defined by the Gazebo Sim Thruster Class. While there are a number of ways to control heading, with two thrusters we can simply employ differential thrust.

Launching Teleoperation Nodes

Launch the ROS/Gazebo bridge

To open the world file with one of the example RoboBoat vehicles (or your own custom vehicle), you'll need to add it to the world. Open the nbpark.sdf file, located in ~/vrx_ws/src/vrx/vrx_gz/worlds, and add the following code block:

<!-- RoboBoat 01 -->
<include>
  <name>roboboat01</name>
  <pose>-185 1088 0 0 0 0</pose>
  <uri>roboboat01</uri>
</include>

Then, launch the environment:

ros2 launch vrx_gz vrx_environment.launch.py world:=nbpark

To send messages from ROS2 to Gazebo Sim, we must utilize a bridge, specifying the topics and messages we need to send. For the left thruster:

ros2 run ros_gz_bridge parameter_bridge /model/roboboat01/joint/left_engine_propeller_joint/cmd_thrust@std_msgs/msg/Float64]gz.msgs.Double

and for the right thruster:

ros2 run ros_gz_bridge parameter_bridge /model/roboboat01/joint/right_engine_propeller_joint/cmd_thrust@std_msgs/msg/Float64]gz.msgs.Double

Test the Bridges

You can test that the bridges are working by publishing a topic to one or both of the thrusters:

ros2 topic pub /model/roboboat01/joint/left_engine_propeller_joint/cmd_thrust std_msgs/msg/Float64 "data: 150"

using this command you should see your boat going in circles.

Joystick Teleoperation

Config Adjustment

With both bridge commands running, in a separate terminal launch

ros2 launch vrx_gz usv_joy_teleop.py teleop_config:=/home/caguero/vrx2023_ws/src/vrx/vrx_gz/config/roboboat.yaml

The gamepad drives the left and right thrusters directly - similar to a differential drive wheeled robot.

  • The L1 button needs to be pressed all the time in addition to the following commands (dead man's switch),
  • the left stick up/down axis (axis 1) is mapped to the left thruster forward/reverse,
  • the right stick up/down axis (axis 3) is mapped to the right thruster forward/reverse

Therefore, pushing both sticks forward should cause the boat to drive forward.

Clone this wiki locally