The intent of the following instructions is to present a working example of a simulated Kingfisher/Heron USV in the Gazebo environment, which includes
- A physical and visual description of the USV - supplied by the ros-indigo-kingfisher-description package. The physical description includes the rigid body dynamics.
- A Gazebo plugin to define the added hydrodynamic forces and thruster dynamics of the USV
- Gazebo plugins to simulate sensor measurements
Here we assume that you are using the NPS ROS development environment: Ubuntu 16.04 and ROS Kinetic (documentation forthcoming)
Build the following ROS packages form source:
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
The following source packages are also required
- The usv_gazebo_plugins package: http://wiki.ros.org/usv_gazebo_plugins This is the C++ plugin where the hydrodynamic and thruster model parameters are defined.
- The kingfisher_gazebo package: https://github.com/bsb808/kingfisher_gazebo/tree/indigo-devel This includes xacro files to assemble the model, with appropriate plugins, and launch files
- The geonav_transform package: http://wiki.ros.org/geonav_transform This is utility for local<->global coordinate transformations.
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...
- Start Gazebo
- Load the URDF description of the Kingfisher in the parameter server. This includes our Gazebo plugin to define the dynamics
- Start the robot_state_publisher node
- Spawn the Kingfisher within Gazebo
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...
Send UsvDrive messages using `rostopic`
- Manual driving with keyboard or joystick: Driving Kingfisher with Keyboard or Joystick
- Low-level feedback control using PID: Kingfisher Twist Control
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...
Here is a command to start with a 20 degree roll angle
And 20 degree pitch angle
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...
so that Gazebo would use the version in catkin_ws/devel/lib. Then things worked!