Skip to content

This package contains plugins and models for the simulation of surface vessels in Gazebo.

License

Notifications You must be signed in to change notification settings

srmainwaring/asv_sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASV Simulator

Ubuntu Jammy CI Cpplint Cppcheck

This package contains plugins and models for the simulation of surface vessels in Gazebo.

rs750_ardupilot_v3_upwind

Dependencies

  • A working installation of Gazebo Garden or later including development symbols.

Ubuntu

  • Ubuntu 22.04 (Jammy)
  • Gazebo Sim, version 7.1.0 (Garden)

macOS

  • macOS 12.6.2 (Monterey)
  • Gazebo Sim, version 7.1.0 (Garden)

Installation

Create a workspace

mkdir -p gz_ws/src

Clone and build the package

Clone the asv_sim repository:

cd ~/gz_ws/src
git clone https://github.com/srmainwaring/asv_sim.git

Compile the package:

Ubuntu

colcon build --symlink-install --merge-install --cmake-args \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_STANDARD=17

Source the workspace:

source ./install/setup.bash

macOS

colcon build --symlink-install --merge-install --cmake-args \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_MACOSX_RPATH=FALSE \
-DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib

Source the workspace:

source ./install/setup.zsh

Usage

Set environment variables

# for future use - to support multiple Gazebo versions
export GZ_VERSION=garden

# not usually required as should default to localhost address
export GZ_IP=127.0.0.1

# ensure the model and world files are found
export GZ_SIM_RESOURCE_PATH=$GZ_SIM_RESOURCE_PATH:\
$HOME/gz_ws/src/asv_sim/asv_sim_gazebo/worlds

# ensure the system plugins are found
export GZ_SIM_SYSTEM_PLUGIN_PATH=$GZ_SIM_SYSTEM_PLUGIN_PATH:\
$HOME/gz_ws/src/asv_sim/install/lib

Anemometer Sensor

The package includes a custom Anemometer sensor to measure wind speed and direction.

Usage

Add the SDF for the sensor to a <link> element of your model.

<sensor name="anemometer" type="custom" gz:type="anemometer">
  <always_on>1</always_on>
  <update_rate>30</update_rate>
  <topic>anemometer</topic>
  <gz:anemometer>
    <noise type="gaussian">
      <mean>0.2</mean>
      <stddev>0.1</stddev>
    </noise>
  </gz:anemometer>
</sensor>

Published Topics

  1. ~/anemometer (gz::msgs::Vector3d)
  • header.stamp (gz::msgs::Time)
    The simulation time of the observation.

  • x, y, z (double)
    The apparent wind velocity components at the sensor origin in the world frame (i.e. true wind adjusted for the link velocity).

Parameters

  1. <always_on> (bool, default: false)
    Standard <sensor> parameter. See SDF documentation for details.

  2. <update_rate> (double, default: 0)
    Standard <sensor> parameter. See SDF documentation for details.

  3. <topic> (string, default: ~/anemometer)
    Standard <sensor> parameter. See SDF documentation for details.

Anemometer Example

To run the example:

gz sim -v4 -s -r anemometer.sdf

The system plugin is registered with the simulation in the world file using:

<plugin filename="asv_sim2-anemometer-system"
  name="gz::sim::systems::Anemometer">
</plugin>

You should see a world containing a single block at the origin. The figure below shows the block falling to demonstate the effect of motion on apparent wind:

anemometer-falling

When the block is at rest with axis aligned with the world frame, the true and apparent wind should be the same.

% gz topic -e -t /anemometer -n 1
header {
  stamp {
    sec: 61
    nsec: 369000000
  }
  data {
    key: "frame_id"
    value: "anemometer::base_link::anemometer"
  }
  data {
    key: "seq"
    value: "61368"
  }
}
x: -5
y: 1.4381672343972489e-17
z: -0.00099989893750004975

When the block is in motion, for instance by setting the z pose to 100 and letting it fall, the apparent wind will be adjusted for the object's motion.

gz topic -e -t /anemometer -n 1
header {
  stamp {
    sec: 58
    nsec: 596000000
  }
  data {
    key: "frame_id"
    value: "anemometer::base_link::anemometer"
  }
  data {
    key: "seq"
    value: "58595"
  }
}
x: -5
y: 1.959765959893313e-16
z: 25.675000101061269

License

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

About

This package contains plugins and models for the simulation of surface vessels in Gazebo.

Resources

License

Stars

Watchers

Forks

Packages

No packages published