mirror of
https://gitee.com/yyz_o/bk_bishe_pi.git
synced 2025-09-07 23:21:26 +00:00
25.5.29第二次提交
This commit is contained in:
@@ -16,7 +16,7 @@ void BOTturn(int turn)
|
|||||||
{
|
{
|
||||||
MOTORDriveRaw(1,20);
|
MOTORDriveRaw(1,20);
|
||||||
MOTORDriveRaw(2,-18);
|
MOTORDriveRaw(2,-18);
|
||||||
} while (abs(ENCODERRead(2)) < 250);
|
} while (abs(ENCODERRead(2)) < 240);
|
||||||
MOTORDriveRaw(1,0);
|
MOTORDriveRaw(1,0);
|
||||||
MOTORDriveRaw(2,0);
|
MOTORDriveRaw(2,0);
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ void BOTturn(int turn)
|
|||||||
{
|
{
|
||||||
MOTORDriveRaw(1,-20);
|
MOTORDriveRaw(1,-20);
|
||||||
MOTORDriveRaw(2,18);
|
MOTORDriveRaw(2,18);
|
||||||
} while (abs(ENCODERRead(2)) < 250);
|
} while (abs(ENCODERRead(2)) < 240);
|
||||||
MOTORDriveRaw(1,0);
|
MOTORDriveRaw(1,0);
|
||||||
MOTORDriveRaw(2,0);
|
MOTORDriveRaw(2,0);
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ void BOTturn(int turn)
|
|||||||
MOTORDriveRaw(1,20);
|
MOTORDriveRaw(1,20);
|
||||||
MOTORDriveRaw(2,-18);
|
MOTORDriveRaw(2,-18);
|
||||||
|
|
||||||
} while (abs(ENCODERRead(2)) < 580);
|
} while (abs(ENCODERRead(2)) < 570);
|
||||||
MOTORDriveRaw(1,0);
|
MOTORDriveRaw(1,0);
|
||||||
MOTORDriveRaw(2,0);
|
MOTORDriveRaw(2,0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,14 @@ int main()
|
|||||||
array_copy_wall(mazesize_x, mazesize_y, copy_wall); //复制一份wall数组,并转换为一维数组,便于后续频繁读取提升性能
|
array_copy_wall(mazesize_x, mazesize_y, copy_wall); //复制一份wall数组,并转换为一维数组,便于后续频繁读取提升性能
|
||||||
|
|
||||||
cout << "访问数组打印:" << endl;
|
cout << "访问数组打印:" << endl;
|
||||||
|
cout << endl;
|
||||||
output_arr2D(mazesize_x, mazesize_y, copy_mark); //打印地图mark信息
|
output_arr2D(mazesize_x, mazesize_y, copy_mark); //打印地图mark信息
|
||||||
cout << "地图打印:" << endl;
|
cout << "地图打印:" << endl;
|
||||||
|
cout << endl;
|
||||||
output_arrwall(mazesize_x, mazesize_y, copy_wall); //打印墙壁wall信息
|
output_arrwall(mazesize_x, mazesize_y, copy_wall); //打印墙壁wall信息
|
||||||
|
|
||||||
cout << "请输入目标点的X,Y坐标值 用空格隔开并回车" << endl;
|
cout << "请输入目标点的X,Y坐标值 用空格隔开并回车" << endl;
|
||||||
|
cout << endl;
|
||||||
cin >> target_x >> target_y;
|
cin >> target_x >> target_y;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
@@ -39,6 +42,7 @@ int main()
|
|||||||
|
|
||||||
flood(map, copy_wall); //洪水填充算法
|
flood(map, copy_wall); //洪水填充算法
|
||||||
cout << "路径打印:" << endl;
|
cout << "路径打印:" << endl;
|
||||||
|
cout << endl;
|
||||||
output_arr2D(mazesize_x, mazesize_y, map); //打印map的数组信息
|
output_arr2D(mazesize_x, mazesize_y, map); //打印map的数组信息
|
||||||
|
|
||||||
const int len = map[((target_x - 1) * mazesize_y) + (target_y -1)]; //迷宫的终点(人为确定)
|
const int len = map[((target_x - 1) * mazesize_y) + (target_y -1)]; //迷宫的终点(人为确定)
|
||||||
@@ -47,6 +51,7 @@ int main()
|
|||||||
build_path(target_x - 1, target_y - 1, len, path, map, copy_wall); //构建出最短路径path数组
|
build_path(target_x - 1, target_y - 1, len, path, map, copy_wall); //构建出最短路径path数组
|
||||||
|
|
||||||
cout << "移动指令打印:" << endl;
|
cout << "移动指令打印:" << endl;
|
||||||
|
cout << endl;
|
||||||
output_arrpath(len, path); //打印path数组信息,及小车每一步的行驶方向
|
output_arrpath(len, path); //打印path数组信息,及小车每一步的行驶方向
|
||||||
|
|
||||||
drive_path(len, path); //移动到指定目标点
|
drive_path(len, path); //移动到指定目标点
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ using namespace std;
|
|||||||
/*---定义数据---*/
|
/*---定义数据---*/
|
||||||
/*---定义全局常量---*/
|
/*---定义全局常量---*/
|
||||||
const int DIST_cell = 240; //单元格长度
|
const int DIST_cell = 240; //单元格长度
|
||||||
const int DIST_move = 330; //移动的单元格距离
|
const int DIST_move = 320; //移动的单元格距离
|
||||||
const int DIST_wall_F = 95; //与墙壁的距离
|
//~ const int DIST_move = 330; //移动的单元格距离
|
||||||
|
const int DIST_wall_F = 100; //与墙壁的距离
|
||||||
|
//~ const int DIST_wall_F = 95; //与墙壁的距离
|
||||||
//~ const int DIST_wall_RL = 90; //与左右墙壁的距离 1
|
//~ const int DIST_wall_RL = 90; //与左右墙壁的距离 1
|
||||||
const int DIST_wall_RL = 87; //与左右墙壁的距离
|
const int DIST_wall_RL = 87; //与左右墙壁的距离
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user