Compare commits

..

3 Commits

Author SHA1 Message Date
Ñõԭ×Ó
9ba913646c 25.5.29第二次提交 2025-05-29 12:11:35 +08:00
Ñõԭ×Ó
efa0d49694 2025.5.29第二次 2025-05-29 11:04:41 +08:00
氧原子
a30de465d1 2025.5.29第一次提交 2025-05-29 10:59:54 +08:00
6 changed files with 14 additions and 5 deletions

View File

@@ -1,8 +1,10 @@
cxx := gccarm cxx := gccarm
#~ cxx := g++sim
file_cpp := $(wildcard *.cpp) file_cpp := $(wildcard *.cpp)
file_o := /home/pi/usr/maze2.x file_o := /home/pi/usr/maze2.x
#~ file_o := ../maze2.x
$(file_o) : $(file_cpp) $(file_o) : $(file_cpp)
@$(cxx) $^ -o $@ @$(cxx) $^ -o $@

View File

@@ -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);
} }

View File

@@ -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); //移动到指定目标点

View File

@@ -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; //与左右墙壁的距离

BIN
maze2.x Normal file

Binary file not shown.

BIN
文件/maze2.x Executable file

Binary file not shown.