This package contains plugins and models for the simulation of surface vessels in Gazebo.
- A working installation of Gazebo Garden or later including development symbols.
- Ubuntu 22.04 (Jammy)
- Gazebo Sim, version 7.1.0 (Garden)
- macOS 12.6.2 (Monterey)
- Gazebo Sim, version 7.1.0 (Garden)
mkdir -p gz_ws/src
Clone the asv_sim
repository:
cd ~/gz_ws/src
git clone https://github.com/srmainwaring/asv_sim.git
Compile the package:
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
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
# 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
The package includes a custom Anemometer sensor to measure wind speed and direction.
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>
~/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).
-
<always_on>
(bool
, default:false
)
Standard<sensor>
parameter. See SDF documentation for details. -
<update_rate>
(double
, default:0
)
Standard<sensor>
parameter. See SDF documentation for details. -
<topic>
(string
, default:~/anemometer
)
Standard<sensor>
parameter. See SDF documentation for details.
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:
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
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.