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

@@ -8,9 +8,10 @@ using namespace std;
/*---定义数据---*/
/*---定义全局常量---*/
const int DIST_cell = 300 ; //单元格长度
const int DIST_wall_F = 90 ; //与墙壁的距离
extern const int DIST_wall_RL = 100; //与左右墙壁的距离
const int DIST_cell = 240; //单元格长度
const int DIST_move = 292; //移动的单元格距离
const int DIST_wall_F = 90; //与墙壁的距离
const int DIST_wall_RL = 88; //与左右墙壁的距离
/*---定义全局变量---*/
/*---容器类---*/
@@ -28,19 +29,21 @@ int rob_dir = 0; //机器人当前的朝向初始为0
/*---PID算法---*/
const float Kp = 0.8, Ki = 0.015, Kd = 0.15; //定义PID的参数
float Kpid; //定义PID计算后输出的倍率
const float Kp = 0.4, Ki = 0, Kd = 0.25; //定义PID的参数17
//~ const float Kp = 0.825, Ki = 0.0081, Kd = 0.175; //定义PID的参数17
//~ const float Kp = 0.80, Ki = 0.0076, Kd = 0.2; //定义PID的参数18
//~ float Kpid; //定义PID计算后输出的倍率
int Kpid_speed;
const float Kpid_base = 1; //定义基本角速度和速度
const int speed = 18; //定义基本角速度和速度
const int speed2 = 0.75*speed; //快到目的地时减速
const int speed_xianfu = 3; //定义kpid限幅
int speed1;
int err, err_old, err_sum, err_diff; //定义误差,上一次误差,积分误差,微分误差
const int eI_max = 200; //定义积分限幅
const float Kpid_base = 1; //定义基本角速度和速度
const int speed_l = 16; //定义基本左轮速度
//~ const int speed_r = speed_l - 2; //定义基本右轮速度
int speed_r = speed_l - 2; //定义基本右轮速度
const int speed_xianfu = 2; //定义kpid限幅
int err, err_old, err_sum, err_diff; //定义误差,上一次误差,积分误差,微分误差
const int eI_max = 200; //定义积分限幅
/*---目标点的坐标---*/
const int target_x = 4; //声明目标点的X坐标
const int target_y = 4; //声明目标点的Y坐标
/*---定义结束---*/
/*---定义结束---*/