Softivation

SITL wind doesn't push the drone

You set SIM_WIND_SPD in the SITL wind simulation, and the drone doesn't budge. The wind is blowing, but the speed reaching the airframe at 10 meters is only 4.08 m/s.

Furkan IŞIKAY 7 min read

You set the wind speed to 10 in the simulation. The vehicle on the map stays at the same point, the speed gauges read zero, and nothing on screen moves. At this point it's perfectly reasonable to think the wind isn't being applied at all.

But the wind is being applied. Two separate causes hide the effect from view, and both are at work at the same time.

The drone counters the wind, so it stays in place

In GUIDED, LOITER and AUTO modes, the position controller is active. The moment the wind pushes the vehicle, the position error starts to grow. The controller turns this error into an acceleration request, and the acceleration request goes to the motors as a tilt angle.

That's why the wind leaves its trace in the tilt angle, not in the position. That's also where you need to look: how far the vehicle tilts.

The speed reaching the airframe depends on altitude

SITL scales the wind by altitude. The default profile is a square root: the wind grows from the ground up to a certain altitude and only reaches full strength there. The blue curve in the figure is this profile, and the red dots are the speed that actually reaches the airframe while you hold the drone low.

Wind actually blowing at each altitude with SIM_WIND_SPD = 10

In the default square root profile, the wind grows up to 60 meters: 4.08 m/s at 10 meters, 1.8 m/s at 2 meters. With SIM_WIND_T at 1, it's 10 m/s at every altitude.
Where to look: the red dots. If you hold the drone at 10 meters, less than half the speed you set reaches the airframe. The blue curve only touches 10 at the dashed vertical line. Source: libraries/AP_HAL/SIMState.cpp.

SIM_WIND_T_ALT sets that altitude, and its default is 60 meters. At ten meters the multiplier is the square root of 10/60, that is, 0.41. With SIM_WIND_SPD at 10, the wind reaching the airframe is 4.08 m/s.

Output
SIM_WIND_T 0 square root profile, 1 unlimited, 2 linear
SIM_WIND_T_ALT 60 altitude at which full power is reached, meters
SIM_WIND_SPD 10 speed at full power, m/s

If you want to turn the profile off, set SIM_WIND_T to 1. Then the speed you set blows regardless of altitude.

Example: Before the competition, to test your mission code in the wind, you set SIM_WIND_SPD to 10 and held the drone in LOITER at 2 meters. The map doesn't move, because only 1.8 m/s reaches the airframe and the controller counters it with a slight tilt. If you repeat the same test at 60 meters or set SIM_WIND_T to 1, the full 10 m/s you set blows, and you see the difference in the tilt angle.

Read the tilt angle yourself

To see the wind's effect, look at the roll and pitch fields in the ATTITUDE message. The code below connects, first sets the wind to zero, raises it to 10 four seconds later, and then prints the tilt angle once per second.

Python
# ruzgar_etkisi.py - reads the wind blowing in SITL from the tilt angle
import math, time
from pymavlink import mavutil

m = mavutil.mavlink_connection('tcp:127.0.0.1:5760')
m.wait_heartbeat()
m.mav.request_data_stream_send(m.target_system, m.target_component,
                               mavutil.mavlink.MAV_DATA_STREAM_ALL, 10, 1)

def param_yaz(ad, deger):
    for _ in range(10):
        m.mav.param_set_send(m.target_system, m.target_component, ad.encode(),
                             float(deger), mavutil.mavlink.MAV_PARAM_TYPE_REAL32)
        pv = m.recv_match(type='PARAM_VALUE', blocking=True, timeout=3)
        if pv and pv.param_id.strip('\x00') == ad:
            return pv.param_value
    raise RuntimeError(ad + ' could not be written')

def son_durum():
    # drain the buffer and take the freshest message; otherwise you read stale data
    att = pos = None
    while True:
        msg = m.recv_match(type=['ATTITUDE', 'GLOBAL_POSITION_INT'], blocking=False)
        if msg is None:
            break
        if msg.get_type() == 'ATTITUDE':
            att = msg
        else:
            pos = msg
    return att, pos

param_yaz('SIM_WIND_SPD', 0)
param_yaz('SIM_WIND_DIR', 180)
time.sleep(4)
param_yaz('SIM_WIND_SPD', 10)

for _ in range(12):
    time.sleep(1)
    att, pos = son_durum()
    if att is None or pos is None:
        continue
    yatis = math.degrees(math.acos(math.cos(att.roll) * math.cos(att.pitch)))
    print('altitude %5.1f m tilt %5.2f degrees' % (pos.relative_alt / 1000.0, yatis))

The code drains the buffer on every pass. If you don't drain it, you read delayed telemetry and think the wind is building up slowly. If you run it while the drone holds at 10 meters, you'll see this:

Output
altitude 10.0 m tilt 8.84 degrees
altitude 10.0 m tilt 8.96 degrees
altitude 10.0 m tilt 8.89 degrees
altitude 10.0 m tilt 8.90 degrees
altitude 10.0 m tilt 8.90 degrees
altitude 10.0 m tilt 8.94 degrees
altitude 10.0 m tilt 8.93 degrees
altitude 10.0 m tilt 8.92 degrees

At ten meters the value settles at around 8.9 degrees. The position doesn't move, because the controller absorbs the wind by tilting.

At the same altitude, if you set SIM_WIND_T to 1, the tilt rises from 9.03 degrees to 29.26 degrees. The entire difference comes from the altitude scaling.

Check these in order on your own setup

  • Which physics model you're using. The built-in multicopter model calls update_wind; the Gazebo and JSON source files don't have this call.
  • Wait a few seconds after writing the parameter. The simulation keeps the wind at zero for the first five seconds.
  • Compare your altitude with SIM_WIND_T_ALT. If you're below it, you won't see the speed you set anyway.
  • Look at the tilt angle. In position-holding modes, the position won't move anyway.

The most common mistake is testing the wind at two meters of altitude. There the multiplier is only 0.18, and SIM_WIND_SPD 10 reaches the airframe as 1.8 m/s.

Error Messages and Their Meanings

Unable to find parameter 'SIM_WIND_SPD'

MAVProxy couldn't find the parameter in its own list. Either you're connected to a real flight controller, or the parameter list hasn't finished downloading. Repeat the command once the download is done.

Unknown parameter SIM_WIND_SPD

The mavparm module in pymavlink prints this for lines it doesn't recognize when loading parameters from a file. When lines starting with SIM_ are sent to a vehicle that isn't simulated, every one of them gives this warning.

timeout setting SIM_WIND_SPD to 10.000000

The value was sent, but no acknowledgment came back. The usual cause is a second client. SITL accepts a single TCP connection, and a client that connects later silently gets nothing.

Use wind to build scenarios

The lesson flow that builds wind, swarm and scenario simulation from scratch is in the AI and Drone Simulation course. Its sections go from setting up Gazebo and ROS all the way to detection from the camera.

AI and Drone Simulation Virtual Machine: comes with ArduPilot SITL, ROS Noetic, and Gazebo 11 installed. You start simulating without any setup hassle.

Was this article helpful?

Free resourceArduPilot SITL setup guideSet up the simulation on your own computer: Ubuntu, Windows WSL, or a virtual machine, start to finish.