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

Below is an example developed by Dr. Sean Kragelund for his Introduction to Unmanned Systems course.  The example illustrates using Simulink to interface with ROS to implement feedback control of an unmanned surface vessel (USV).

To run the example, which is based on a Gazebo simulation, you will need the kingfisher_gazebo ROS package.  Instructions for installing the simulation are at Gazebo Simulation of Kingfisher/Heron USV


A good place to start would be our heading controller lab. This is the only one that I've verified on the actual Kingfisher robot. This uses PD control to drive the USV heading to a commanded heading, provided relative to NED coordinates. Please see the attached Simulink model. It subscribes to the /imu/data and /geonav_odom ROS topics, and publishes to the /cmd_drive topic to send thrust commands to the USV.

This version includes a PID controller for body-referenced forward velocity. It also exposes slider gains to tune the P and D gains used for heading control. And just for fun, it has a knob for setting the commanded heading and a slider gain for setting the commanded velocity. Users can run an infinite simulation and drive the boat around in Gazebo using these two interfaces.

To run the attached model:

  1. at Linux command prompt, type roslaunch kingfisher_gazebo elestero.launch and wait for Gazebo to start up and display the Kingfisher in the El Estero world
  2. in MATLAB, type rosinit
  3. in Simulink, run the simulation

This requires your kingfisher_gazebo and geonav_transform packages.
It also relies on a MATLAB Add-On, the Real-Time Pacer, to make Simulink clock time mimic actual time. You can get this block by clicking Add-Ons->Get Add-Ons on the MATLAB toolbar. Search "for real-time pacer," click on it, then click Add. This will request your Mathworks userid and account, then install this block so you can use it in your models.
Also note that if Simulink throws an error, it's usually due to an issue with one or more of the ROS Subscribe blocks in the model. This problem is indicated if you see ??? in the Selected Signal list after double-clicking a Bus Selector block coming out of a Subscribe block. If this is the case, double-click the Subscribe block and click Select... to re-select the ROS topic, then click OK. Finally, verify that there are no longer any ??? in the Selected Signal list of the Bus Selector block. After that, you should be good-to-go.

Simulink Model

  • No labels