testing controls

This commit is contained in:
ishak jmilou.ishak
2024-10-03 13:54:58 +02:00
parent 92be35a8da
commit 6f3f11d5e2

View File

@@ -0,0 +1,52 @@
#include "CKobuki.h"
#include "errno.h"
#include "termios.h"
#include <cstddef>
#include <iostream>
// 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;
}
}