GKD.RoboCtrl
RoboMaster Linux 电控:异步 IO、设备驱动与机器人控制
载入中...
搜索中...
未找到
roboctrl::utils::pid_base< T, error_measurer > 模板结构体 参考

PID 控制器基础模板。 更多...

详细描述

template<typename T, auto error_measurer>
struct roboctrl::utils::pid_base< T, error_measurer >

PID 控制器基础模板。

模板参数
T计算类型
error_measurer误差测度函数

在文件 pid.h 第 22 行定义.

#include <pid.h>

roboctrl::utils::pid_base< T, error_measurer > 的协作图:

类

struct  params_type
 统一的参数封装,方便序列化。 更多...
 

Public 类型

using input_type = T
 
using state_type = T
 

Public 成员函数

 pid_base (const params_type &params)
 
void set_target (T target)
 设置期望目标。
 
T target () const
 
void update (T current, T dt)
 根据当前值和采样周期更新 PID 输出。
 
void update (T current)
 
void update (T target, T current, T dt)
 同时设置目标并根据当前值更新输出。
 
void clean ()
 清空积分项、误差缓存与输出。
 
T state () const
 获取最新的控制输出。
 

Public 属性

T kp = 0
 
T ki = 0
 
T kd = 0
 
T max_out {}
 
T max_iout {}
 

成员类型定义说明

◆ input_type

template<typename T , auto error_measurer>
using roboctrl::utils::pid_base< T, error_measurer >::input_type = T

在文件 pid.h 第 30 行定义.

◆ state_type

template<typename T , auto error_measurer>
using roboctrl::utils::pid_base< T, error_measurer >::state_type = T

在文件 pid.h 第 31 行定义.

构造及析构函数说明

◆ pid_base()

template<typename T , auto error_measurer>
roboctrl::utils::pid_base< T, error_measurer >::pid_base ( const params_type &  params)
inline

在文件 pid.h 第 47 行定义.

成员函数说明

◆ clean()

◆ set_target()

template<typename T , auto error_measurer>
void roboctrl::utils::pid_base< T, error_measurer >::set_target ( T  target)
inline

◆ state()

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::state ( ) const
inline

获取最新的控制输出。

在文件 pid.h 第 116 行定义.

被这些函数引用 roboctrl::device::gkd_sentry_gimbal::update().

◆ target()

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::target ( ) const
inline

在文件 pid.h 第 56 行定义.

◆ update() [1/3]

template<typename T , auto error_measurer>
void roboctrl::utils::pid_base< T, error_measurer >::update ( T  current)
inline

Legacy update preserving the historical per-call PID behavior.

在文件 pid.h 第 90 行定义.

引用了 roboctrl::utils::pid_base< T, error_measurer >::update().

被这些函数引用 roboctrl::utils::pid_base< T, error_measurer >::update().

◆ update() [2/3]

template<typename T , auto error_measurer>
void roboctrl::utils::pid_base< T, error_measurer >::update ( T  current,
T  dt 
)
inline

根据当前值和采样周期更新 PID 输出。

与传统 RM 风格 PID(error[0]/error[1] 差分)保持兼容:

  • 误差缓存顺序:先 old 再 new
  • 积分项:I += ki * error * dt
  • 微分项:D = kd * (error_curr - error_prev) / dt
  • 限幅顺序:先 Iout,再输出

在文件 pid.h 第 67 行定义.

被这些函数引用 roboctrl::device::gkd_sentry_gimbal::update() , 以及 roboctrl::utils::pid_base< T, error_measurer >::update().

◆ update() [3/3]

template<typename T , auto error_measurer>
void roboctrl::utils::pid_base< T, error_measurer >::update ( T  target,
T  current,
T  dt 
)
inline

同时设置目标并根据当前值更新输出。

参数
target本次控制的目标值
current当前反馈值
dt采样周期,单位为秒

在文件 pid.h 第 98 行定义.

引用了 roboctrl::utils::pid_base< T, error_measurer >::set_target() , 以及 roboctrl::utils::pid_base< T, error_measurer >::update().

类成员变量说明

◆ kd

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::kd = 0

在文件 pid.h 第 25 行定义.

◆ ki

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::ki = 0

在文件 pid.h 第 24 行定义.

◆ kp

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::kp = 0

在文件 pid.h 第 23 行定义.

◆ max_iout

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::max_iout {}

在文件 pid.h 第 28 行定义.

◆ max_out

template<typename T , auto error_measurer>
T roboctrl::utils::pid_base< T, error_measurer >::max_out {}

在文件 pid.h 第 27 行定义.


该结构体的文档由以下文件生成: