mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
testing controls
This commit is contained in:
52
src/C++/Driver/src/test.cpp
Normal file
52
src/C++/Driver/src/test.cpp
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user