diff --git a/src/C++/Driver/src/test.cpp b/src/C++/Driver/src/test.cpp index f846e7d..b2862c7 100644 --- a/src/C++/Driver/src/test.cpp +++ b/src/C++/Driver/src/test.cpp @@ -1,8 +1,8 @@ #include "CKobuki.h" -#include -#include -#include #include "graph.h" +#include +#include +#include using namespace std; CKobuki robot; @@ -11,57 +11,56 @@ int command(); const int forward = 1; const int ROTATE = 2; -int main() -{ - unsigned char *null_ptr(0); - robot.startCommunication("/dev/ttyUSB0", true, null_ptr); - usleep(1 * 1000 * 1000); - thread mv(command); - usleep(30 * 1000 * 1000); - mv.join(); //only exit once thread one is done running +int main() { + unsigned char *null_ptr(0); + robot.startCommunication("/dev/ttyUSB0", true, null_ptr); + usleep(1 * 1000 * 1000); + thread mv(command); + usleep(30 * 1000 * 1000); + mv.join(); // only exit once thread one is done running } // int checkCenterCliff() // { // while (true) // { -// std::cout << "cliffsensordata:" << robot.parser.data.CliffSensorCenter << std::endl; +// std::cout << "cliffsensordata:" << +// robot.parser.data.CliffSensorCenter << std::endl; // } // } // int checkWheelDrop(){ // while (true) // { -// std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft << std::endl; +// std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft +// << std::endl; // } // } -int command(){ - cout << "choose between forward and rotate" << endl; - cout << "What must the robot do?"; - cin >> input; +int command() { + std::cout << "choose between forward and rotate" << endl; + std::cout << "What must the robot do?"; + cin >> input; - switch(input){ - case forward:{ - int distance; - std::cout >> "Enter distance to move forward: "; - std::cin >> distance; - robot.goStraight(distance); - } - - case ROTATE:{ - int angle; - std::cout >> "Enter angle to rotate: "; - std::cin >> angle; - robot.doRotation(angle); - } - robot.goStraight(-1); - break; - - default: - cout << "Invalid input" << endl; - break; - } - + switch (input) { + case forward: { + int distance; + std::cout >> "Enter distance to move forward: "; + std::cin >> distance; + robot.goStraight(distance); + } break; + + case ROTATE: { + int angle; + std::cout >> "Enter angle to rotate: "; + std::cin >> angle; + robot.doRotation(angle); + robot.goStraight(-1); + + } break; + + default: + cout << "Invalid input" << endl; + break; + } } -