mirror of
https://gitee.com/yyz_o/bk_bishe_pi.git
synced 2025-09-07 23:21:26 +00:00
2025.5.18第一次提交,包括17号和今天上午对实机的调试
This commit is contained in:
79
robot_test_code/实机测试/test_turn2.cpp
Normal file
79
robot_test_code/实机测试/test_turn2.cpp
Normal 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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user