From 249c6d1d5be31ed914e7f77754e188082c5b04fd Mon Sep 17 00:00:00 2001 From: leondevdev <75674735+leondevdev@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:03:02 +0100 Subject: [PATCH] Update Main.cpp --- Main.cpp | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/Main.cpp b/Main.cpp index 9deb46d..17f74aa 100644 --- a/Main.cpp +++ b/Main.cpp @@ -184,39 +184,54 @@ void drive() } */ + if (0 == Direction){ - omniDrive.setVelocity(0.1, 0, 0); - if (1 <= x_distance){ + omniDrive.setVelocity(0.2, 0, 0); + if (0.5 <= x_distance){ Direction = 1; } } 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){ - omniDrive.setVelocity(0.1, 0.1, 0); - - if (x_distance <= 1 && 1 <= y_distance ){ + omniDrive.setVelocity(0.2, 0.2, 0); + if (0.2 <= x_distance && 0.28 <= y_distance){ Direction = 3; + } + } + + if (3 == Direction){ + omniDrive.setVelocity(-0.2, -0.2, 0); + if(0.1 >= x_distance && 0.1 >= y_distance){ + Direction = 4; } } - if (3 == Direction){ - for (int i = 0; i < 200; i++){ - - 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(); - rec::robotino::api2::msleep(100); + rec::robotino::api2::msleep(10); } } @@ -227,6 +242,7 @@ void CrossingDriveanndRotate(){ rotate360(); } + if (false == DriveorRotate){ DriveorRotate = true; @@ -240,7 +256,7 @@ void destroy() int main( int argc, char **argv ) { - std::string hostname = "192.168.100.170"; + std::string hostname = "172.27.1.1"; if( argc > 1 ) { hostname = argv[1]; @@ -279,4 +295,3 @@ int main( int argc, char **argv ) #endif } -