HRI board firmware  v2.1
Microcontroller firmware of the board used during the HRI labs.
Data Structures | Functions
Lib / PID regulator

Proportionnal-integral-derivative regulator with integrator saturation capability. More...

Data Structures

struct  pid_Pid
 PID regulator structure. More...
 

Functions

void pid_Init (pid_Pid *pid, float32_t kp, float32_t ki, float32_t kd, float32_t arw, float32_t feedforward)
 Initialize the PID structure. More...
 
float32_t pid_Step (pid_Pid *pid, float32_t current, float32_t target, float32_t dt)
 Step the PID structure. More...
 

Detailed Description

Proportionnal-integral-derivative regulator with integrator saturation capability.

First, instantiate a pid_Pid structure (e.g. "pid_Pid pid;"), then initialize it once with pid_Init(). Then, every time a new command needs to be computed (typically when a new measurement arrives), call pid_Step().

Function Documentation

◆ pid_Init()

void pid_Init ( pid_Pid pid,
float32_t  kp,
float32_t  ki,
float32_t  kd,
float32_t  arw,
float32_t  feedforward 
)

Initialize the PID structure.

Parameters
pidpointer to the PID structure.
kpproportionnal coefficient of the PID. No effect if zero.
kiintegral coefficient of the PID. No effect if zero.
kdderivative coefficient of the PID. No effect if zero.
arwmaximum value of the integrator (anti-reset windup). Disabled if negative.
feedforwardcomponent proportional to the target (not the error). No effect if zero.

◆ pid_Step()

float32_t pid_Step ( pid_Pid pid,
float32_t  current,
float32_t  target,
float32_t  dt 
)

Step the PID structure.

Parameters
pidpointer to the PID structure.
currentcurrent state of the system to control.
targettarget state of the system to control.
dttimestep (time since the last call of this function) [s].
Return values
commandto apply to the system.