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

@@ -1,14 +1,16 @@
cxx := gccarm
#~ cxx := gpparm
#~ file_cpp := $(wildcard *.cpp)
file_cpp := ./test_turn.cpp
#~ file_cpp := ./test_turn.cpp
#~ file_cpp := ./test_turn2.cpp
#~ file_cpp := ./test_run.cpp
#~ file_cpp := ./test_psd.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 := /home/pi/usr/turn.x
file_o := /home/pi/usr/psd.x
$(file_o) : $(file_cpp)
@$(cxx) $^ -o $@

View File

@@ -11,8 +11,8 @@ int main()
LCDMenu("","","","END");
do
{
Fwall = PSDGetRaw(1); //检测前面侧是否有墙
Lwall = PSDGetRaw(2); //检测左面
Fwall = PSDGetRaw(1)-2; //检测前面侧是否有墙
Lwall = PSDGetRaw(2)-16; //检测左面
Rwall = PSDGetRaw(3); //检测右面
bwall = PSDGetRaw(4); //
cout << "PSD L:" << Lwall << " R:" << Rwall << " F:" << Fwall << " b:" << bwall << endl; ;

View File

@@ -7,10 +7,8 @@ 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 f_wall, b_wall;
int old_f_wall, old_b_wall;
int turn_check;
LCDMenu("","","","END");
int num;
@@ -65,6 +63,34 @@ int main()
OSWait(50);
} while (turn_check < -3 || b_wall > 130);
}
else if (num == 2)
{
b_wall = PSDGetRaw(4) - 2;
f_wall = PSDGetRaw(1) - 2;
do
{
old_b_wall = b_wall;
old_f_wall = f_wall;
MOTORDriveRaw(1,19);
MOTORDriveRaw(2,-17);
//~ MOTORDriveRaw(1,24);
//~ MOTORDriveRaw(2,-22);
OSWait(1000);
//~ OSWait(1980);
MOTORDriveRaw(1,0);
MOTORDriveRaw(2,0);
b_wall = (PSDGetRaw(4) - 2) * 0.7 + old_b_wall * 0.3; //减小突变
f_wall = (PSDGetRaw(1) - 2) * 0.7 + old_f_wall * 0.3; //减小突变
//~ b_wall = PSDGetRaw(4) - 2;
//~ f_wall = PSDGetRaw(1) - 2;
turn_check = b_wall - old_b_wall;
/*---打印输出PSD数值---*/
//~ cout << "PSD L:" << L_PSD << " R:" << R_PSD << " F:" << F_PSD << " " ;
cout << "f_wall: " << f_wall << "\t" << "b_wall: " << b_wall << "\t" << "check: " << turn_check << endl;
/*---打印结束---*/
OSWait(50);
} while (f_wall < 200 || turn_check < -4 || b_wall > 130);
}
//~ if(num == 1)
//~ {
//~ MOTORDriveRaw(1,19);

View File

@@ -0,0 +1,79 @@
#include<iostream>
#include<string>
#include<cmath>
//~ #include"eyebot++.h"
#include"/home/pi/eyebot/include/eyebot++.h"
using namespace std;
int main()
{
LCDMenu("","","","END");
int num;
//~ int pwm1, pwm2;
do
{
cin>>num;
if (num == 1)
{
ENCODERReset(1);
ENCODERReset(2);
do
{
MOTORDriveRaw(1,21);
MOTORDriveRaw(2,-19);
} while (abs(ENCODERRead(2)) < 217);
MOTORDriveRaw(1,0);
MOTORDriveRaw(2,0);
}
else if (num == 2)
{
ENCODERReset(1);
ENCODERReset(2);
do
{
MOTORDriveRaw(1,21);
MOTORDriveRaw(2,-19);
} while (abs(ENCODERRead(2)) < 500);
MOTORDriveRaw(1,0);
MOTORDriveRaw(2,0);
}
else if (num == 3)
{
ENCODERReset(1);
ENCODERReset(2);
do
{
MOTORDriveRaw(1,-21);
MOTORDriveRaw(2,19);
} while (abs(ENCODERRead(2)) < 242);
MOTORDriveRaw(1,0);
MOTORDriveRaw(2,0);
}
else if (num == 4)
{
ENCODERReset(1);
ENCODERReset(2);
do
{
MOTORDriveRaw(1,-21);
} while (abs(ENCODERRead(1)) < 285);
MOTORDriveRaw(1,0);
do
{
MOTORDriveRaw(2,19);
} while (abs(ENCODERRead(2)) < 285);
MOTORDriveRaw(2,0);
}
else
{
cout << " num error " << endl;
}
} while (KEYRead() != KEY4);
}