2025.5.17第一次提交,包括16号和今天,在实机上,对代码修改后的结果

This commit is contained in:
Ñõԭ×Ó
2025-05-17 15:04:27 +08:00
parent 137218ebe5
commit 5ce7796b14
7 changed files with 300 additions and 74 deletions

View File

@@ -0,0 +1,26 @@
cxx := gccarm
#~ file_cpp := $(wildcard *.cpp)
file_cpp := ./test_turn.cpp
#~ file_cpp := ./test_run.cpp
#~ file_cpp := ./test_psd.cpp
#~ file_o := /home/pi/usr/move.x
file_o := /home/pi/usr/turn.x
#~ file_o := /home/pi/usr/psd.x
$(file_o) : $(file_cpp)
@$(cxx) $^ -o $@
maze : $(file_o)
clean :
@rm -rf $(file_o)
debug :
@echo $(cxx)
@echo $(file_cpp)
@echo $(file_o)
.PHONY : maze clean debug

View File

@@ -0,0 +1,22 @@
#include<iostream>
#include<string>
#include"eyebot++.h"
using namespace std;
int main()
{
int Fwall,Lwall,Rwall,bwall;
LCDMenu("","","","END");
do
{
Fwall = PSDGetRaw(1); //检测前面侧是否有墙
Lwall = PSDGetRaw(2); //检测左面
Rwall = PSDGetRaw(3); //检测右面
bwall = PSDGetRaw(4); //
cout << "PSD L:" << Lwall << " R:" << Rwall << " F:" << Fwall << " b:" << bwall << endl; ;
} while (KEYRead() != KEY4);
}

View File

@@ -7,13 +7,27 @@ using namespace std;
int main()
{
int Fwall,Lwall,Rwall;
LCDMenu("","","","END");
//~ int num;
do
{ //检测墙面
MOTORDriveRaw(1,50);
MOTORDriveRaw(2,50);
{
MOTORDriveRaw(1,16);
MOTORDriveRaw(2,14);
//~ cin>>num;
//~ if(num)
//~ {
//~ MOTORDriveRaw(1,25);
//~ MOTORDriveRaw(2,-24);
//~ OSWait(1650);
//~ MOTORDriveRaw(1,18);
//~ MOTORDriveRaw(2,-16);
//~ OSWait(3500);
//~ MOTORDriveRaw(1,0);
//~ MOTORDriveRaw(2,0);
//~ }
} while (KEYRead() != KEY4);
}
}

View File

@@ -0,0 +1,106 @@
#include<iostream>
#include<string>
#include"eyebot++.h"
using namespace std;
int main()
{
//~ int f_wall, r_wall, l_wall, b_wall;
//~ int old_f_wall, old_r_wall, old_l_wall, old_b_wall;
int b_wall;
int old_b_wall;
int turn_check;
LCDMenu("","","","END");
int num;
do
{
cin>>num;
if(num == 1)
{
b_wall = PSDGetRaw(4) - 2;
do
{
old_b_wall = b_wall;
MOTORDriveRaw(1,19);
MOTORDriveRaw(2,-17);
//~ MOTORDriveRaw(1,24);
//~ MOTORDriveRaw(2,-22);
OSWait(850);
//~ OSWait(1980);
MOTORDriveRaw(1,0);
MOTORDriveRaw(2,0);
b_wall = (PSDGetRaw(4) - 2) * 0.7 + old_b_wall * 0.3; //减小突变
//~ b_wall = PSDGetRaw(4) - 2;
turn_check = b_wall - old_b_wall;
/*---打印输出PSD数值---*/
//~ cout << "PSD L:" << L_PSD << " R:" << R_PSD << " F:" << F_PSD << " " ;
cout << "b_wall:" << b_wall << " check:" << turn_check << endl;
/*---打印结束---*/
OSWait(50);
} while ( turn_check < -3 || b_wall > 130);
}
else if (num == 3)
{
b_wall = PSDGetRaw(4) - 2;
do
{
old_b_wall = b_wall;
MOTORDriveRaw(1,-19);
MOTORDriveRaw(2,17);
//~ MOTORDriveRaw(1,24);
//~ MOTORDriveRaw(2,-22);
OSWait(850);
//~ OSWait(1980);
MOTORDriveRaw(1,0);
MOTORDriveRaw(2,0);
b_wall = (PSDGetRaw(4) - 2) * 0.7 + old_b_wall * 0.3; //减小突变
//~ b_wall = PSDGetRaw(4) - 2;
turn_check = b_wall - old_b_wall;
/*---打印输出PSD数值---*/
//~ cout << "PSD L:" << L_PSD << " R:" << R_PSD << " F:" << F_PSD << " " ;
cout << "b_wall:" << b_wall << " check:" << turn_check << endl;
/*---打印结束---*/
OSWait(50);
} while (turn_check < -3 || b_wall > 130);
}
//~ if(num == 1)
//~ {
//~ MOTORDriveRaw(1,19);
//~ MOTORDriveRaw(2,-17);
//~ MOTORDriveRaw(1,24);
//~ MOTORDriveRaw(2,-22);
//~ OSWait(1500);
//~ OSWait(1980);
//~ MOTORDriveRaw(1,0);
//~ MOTORDriveRaw(2,0);
//~ }
//~ else if(num == 2)
//~ {
//~ MOTORDriveRaw(1,24);
//~ MOTORDriveRaw(2,-22);
//~ MOTORDriveRaw(1,24);
//~ MOTORDriveRaw(2,-22);
//~ OSWait(2700);
//~ OSWait(3250);
//~ MOTORDriveRaw(1,0);
//~ MOTORDriveRaw(2,0);
//~ }
//~ else if(num == 3)
//~ {
//~ MOTORDriveRaw(1,26);
//~ MOTORDriveRaw(2,-24);
//~ MOTORDriveRaw(1,-24);
//~ MOTORDriveRaw(2,22);
//~ OSWait(1815);
//~ OSWait(2025);
//~ MOTORDriveRaw(1,0);
//~ MOTORDriveRaw(2,0);
//~ }
else
{
}
} while (KEYRead() != KEY4);
}