mirror of
https://gitee.com/yyz_o/bk_bishe_pi.git
synced 2025-09-07 23:21:26 +00:00
2025.5.15第三次提交,继续修改
This commit is contained in:
@@ -9,13 +9,14 @@ using namespace std;
|
||||
|
||||
/*---定义数据---*/
|
||||
/*---定义全局常量---*/
|
||||
const int DIST_cell = 360 ; //单元格长度
|
||||
const int DIST_wall = 130 ; //与墙壁的距离
|
||||
const int DIST_cell = 300 ; //单元格长度
|
||||
const int DIST_wall_F = 90 ; //与墙壁的距离
|
||||
extern const int DIST_wall_RL = 100; //与左右墙壁的距离
|
||||
|
||||
/*---定义全局变量---*/
|
||||
/*---容器类---*/
|
||||
vector<vector<int>> mark(1,vector<int>(1,0)); //定义mark容器(二维容器),容器初始为1行1列 1=为已访问
|
||||
vector<vector<vector<int>>> wall(2,vector<vector<int>>(2,vector<int>(2,0))); //定义wall容器(三维容器),容器初始为1行1列,且每个格子内带有2个墙壁信息 1=墙壁;0=通路
|
||||
std::vector<std::vector<int>> mark(1,std::vector<int>(1,0)); //定义mark容器(二维容器),容器初始为1行1列 1=为已访问
|
||||
std::vector<std::vector<std::vector<int>>> wall(2,std::vector<std::vector<int>>(2,std::vector<int>(2,0))); //定义wall容器(三维容器),容器初始为1行1列,且每个格子内带有2个墙壁信息 1=墙壁;0=通路
|
||||
|
||||
/*---机器人坐标---*/
|
||||
int rob_x0 = 0; //机器人起点X坐标
|
||||
@@ -28,11 +29,12 @@ int rob_dir = 0; //机器人当前的朝向(初始为0)
|
||||
|
||||
|
||||
/*---PID算法---*/
|
||||
const float Kp = 1, Ki = 0, Kd = 0.5; //定义PID的参数
|
||||
const float Kp = 0.5, Ki = 0.2, Kd = 0.5; //定义PID的参数
|
||||
float Kpid; //定义PID计算后输出的倍率
|
||||
float Kpid_speed;
|
||||
const int Kpid_base = 2, speed = 24; //定义基本角速度和速度
|
||||
const int speed2 = 0.75*speed; //快到目的地时减速
|
||||
int Kpid_speed;
|
||||
const float Kpid_base = 0.1; //定义基本角速度和速度
|
||||
const int speed = 50; //定义基本角速度和速度
|
||||
const int speed2 = 0.75*speed; //快到目的地时减速
|
||||
int speed1;
|
||||
int err, err_old, err_sum, err_diff; //定义误差,上一次误差,积分误差,微分误差
|
||||
const int eI_max = 20; //定义积分限幅
|
||||
|
||||
Reference in New Issue
Block a user