2025.5.18第一次提交,包括17号和今天上午对实机的调试

This commit is contained in:
Ñõԭ×Ó
2025-05-18 11:35:02 +08:00
parent 47a4473330
commit df42d6ce7f
14 changed files with 232 additions and 103 deletions

View File

@@ -4,26 +4,21 @@
#include"PID.h"
using namespace std;
float Kp = 0.79, Ki = 0.009, Kd = 0.14; //定义PID的参数
float Kp = 0.815, Ki = 0.0083, Kd = 0.167; //定义PID的参数
float Kpid;
int Kpid_speed;
const int speed_l = 17;
const int speed_l = 18;
const int speed_r = speed_l - 2;
const int speed_err = 2;
const float Kpid_base = 1;
// const int speed2 = 0.75*speed;
// int speed1;
//int speed2 = speed;
/*---定义全局变量---*/
int err, err_old, err_sum, err_diff; //定义误差,上一次误差,积分误差,微分误差
const int eI_max = 200;
/*---定义全局常量---*/
/*---定义全局常量---*/
// const int DIST_cell = 300 ;
// const int DIST_wall = 100 ;
const int DIST_cell = 310;
const int DIST_wall_f = 120;
const int DIST_wall_f = 75;
const int DIST_wall_rl = 90;
/*---全局各种变量与常量定义完成---*/
@@ -126,7 +121,7 @@ void PIDStraight()
/*---打印输出PSD数值---*/
cout << "PSD L:" << L_PSD << " R:" << R_PSD << " F:" << F_PSD << " " ;
/*---打印结束---*/
if (20<L_PSD && L_PSD<180 && 50<R_PSD && R_PSD<180) //如果两侧都有墙的情况
if (20<L_PSD && L_PSD<180 && 20<R_PSD && R_PSD<180) //如果两侧都有墙的情况
{
err = L_PSD - R_PSD;
PID_AL();