The one-line mental model
Weather adaptation means estimating the disturbance you are flying through, compensating for it in the control loop, degrading sensing gracefully when rain or fog hits, and refusing to launch when conditions exceed a documented envelope.
You will learn to:
- Infer wind speed and direction from motor currents and IMU residuals
- Distinguish steady wind from turbulence and respond differently to each
- Detect sensor degradation caused by precipitation and optics fouling
- Encode operational weather limits as machine-checkable launch gates
Prerequisites
- !Quadrotor dynamics basics
- !PID or cascaded control
- !Sensor fusion intuition
What You'll Learn
- 1Quantify how wind scales with altitude and terrain
- 2Build a simple disturbance observer from motor commands
- 3Design a weather-aware mission abort policy
How weather actually attacks a drone
Steady wind is the easy case. A constant 6 m/s breeze tilts the aircraft into a trim angle that offsets the horizontal drag force; a well-tuned controller holds position with modest extra motor effort. Gusts are harder because their rise time overlaps the controller's own bandwidth â you end up chasing a moving target. Turbulence is hardest of all: near buildings, ridgelines, and forest edges, wind becomes a broadband disturbance whose energy sits exactly where your inner loop is trying to work, and no amount of integral gain removes it. The same aerodynamic coupling that makes a quadrotor agile makes it a good turbulence sensor and a poor turbulence rejecter.
Precipitation and fog attack differently â they degrade perception instead of dynamics. Water on the lens blurs images and confuses optical-flow velocity estimates. Rain streaks create false motion in frame differencing. Fog reduces feature contrast until VIO loses tracking entirely. Wet motors and ESCs change thermal margins, so sustained rain flight shortens endurance beyond what the extra drag alone would predict.
| Condition | Primary effect | Typical control response | Typical sensing response |
|---|---|---|---|
| Steady wind | Constant force offset | Trim tilt, raise position gain slightly | None required |
| Gusts | Transient force | Feed-forward from wind estimate | Flag unreliable flow |
| Turbulence | Broadband disturbance | Lower gains, widen position tolerance | Increase filter smoothing |
| Rain | Drag, lens fouling | Reduce speed, raise battery margin | Confidence gating on cameras |
| Fog | Visibility loss | Slow down, widen spacing | Fall back to ranging sensors |
| Crosswind landing | Ground-effect interaction | Flare early, align heading to wind | Monitor drift rate closely |
Estimating wind while you fly
You rarely have a dedicated anemometer on a small drone, but you have something almost as good: a full motor command set, an IMU, and a dynamics model. In steady hover, the vertical force balance ties collective thrust to weight; any horizontal acceleration the IMU sees that the attitude command cannot explain is wind. A first-order disturbance observer captures this with a few lines of state.
from dataclasses import dataclass
import numpy as np
@dataclass
class WindEstimate:
speed: float # m/s
direction_rad: float
gustiness: float # variance proxy
confidence: float
class DisturbanceObserver:
"""First-order wind observer from commanded tilt and measured accel."""
def __init__(self, alpha=0.15, g=9.81):
self.alpha = alpha
self.g = g
self.wind = np.zeros(2) # north, east body-projected
self.gust_var = 0.0
def update(self, measured_accel_xy, commanded_tilt_rad):
"""measured_accel_xy: IMU x,y acceleration (m/s^2); tilt: [roll, pitch]."""
tilt = np.asarray(commanded_tilt_rad, dtype=float)
# Acceleration the controller intends to produce
commanded_accel = self.g * np.tan(tilt)
residual = np.asarray(measured_accel_xy, dtype=float) - commanded_accel
# Residual is largely drag from ambient wind
self.wind = (1 - self.alpha) * self.wind + self.alpha * residual * 0.35
self.gust_var = (1 - self.alpha) * self.gust_var \
+ self.alpha * float(np.var(residual))
speed = float(np.linalg.norm(self.wind))
direction = float(np.arctan2(self.wind[1], self.wind[0]))
conf = float(np.clip(1.0 - self.gust_var / 25.0, 0.2, 0.95))
return WindEstimate(speed, direction, self.gust_var, conf)
obs = DisturbanceObserver()
rng = np.random.default_rng(4)
wind_true = np.array([2.0, -1.0]) # m/s in x, y
for step in range(60):
gust = rng.normal(0, 0.4, 2)
drag_accel = 0.35 * (wind_true + gust)
measured = drag_accel + rng.normal(0, 0.05, 2)
tilt_cmd = [0.02, 0.01]
est = obs.update(measured, tilt_cmd)
print(f"estimated wind speed {est.speed:.2f} m/s "
f"direction {np.degrees(est.direction_rad):.0f} deg "
f"confidence {est.confidence:.2f}")
The alpha parameter trades responsiveness against noise. Too high, and the observer chases turbulence as if it were a steady change; too low, and the estimate lags through a gust front when you most need it. Values between 0.1 and 0.2 at a 50 to 100 Hz update rate work for most small quadcoptors.
Compensating: feed-forward, gains, and tolerance
Once wind is estimated, three responses layer on top of each other. Feed-forward adds the estimated disturbance force to the attitude command so the controller does not have to integrate the error out slowly. Gain scheduling trims position-loop gains down as gustiness rises, trading tightness for stability â fighting turbulence head-on wastes battery and excites structural modes. Finally, widen the operational position tolerance in high gusts so the planner does not treat every wind-induced excursion as a tracking failure and command aggressive, costly corrections.
import numpy as np
class WeatherAdaptiveController:
"""Position controller with wind feed-forward and gust scheduling."""
def __init__(self, kp_base=1.2, ki=0.15, kd=0.6):
self.kp_base = kp_base
self.ki = ki
self.kd = kd
self.integral = np.zeros(2)
def gains_for(self, gustiness):
"""Shrink proportional gain as gust energy rises."""
scale = float(np.clip(1.0 - 0.08 * gustiness, 0.45, 1.0))
return self.kp_base * scale, self.kd * (1.0 + 0.05 * gustiness)
def step(self, pos, vel, target, wind: WindEstimate):
err = np.asarray(target, dtype=float) - np.asarray(pos, dtype=float)
self.integral = np.clip(self.integral + err * 0.02, -1.5, 1.5)
kp, kd = self.gains_for(wind.gustiness)
# Feed-forward: push directly against estimated wind drag
ff = np.array([np.cos(wind.direction_rad),
np.sin(wind.direction_rad)]) * wind.speed * 0.35
cmd = kp * err + self.ki * self.integral - kd * np.asarray(vel) + ff
tol = 0.15 + 0.08 * wind.gustiness
return cmd, tol
ctl = WeatherAdaptiveController()
calm = WindEstimate(1.0, 0.3, 0.5, 0.9)
gusty = WindEstimate(7.5, 2.1, 14.0, 0.6)
for label, w in [("calm", calm), ("gusty", gusty)]:
cmd, tol = ctl.step([10.0, 5.0], [0.1, 0.0], [12.0, 6.0], w)
kp, _ = ctl.gains_for(w.gustiness)
print(f"{label:6s}: kp {kp:.2f} feed-forward {np.round(np.linalg.norm(cmd), 2)}"
f" position tolerance {tol:.2f} m")
The position tolerance output is the part teams forget. Feed it into the planner's cost function so the aircraft does not thrash trying to hold a 10-centimeter line in a 9 m/s gust. Battery consumption drops sharply when the mission accepts physically unavoidable error instead of fighting it.
Precipitation and optics: detect, then degrade
You cannot waterproof your way out of lens fouling on a moving airframe. What you can do is detect degradation early and switch behavior. Optical flow is the canary: when flow residual against IMU-predicted motion spikes while frame contrast collapses, the lens is wet or the scene is fogged. The response is to stop trusting vision for velocity, widen position uncertainty, and either continue on inertial-plus-GPS with conservative speeds or abort.
from dataclasses import dataclass
import numpy as np
@dataclass
class SensorHealth:
vision_trusted: bool
reason: str
severity: str # 'ok' | 'degraded' | 'failed'
class OpticsHealthMonitor:
"""Detect rain/fog degradation from flow residual and contrast."""
def __init__(self, residual_gate=1.8, contrast_gate=0.06):
self.residual_gate = residual_gate
self.contrast_gate = contrast_gate
def evaluate(self, flow_xy, inertial_xy, frame_std):
residual = float(np.linalg.norm(
np.asarray(flow_xy) - np.asarray(inertial_xy)))
contrast = float(frame_std) / 255.0
if residual > self.residual_gate and contrast < self.contrast_gate:
return SensorHealth(False, "lens fouled or fog â flow unreliable", "failed")
if residual > self.residual_gate or contrast < self.contrast_gate:
return SensorHealth(False, "vision degraded â widen uncertainty", "degraded")
return SensorHealth(True, "optics nominal", "ok")
mon = OpticsHealthMonitor()
cases = [
("clear hover", [0.05, 0.02], [0.04, 0.03], 42.0),
("light drizzle", [0.9, 0.7], [0.1, 0.05], 28.0),
("lens soaked", [3.5, 2.8], [0.2, 0.1], 12.0),
]
for name, flow, inertial, std in cases:
health = mon.evaluate(flow, inertial, std)
print(f"{name:14s}: {health.severity:8s} â {health.reason}")
Feed the severity level straight into the flight state machine: degraded keeps the mission alive at reduced speed with inertial-dominant fusion; failed triggers a controlled climb, a straight-line return if GPS is healthy, or a vertical landing if it is not. The decision logic belongs in code with logged reasons, not in a pilot's improvised judgment mid-flight.
Launch gates and mission planning
The last piece is pre-flight. Every airframe publishes a wind tolerance â commonly 8 to 12 m/s for small commercial quadcoptors, less forpayload-heavy or high-drag configurations â and a precipitation limit tied to IP rating and motor sealing. Turn those into explicit gates that block arming, and refresh them in flight from the observer so a mission that started legal can be recalled when conditions exceed the envelope at altitude, where wind is routinely stronger than at ground level.
| Gate | Example threshold | Action when exceeded |
|---|---|---|
| Surface wind | Above 8 m/s | Block launch |
| Estimated wind at altitude | Above 10 m/s | Abort and RTL |
| Gust variance | Above threshold for 10 s | Loosen tolerance, reduce speed |
| Optics health | Failed | Abort or inertial-only return |
| Battery in wind | Below reserve + wind margin | Force landing |
Wind shear between 30 and 80 meters is the classic surprise: calm at takeoff, strong at survey altitude. The observer from earlier in the lesson is exactly the instrument that catches it â sample it during the climb-out and make the continue-or-abort decision before reaching working altitude, when the aircraft still has the most energy and the most maneuvering room.
Common Mistakes
Tuning position gains once in calm weather and leaving them year-round
Fix: Schedule gains from the live gust estimate; fighting turbulence with calm-weather gains wastes battery and excites structural modes.
Ignoring wind gradient with altitude
Fix: Run the observer during climb-out and gate the continue decision on wind at working altitude, not at launch.
Trusting optical flow after rain starts
Fix: Monitor flow-versus-inertial residual and frame contrast; gate vision trust explicitly.
No documented wind or precipitation limit for the airframe
Fix: Publish a per-model envelope and encode it as arming and abort gates in software.
Best Practices
- Log wind estimates, gust variance, and sensor-health verdicts on every mission for trend analysis
- Include a wind margin in battery reserve calculations â headwind returns cost far more than the range map suggests
- Rehearse the abort state machine in simulation with injected wind steps before first flight
- Align the aircraft heading into the wind for landing to minimize ground-effect lateral drift
Key Takeaways
- Steady wind is a trim problem, gusts are a bandwidth problem, turbulence is a tolerance problem
- A first-order disturbance observer recovers wind from IMU residuals without extra sensors
- Feed-forward plus scheduled gains plus widened position tolerance is the layered response that actually saves battery
- Precipitation and fog are handled by detecting perception degradation and gating trust, not by hoping
- Weather gates belong in software with logged reasons, refreshed continuously from in-flight estimates