Page tree
Skip to end of metadata
Go to start of metadata

Introduction

The intent of the following instructions is to present a working example of a simulated Kingfisher/Heron USV in the Gazebo environment, which includes

  1. A physical and visual description of the USV - supplied by the ros-indigo-kingfisher-description package.  The physical description includes the rigid body dynamics.
  2. A Gazebo plugin to define the added hydrodynamic forces and thruster dynamics of the USV
  3. Gazebo plugins to simulate sensor measurements

Prerequisites

Kinetic

Here we assume that you are using the NPS ROS development environment: Ubuntu 16.04 and ROS Kinetic (documentation forthcoming)

sudo apt-get install ros-kinetic-hector-gazebo-plugins  ros-kinetic-geographic-info ros-kinetic-tf2-geometry-msgs

Build the following ROS packages form source:

Indigo

Here we assume that you are using the NPS ROS development environment: Ubuntu 14.04 and ROS Indigo

You should have the following packages installed

  • ros-indigo-kingfisher-description: provides the URDF description of the shape and size of the USV
  • ros-indigo-kingfisher-msgs: defines the kingfisher-specific ROS messages - including the "cmd_drive" message type used to command the USV.
  • ros-indigo-hector-gazebo-plugins: defines the IMU and GPS simulators as plugins to Gazebo
sudo apt-get update
sudo apt-get install ros-indigo-kingfisher-description ros-indigo-kingfisher-msgs ros-indigo-hector-gazebo-plugins

 

The following source packages are also required

You should download all three of the above packages into your local catkin workspace and compile them using the catkin_make.  If you are new to adding ROS packages to your system, use this tutorial: Setting up a ROS package from Git for a general tutorial on the workflow of adding new source packages to your system.

With any luck the project will build without errors and you will see something like this...

Notice the lines in green and red which are encouraging signs that the library was build.  If you look in ~/catckin_ws/devel/lib/ you should see the file libusv_gazebo_dynamics_plugins.so which is the compiled library that will be used by Gazebo

Launching a Kingfisher in Gazebo

We will use a launch file from the kingfisher_gazebo package to create an instance of the model and plugin - this is referred to as spawning the model. 

Wwe should be able to use a launch file to do the following...

  1. Start Gazebo
  2. Load the URDF description of the Kingfisher in the parameter server.  This includes our Gazebo plugin to define the dynamics
  3. Start the robot_state_publisher node
  4. Spawn the Kingfisher within Gazebo
roslaunch kingfisher_gazebo base_gazebo.launch

The base_gazebo.launch file accepts a arguments for different sensor situations - see Simulated Sensors: Kingfisher Example for more information.

If this is the first time you've run Gazebo on the machine, you may see some errors having to do with downloading models from the model database.  The Gazebo window will open, but will just be black.  Let Gazebo run for ~5 minutes in this state and restart the program.  This should allow Gazebo some time to download the standard models.

If successful you should see something like this...

You should see the terminal window include output similar to this...

The plugin is generating the Command timeout! messages indicating it is not receiving Drive messages on the cmd_drive channel.  Some examples on generating Drive messages are...

Simulation Parameters

They physical parameters of the USV (drag, added mass, etc.) are defined as parameters within the usv_gazebo_dynamics_plugin.xacro file in the usv_gazebo_plugins package, urdf directory.  Details on the parameter notation can be found at... http://wiki.ros.org/usv_gazebo_plugins: https://wiki.nps.edu/display/RC/Driving+Kingfisher+with+Keyboard The parameters sensors (covariances, bias, offsets, etc.) are defined in the urdf directory of the kingfisher_gazebo package, e.g., gps.gazebo.xacro, imu.gazebo.xacro, etc.

(Re)Setting Model State

A nice way to test the model is to set the state of the model and then see the natural response.  this can be done using the rostopic command like so...

rostopic pub -1 /gazebo/set_model_state gazebo_msgs/ModelState '{model_name: mobile_base, pose: { position: { x: 0, y: 0, z: 6 }, orientation: {x: 0, y: 0.0, z: 0, w: 1.0 } }, twist: { linear: { x: 0, y: 0, z: 0 }, angular: { x: 0, y: 0, z: 0}  }, reference_frame: world }'

Here is a command to start with a 20 degree roll angle

rostopic pub -1 /gazebo/set_model_state gazebo_msgs/ModelState '{model_name: mobile_base, pose: { position: { x: 0, y: 0, z: 0.45 }, orientation: {x: 0.17, y: 0.0, z: 0, w: 0.98 } }, twist: { linear: { x: 0, y: 0, z: 0 }, angular: { x: 0, y: 0, z: 0}  }, reference_frame: world }'

And 20 degree pitch angle

rostopic pub -1 /gazebo/set_model_state gazebo_msgs/ModelState '{model_name: mobile_base, pose: { position: { x: 0, y: 0, z: 0.25 }, orientation: {x: 0.0, y: 0.17, z: 0, w: 0.98 } }, twist: { linear: { x: 0, y: 0, z: 0 }, angular: { x: 0, y: 0, z: 0}  }, reference_frame: world }'

 

Troubleshooting

Failed to load plugin

Verified that the libusv_gazebo_plugin.so was created and is in catkin_ws/devel/lib  (where catkin puts our compiled library).

Reading the error above, it turned out there was an older version of libkingfisher_gazebo_plugins.so in the directory /usr/lib/x86_64-linux-gnu/gazebo-2.2/plugins.  Using ldd I determined that this older version was linked to shared libraries not on the machine.  I moved the older version to a different name...

sudo mv libkingfisher_gazebo_plugins.so oldlibkingfisher_gazebo_plugins.so

so that Gazebo would use the version in catkin_ws/devel/lib.  Then things worked!

 

 

  • No labels