Skip to content

File syn_flight_pid.h

FileList > control > syn_flight_pid.h

Go to the source code of this file

Zero-Heap 3-Axis Quadcopter Flight PID Stabilization & Motor Mixer. More...

  • #include "syntropic/common/syn_defs.h"
  • #include "syntropic/control/syn_pid.h"
  • #include "syntropic/util/syn_qmath.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Flight_Commands
struct SYN_Flight_Controller
struct SYN_Flight_IMU
struct SYN_Flight_MotorOutputs

Public Functions

Type Name
SYN_Status syn_flight_init (SYN_Flight_Controller * fc)
Initialize 3-axis flight PID controller instance.
SYN_Status syn_flight_update (SYN_Flight_Controller * fc, const SYN_Flight_IMU * imu, const SYN_Flight_Commands * cmd, uint32_t dt_ms, SYN_Flight_MotorOutputs * motors)
Step 3-axis flight controller and compute Quad-X motor outputs.

Detailed Description

Architecture: * Cascaded Dual-Loop Control: * Outer Angle Loop: Desired angle (deg) -> Gyro Rate Setpoint (deg/s). * Inner Rate Loop: Gyro Rate Error -> Motor Axis Torque Output (Roll, Pitch, Yaw).

  • Quadcopter X-Configuration Motor Mixer:
  • Motor 1 (Front-Right, CCW): Throttle - Roll + Pitch + Yaw
  • Motor 2 (Rear-Right, CW): Throttle - Roll - Pitch - Yaw
  • Motor 3 (Rear-Left, CCW): Throttle + Roll - Pitch + Yaw
  • Motor 4 (Front-Left, CW): Throttle + Roll + Pitch - Yaw

All operations use Q16.16 fixed-point arithmetic. Zero float, zero heap.

Public Functions Documentation

function syn_flight_init

Initialize 3-axis flight PID controller instance.

SYN_Status syn_flight_init (
    SYN_Flight_Controller * fc
) 

Parameters:

  • fc Pointer to flight controller struct.

Returns:

SYN_OK on success.


function syn_flight_update

Step 3-axis flight controller and compute Quad-X motor outputs.

SYN_Status syn_flight_update (
    SYN_Flight_Controller * fc,
    const SYN_Flight_IMU * imu,
    const SYN_Flight_Commands * cmd,
    uint32_t dt_ms,
    SYN_Flight_MotorOutputs * motors
) 

Parameters:

  • fc Pointer to flight controller struct.
  • imu Pointer to IMU measurements.
  • cmd Pointer to pilot command inputs.
  • dt_ms Time step in milliseconds (e.g. 1ms = 1kHz loop).
  • motors Pointer to output motor commands struct.

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/control/syn_flight_pid.h