Skip to content

File syn_flight_pid.c

FileList > control > syn_flight_pid.c

Go to the source code of this file

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

  • #include "syntropic/control/syn_flight_pid.h"
  • #include <string.h>

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.

Public Static Functions

Type Name
uint16_t clamp_us (int32_t val)
Clamp pulse width value to 1000..2000 us servo range.

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.


Public Static Functions Documentation

function clamp_us

Clamp pulse width value to 1000..2000 us servo range.

static uint16_t clamp_us (
    int32_t val
) 

Parameters:

  • val Input pulse width value.

Returns:

Clamped pulse width in us.



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