飞道的博客

自动驾驶控制算法之车辆纵向控制(project)

871人阅读  评论(0)

本文为深蓝学院-自动驾驶控制与规划-第二章作业

目录

1 project introduction

2 思路提示

3 解决积分饱和的方法

3.1 IC 积分遇限削弱法

3.2 BC 反馈抑制抗饱和

4 ROS+LGSVL联合仿真


1 project introduction

本项目希望大家根据PID控制方法实现一个巡航控制系统。我们已经为大家开发了ROS1.0的系统框架,仅需要大家实现.cpp文件中的todo部分,即 control 实现以及 reset PID参数。

框架如下


  
  1. #include "pid_controller.h"
  2. namespace shenlan {
  3. namespace control {
  4. PIDController:: PIDController( const double kp, const double ki,
  5. const double kd) {
  6. kp_ = kp;
  7. ki_ = ki;
  8. kd_ = kd;
  9. previous_error_ = 0.0;
  10. previous_output_ = 0.0;
  11. integral_ = 0.0;
  12. first_hit_ = true;
  13. }
  14. // /**to-do**/ 实现PID控制
  15. double PIDController::Control(const double error, const double dt) {
  16. }
  17. // /**to-do**/ 重置PID参数
  18. void PIDController::Reset() {
  19. }
  20. } // namespace control
  21. } // namespace shenlan

2 思路提示

为实现PID控制,我们可以利用离散的PID控制来实现,当采样时间足够短时,也能保持较好的性能,公式如下

需要注意的点就是积分初始值为0、微分初始值为0 


  
  1. double PIDController::Control(const double error, const double dt) {
  2. if (dt<= 0)
  3. { return previous_output_;
  4. }
  5. double diff= 0;
  6. double output= 0;
  7. if (first_hit_){
  8. first_hit_= false;
  9. }
  10. else{
  11. diff=( error-previous_error_)*kd_/dt;
  12. }
  13. integral_ += error*dt*ki_;//积分的计算可以由下面两种方法替代
  14. output= error*kp_+integral_+diff;
  15. previous_error_= error;
  16. previous_output_= output;
  17. return output;
  18. }

同时项目中还要求写一个 reset 的函数,我们需要更新下面这四个参数来保证从头开始


  
  1. void PIDController:: Reset() {
  2. previous_error_ = 0.0;
  3. previous_output_ = 0.0;
  4. integral_ = 0.0;
  5. first_hit_ = true;
  6. }

3 解决积分饱和的方法

3.1 IC 积分遇限削弱法


  
  1. // 积分遇限消弱法
  2. double output_saturation_high= 10.0;
  3. double output_saturation_low= -10.0;
  4. double u = error*kp_+integral_+ error*dt*ki_+diff*kd_ ; // 算当前时刻理应输出大小
  5. if ((( error *u)> 0) &&
  6. ((u > output_saturation_high )||(u < output_saturation_low))) {
  7. }
  8. else {
  9. integral_ += error*dt*ki_;
  10. }

3.2 BC 反馈抑制抗饱和


  
  1. // 反馈抑制抗饱和
  2. double output_saturation_high= 10.0;
  3. double output_saturation_low= -10.0;
  4. double kaw=ki_/kp_;
  5. double u = error*kp_+integral_+error*dt*ki_+diff*kd_;
  6. double aw_term = 0.0;
  7. if (u > output_saturation_high){
  8. aw_term=(output_saturation_high-u)*kaw;
  9. }
  10. else if (u < output_saturation_low)
  11. aw_term=(output_saturation_low)*kaw;
  12. else{
  13. }
  14. integral_+=aw_term+error*dt*ki_;
  15. }

4 ROS+LGSVL联合仿真

这里是联合仿真的链接

 自动驾驶PID控制(ROS+LGSVL联合仿真)_哔哩哔哩_bilibili


转载:https://blog.csdn.net/weixin_65089713/article/details/128720062
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场