Vayu

Control System

The control system in Vayu generates actuator commands required to stabilize and control the drone based on estimated state and user inputs. It is implemented as a cascaded architecture consisting of an outer attitude loop and an inner rate loop, operating at different frequencies to balance stability and responsiveness.

Control Architecture

The system follows a hierarchical structure where the attitude controller computes desired angular rates, which are then tracked by the rate controller. This separation enables robust stabilization while allowing intuitive control through orientation commands.

Cascaded control structure in Vayu.

The attitude controller converts user commands into target angles and computes desired angular rates using PID control. The rate controller then tracks these target rates using gyroscope feedback and produces control outputs for each axis.

PID Controller Formulation

The controller output is computed as: u=Kpe+Kiedt+Kdddt(y)+Kffṙu = K_p e + K_i \int e\,dt + K_d \frac{d}{dt}(-y) + K_{ff} \dot{r}

where e=rye = r - y is the error between setpoint and measurement.

Implementation Details

The implementation incorporates several practical enhancements:

Derivative on Measurement: D=Kdy(t)y(tdt)dtD = -K_d \frac{y(t) - y(t - dt)}{dt} This avoids derivative kick during rapid setpoint changes.

Low-Pass Filtering: Df=Df+α(DDf),α=dtdt+RCD_f = D_f + \alpha (D - D_f), \quad \alpha = \frac{dt}{dt + RC}

Integral Anti-Windup: I=clamp(I+Kiedt,Imax,Imax)I = \text{clamp}(I + K_i e dt, -I_{\max}, I_{\max})

Integration is limited when actuator saturation occurs to prevent windup.

Feedforward Term: A feedforward component based on setpoint rate improves responsiveness.

Multi-Rate Execution: The rate loop operates at approximately 1 kHz for fast stabilization, while the attitude loop runs at approximately 250 Hz for smoother control.

Data Flow Between Controllers

The attitude controller produces desired angular rates which are passed to the rate controller through a lock-free buffer mechanism, ensuring non-blocking communication between task. The rate controller then computes final control outputs using real-time gyroscope measurements.