mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
62 lines
885 B
C++
62 lines
885 B
C++
#include "CKobuki.h"
|
|
#include <iostream>
|
|
#include <cmath>
|
|
#include <thread>
|
|
#include "graph.h"
|
|
|
|
using namespace std;
|
|
CKobuki robot;
|
|
int movement();
|
|
|
|
int main()
|
|
{
|
|
unsigned char *null_ptr(0);
|
|
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
|
usleep(1 * 1000 * 1000);
|
|
cout << "Enter commando";
|
|
thread mv(movement);
|
|
usleep(30 * 1000 * 1000);
|
|
}
|
|
|
|
int checkCenterCliff()
|
|
{
|
|
while (true)
|
|
{
|
|
std::cout << "cliffsensordata:" << robot.data.CliffSensorCenter << std::endl;
|
|
}
|
|
}
|
|
|
|
int movement()
|
|
{
|
|
int text;
|
|
while (true)
|
|
{
|
|
cin >> text;
|
|
|
|
if (text == 1)
|
|
{
|
|
robot.goStraight(1);
|
|
}
|
|
else if (text == 2)
|
|
{
|
|
// 1 is full circle
|
|
robot.doRotation(0.25);
|
|
}
|
|
else if (text == 3)
|
|
{
|
|
// Add your code here for text == 3
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
robot.doRotation(text);
|
|
throw "NaN";
|
|
}
|
|
catch (const char *msg)
|
|
{
|
|
cerr << msg << endl;
|
|
}
|
|
}
|
|
}
|
|
} |