diff --git a/src/C++/Driver/src/main.cpp b/src/C++/Driver/src/main.cpp index 8ec94c6..029f252 100644 --- a/src/C++/Driver/src/main.cpp +++ b/src/C++/Driver/src/main.cpp @@ -1,37 +1,53 @@ #include "CKobuki.h" #include #include - +#include #include "graph.h" using namespace std; CKobuki robot; +int movement(); -int main() { - unsigned char * null_ptr(0); - int text; +int main() +{ + unsigned char *null_ptr(0); robot.startCommunication("/dev/ttyUSB0", true, null_ptr); - usleep(1*1000*1000); + usleep(1 * 1000 * 1000); cout << "Enter commando"; - cin >> text; - if (text == 1) { - robot.goStraight(10); - } - if (text == 2) { - robot.doRotation(90); - } - if (text == 3) { - robot.doRotation(90); - } - else { - cout << "no text specified"; - } - - usleep(30*1000*1000); + usleep(30 * 1000 * 1000); + thread mv(movement); } -int checkCenterCliff() { - while(true) { - std::cout << "cliffsensordata:" << robot.data.CliffSensorCenter << std::endl; +int checkCenterCliff() +{ + while (true) + { + std::cout << "cliffsensordata:" << robot.data.CliffSensorCenter << std::endl; } -} \ No newline at end of file +} + +int movement() +{ + int text; + while (true) + { + cin >> text; + + if (text == 1) + { + robot.goStraight(10); + } + if (text == 2) + { + robot.doRotation(90); + } + if (text == 3) + { + robot.doRotation(90); + } + else + { + cout << "no text specified"; + } + } +}