gazebo
wind
Gazebo wind effect plugin
Gazebo can simulate wind by defining a world wind velocity and loading the
WindEffects system plugin. The world-level <wind> element sets the base wind
vector in meters per second:
<wind>
<linear_velocity> 2 0 0</linear_velocity>
</wind>
This value describes the direction and speed of the air flow in the world frame.
For example, 2 0 0 pushes along +X, while 0 1 0 pushes along +Y.
The gz::sim::systems::WindEffects plugin converts that wind field into forces
on simulated links. The plugin can also shape the wind over time. In the simple
case, time_for_rise controls how quickly the wind reaches the requested
magnitude:
<plugin
filename= "gz-sim-wind-effects-system"
name= "gz::sim::systems::WindEffects" >
<force_approximation_scaling_factor> 1</force_approximation_scaling_factor>
<horizontal>
<magnitude>
<time_for_rise> 1.0</time_for_rise>
</magnitude>
</horizontal>
</plugin>
To simulate gusts, add a time-varying term such as <sin>. The
amplitude_percent changes how strong the oscillation is relative to the base
wind, and period controls how many seconds one cycle takes.
Wind response is applied at the link level. Enable wind on the model and on each
link that should be affected:
<model name= "box" >
<enable_wind> true</enable_wind>
<link name= "link" >
<enable_wind> true</enable_wind>
</link>
</model>
Whether the object visibly moves depends on the rest of its physics properties.
A lighter link accelerates more, lower ground friction lets it slide more easily,
and the collision geometry determines the approximate area exposed to the wind.
In the demos below, the box has low mass and low friction so the wind force is
easy to see.
Demo
Wind
<?xml version="1.0" ?>
<sdf version="1.6">
<world name="empty">
<physics name="1ms" type="ignored">
<max_step_size>0.001</max_step_size>
<real_time_factor>1.0</real_time_factor>
</physics>
<plugin
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>
<plugin
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>
<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>
<!-- base wind velocity: x y z, m/s -->
<wind>
<linear_velocity>2 0 0</linear_velocity>
</wind>
<plugin
filename="gz-sim-wind-effects-system"
name="gz::sim::systems::WindEffects">
<force_approximation_scaling_factor>1</force_approximation_scaling_factor>
<horizontal>
<magnitude>
<time_for_rise>1.0</time_for_rise>
</magnitude>
</horizontal>
</plugin>
<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<surface>
<friction>
<ode>
<mu>0.01</mu>
<mu2>0.01</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<ambient>0.8 0.8 0.8 1</ambient>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.8 0.8 0.8 1</specular>
</material>
</visual>
</link>
</model>
<model name="box">
<pose>0 0 1 0 0 0</pose>
<enable_wind>true</enable_wind>
<link name="link">
<!-- Important: wind acts on links, not the whole model. -->
<enable_wind>true</enable_wind>
<inertial>
<mass>0.02</mass>
<inertia>
<ixx>0.003333</ixx><iyy>0.003333</iyy><izz>0.003333</izz>
</inertia>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0.01</mu>
<mu2>0.01</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</visual>
</link>
</model>
</world>
</sdf>
Demo: Simulate wind gust
Wind Gust
<?xml version="1.0" ?>
<sdf version="1.6">
<world name="empty">
<physics name="1ms" type="ignored">
<max_step_size>0.001</max_step_size>
<real_time_factor>1.0</real_time_factor>
</physics>
<plugin
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>
<plugin
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>
<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>
<!-- base wind velocity: x y z, m/s -->
<wind>
<linear_velocity>0 1 0</linear_velocity>
</wind>
<plugin
filename="gz-sim-wind-effects-system"
name="gz::sim::systems::WindEffects">
<force_approximation_scaling_factor>1</force_approximation_scaling_factor>
<horizontal>
<magnitude>
<time_for_rise>0.2</time_for_rise>
<sin>
<amplitude_percent>1.0</amplitude_percent>
<period>3</period>
</sin>
</magnitude>
</horizontal>
</plugin>
<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<surface>
<friction>
<ode>
<mu>0.01</mu>
<mu2>0.01</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<ambient>0.8 0.8 0.8 1</ambient>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.8 0.8 0.8 1</specular>
</material>
</visual>
</link>
</model>
<model name="box">
<pose>0 -10 1 0 0 0</pose>
<enable_wind>true</enable_wind>
<link name="link">
<!-- Important: wind acts on links, not the whole model. -->
<enable_wind>true</enable_wind>
<inertial>
<mass>0.02</mass>
<inertia>
<ixx>0.003333</ixx><iyy>0.003333</iyy><izz>0.003333</izz>
</inertia>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0.01</mu>
<mu2>0.01</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</visual>
</link>
</model>
</world>
</sdf>