Update Main.cpp

This commit is contained in:
leondevdev 2022-12-13 14:03:02 +01:00 committed by GitHub
parent d270bfa5ef
commit 249c6d1d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,39 +184,54 @@ void drive()
} }
*/ */
if (0 == Direction){ if (0 == Direction){
omniDrive.setVelocity(0.1, 0, 0); omniDrive.setVelocity(0.2, 0, 0);
if (1 <= x_distance){ if (0.5 <= x_distance){
Direction = 1; Direction = 1;
} }
} }
if (1 == Direction){ if (1 == Direction){
omniDrive.setVelocity(-0.1, 0, 0); omniDrive.setVelocity(-0.2, 0, 0);
if (0.1 >= x_distance){
Direction = 2;
}
if (0.3 >= x_distance)
Direction = 2;
} }
if (2 == Direction){ if (2 == Direction){
omniDrive.setVelocity(0.1, 0.1, 0); omniDrive.setVelocity(0.2, 0.2, 0);
if (0.2 <= x_distance && 0.28 <= y_distance){
if (x_distance <= 1 && 1 <= y_distance ){
Direction = 3; Direction = 3;
} }
} }
if (3 == Direction){ if (3 == Direction){
for (int i = 0; i < 200; i++){ omniDrive.setVelocity(-0.2, -0.2, 0);
if(0.1 >= x_distance && 0.1 >= y_distance){
Direction = 4;
}
}
omniDrive.setVelocity(0.1, 0.1, 0); if (4 == Direction){
omniDrive.setVelocity(0, 0.2, 0);
if (0.5 <= y_distance){
Direction = 5;
}
}
if (5 == Direction){
omniDrive.setVelocity(0, -0.2, 0);
if (0.1 >= y_distance){
Direction = 6;
} }
} }
com.processEvents(); com.processEvents();
rec::robotino::api2::msleep(100); rec::robotino::api2::msleep(10);
} }
} }
@ -227,6 +242,7 @@ void CrossingDriveanndRotate(){
rotate360(); rotate360();
} }
if (false == DriveorRotate){ if (false == DriveorRotate){
DriveorRotate = true; DriveorRotate = true;
@ -240,7 +256,7 @@ void destroy()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
std::string hostname = "192.168.100.170"; std::string hostname = "172.27.1.1";
if( argc > 1 ) if( argc > 1 )
{ {
hostname = argv[1]; hostname = argv[1];
@ -279,4 +295,3 @@ int main( int argc, char **argv )
#endif #endif
} }