Apollo 11.0
自动驾驶开放平台
apollo::control::PIDController类 参考

A proportional-integral-derivative controller for speed and steering using defualt integral hold 更多...

#include <pid_controller.h>

类 apollo::control::PIDController 继承关系图:
apollo::control::PIDController 的协作图:

Public 成员函数

void Init (const PidConf &pid_conf)
 initialize pid controller
 
void SetPID (const PidConf &pid_conf)
 set pid controller coefficients for the proportional, integral, and derivative
 
void Reset ()
 reset variables for pid controller
 
void Reset_integral ()
 reset integral for pid controller
 
virtual double Control (const double error, const double dt)
 compute control value based on the error
 
virtual ~PIDController ()=default
 
int IntegratorSaturationStatus () const
 get saturation status
 
bool IntegratorHold () const
 get status that if integrator is hold
 
void SetIntegratorHold (bool hold)
 set whether to hold integrator component at its current value.
 

Protected 属性

double kp_ = 0.0
 
double ki_ = 0.0
 
double kd_ = 0.0
 
double kaw_ = 0.0
 
double previous_error_ = 0.0
 
double previous_output_ = 0.0
 
double integral_ = 0.0
 
double integrator_saturation_high_ = 0.0
 
double integrator_saturation_low_ = 0.0
 
bool first_hit_ = false
 
bool integrator_enabled_ = false
 
bool integrator_hold_ = false
 
int integrator_saturation_status_ = 0
 
double output_saturation_high_ = 0.0
 
double output_saturation_low_ = 0.0
 
int output_saturation_status_ = 0
 

详细描述

A proportional-integral-derivative controller for speed and steering using defualt integral hold

在文件 pid_controller.h 第 38 行定义.

构造及析构函数说明

◆ ~PIDController()

virtual apollo::control::PIDController::~PIDController ( )
virtualdefault

成员函数说明

◆ Control()

double apollo::control::PIDController::Control ( const double  error,
const double  dt 
)
virtual

compute control value based on the error

参数
errorerror value, the difference between a desired value and a measured value
dtsampling time interval
返回
control value based on PID terms

被 apollo::control::PIDBCController , 以及 apollo::control::PIDICController 重载.

在文件 pid_controller.cc 第 26 行定义.

26 {
27 if (dt <= 0) {
28 AWARN << "dt <= 0, will use the last output, dt: " << dt;
29 return previous_output_;
30 }
31 double diff = 0;
32 double output = 0;
33
34 if (first_hit_) {
35 first_hit_ = false;
36 } else {
37 diff = (error - previous_error_) / dt;
38 }
39 // integral hold
41 integral_ = 0;
42 } else if (!integrator_hold_) {
43 integral_ += error * dt * ki_;
44 // apply Ki before integrating to avoid steps when change Ki at steady state
51 } else {
53 }
54 }
55 previous_error_ = error;
56 output = error * kp_ + integral_ + diff * kd_; // Ki already applied
57 previous_output_ = output;
58 return output;
59}
#define AWARN
Definition log.h:43
float diff(Image< float > *I, int x1, int y1, int x2, int y2)
Dissimilarity measure between pixels

◆ Init()

void apollo::control::PIDController::Init ( const PidConf &  pid_conf)

initialize pid controller

参数
pid_confconfiguration for pid controller

在文件 pid_controller.cc 第 75 行定义.

75 {
76 previous_error_ = 0.0;
77 previous_output_ = 0.0;
78 integral_ = 0.0;
79 first_hit_ = true;
80 integrator_enabled_ = pid_conf.integrator_enable();
82 std::fabs(pid_conf.integrator_saturation_level());
84 -std::fabs(pid_conf.integrator_saturation_level());
86 integrator_hold_ = false;
87 output_saturation_high_ = std::fabs(pid_conf.output_saturation_level());
88 output_saturation_low_ = -std::fabs(pid_conf.output_saturation_level());
90 SetPID(pid_conf);
91}
void SetPID(const PidConf &pid_conf)
set pid controller coefficients for the proportional, integral, and derivative

◆ IntegratorHold()

bool apollo::control::PIDController::IntegratorHold ( ) const

get status that if integrator is hold

返回
if integrator is hold return true

在文件 pid_controller.cc 第 104 行定义.

104{ return integrator_hold_; }

◆ IntegratorSaturationStatus()

int apollo::control::PIDController::IntegratorSaturationStatus ( ) const

get saturation status

返回
saturation status

在文件 pid_controller.cc 第 100 行定义.

100 {
102}

◆ Reset()

void apollo::control::PIDController::Reset ( )

reset variables for pid controller

在文件 pid_controller.cc 第 66 行定义.

66 {
67 previous_error_ = 0.0;
68 previous_output_ = 0.0;
69 integral_ = 0.0;
70 first_hit_ = true;
73}

◆ Reset_integral()

void apollo::control::PIDController::Reset_integral ( )

reset integral for pid controller

在文件 pid_controller.cc 第 61 行定义.

61 {
62 integral_ = 0.0;
64}

◆ SetIntegratorHold()

void apollo::control::PIDController::SetIntegratorHold ( bool  hold)

set whether to hold integrator component at its current value.

参数
hold

在文件 pid_controller.cc 第 106 行定义.

106{ integrator_hold_ = hold; }

◆ SetPID()

void apollo::control::PIDController::SetPID ( const PidConf &  pid_conf)

set pid controller coefficients for the proportional, integral, and derivative

参数
pid_confconfiguration for pid controller

在文件 pid_controller.cc 第 93 行定义.

93 {
94 kp_ = pid_conf.kp();
95 ki_ = pid_conf.ki();
96 kd_ = pid_conf.kd();
97 kaw_ = pid_conf.kaw();
98}

类成员变量说明

◆ first_hit_

bool apollo::control::PIDController::first_hit_ = false
protected

在文件 pid_controller.h 第 102 行定义.

◆ integral_

double apollo::control::PIDController::integral_ = 0.0
protected

在文件 pid_controller.h 第 99 行定义.

◆ integrator_enabled_

bool apollo::control::PIDController::integrator_enabled_ = false
protected

在文件 pid_controller.h 第 103 行定义.

◆ integrator_hold_

bool apollo::control::PIDController::integrator_hold_ = false
protected

在文件 pid_controller.h 第 104 行定义.

◆ integrator_saturation_high_

double apollo::control::PIDController::integrator_saturation_high_ = 0.0
protected

在文件 pid_controller.h 第 100 行定义.

◆ integrator_saturation_low_

double apollo::control::PIDController::integrator_saturation_low_ = 0.0
protected

在文件 pid_controller.h 第 101 行定义.

◆ integrator_saturation_status_

int apollo::control::PIDController::integrator_saturation_status_ = 0
protected

在文件 pid_controller.h 第 105 行定义.

◆ kaw_

double apollo::control::PIDController::kaw_ = 0.0
protected

在文件 pid_controller.h 第 96 行定义.

◆ kd_

double apollo::control::PIDController::kd_ = 0.0
protected

在文件 pid_controller.h 第 95 行定义.

◆ ki_

double apollo::control::PIDController::ki_ = 0.0
protected

在文件 pid_controller.h 第 94 行定义.

◆ kp_

double apollo::control::PIDController::kp_ = 0.0
protected

在文件 pid_controller.h 第 93 行定义.

◆ output_saturation_high_

double apollo::control::PIDController::output_saturation_high_ = 0.0
protected

在文件 pid_controller.h 第 107 行定义.

◆ output_saturation_low_

double apollo::control::PIDController::output_saturation_low_ = 0.0
protected

在文件 pid_controller.h 第 108 行定义.

◆ output_saturation_status_

int apollo::control::PIDController::output_saturation_status_ = 0
protected

在文件 pid_controller.h 第 109 行定义.

◆ previous_error_

double apollo::control::PIDController::previous_error_ = 0.0
protected

在文件 pid_controller.h 第 97 行定义.

◆ previous_output_

double apollo::control::PIDController::previous_output_ = 0.0
protected

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


该类的文档由以下文件生成: