From 6f3f11d5e259fe6714f51d2e995765a46f1f665b Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Thu, 3 Oct 2024 13:54:58 +0200 Subject: [PATCH] testing controls --- src/C++/Driver/src/test.cpp | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/C++/Driver/src/test.cpp diff --git a/src/C++/Driver/src/test.cpp b/src/C++/Driver/src/test.cpp new file mode 100644 index 0000000..8374bd4 --- /dev/null +++ b/src/C++/Driver/src/test.cpp @@ -0,0 +1,52 @@ +#include "CKobuki.h" +#include "errno.h" +#include "termios.h" +#include +#include + +// define for the commands +#define turnRight robot.doRotation(0.25) +#define turnLeft robot.doRotation(-0.25) +#define straight robot.forward(1024, 2) +#define backwards robot.forward(1024, -1) + +using namespace std; +CKobuki robot; +int command(); + +int main() +{ + unsigned char *null_ptr(0); + robot.startCommunication("/dev/ttyUSB0", true, null_ptr); + usleep(1 * 1000 * 1000); + cout << "Enter commando"; + thread mv(command); + usleep(30 * 1000 * 1000); + mv.join(); //only exit once thread one is done running +} + +int command(){ + int input; + + cin >> input; + + switch(input){ + case 1: + straight; + break; + case 2: + turnRight; + break; + case 3: + turnLeft; + break; + case 4: + backwards; + break; + default: + cout << "Invalid input" << endl; + break; + } + +} +