Files
J2S1-Kobuki/src/C++/Driver/src/main.cpp
2024-09-23 14:14:37 +02:00

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;
}
}
}
}