mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
put movement in its own function
This commit is contained in:
@@ -1,37 +1,53 @@
|
|||||||
#include "CKobuki.h"
|
#include "CKobuki.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <thread>
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
CKobuki robot;
|
CKobuki robot;
|
||||||
|
int movement();
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
unsigned char * null_ptr(0);
|
{
|
||||||
int text;
|
unsigned char *null_ptr(0);
|
||||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||||
usleep(1*1000*1000);
|
usleep(1 * 1000 * 1000);
|
||||||
cout << "Enter commando";
|
cout << "Enter commando";
|
||||||
cin >> text;
|
usleep(30 * 1000 * 1000);
|
||||||
if (text == 1) {
|
thread mv(movement);
|
||||||
|
}
|
||||||
|
|
||||||
|
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(10);
|
robot.goStraight(10);
|
||||||
}
|
}
|
||||||
if (text == 2) {
|
if (text == 2)
|
||||||
robot.doRotation(90);
|
{
|
||||||
}
|
robot.doRotation(90);
|
||||||
if (text == 3) {
|
}
|
||||||
robot.doRotation(90);
|
if (text == 3)
|
||||||
}
|
{
|
||||||
else {
|
robot.doRotation(90);
|
||||||
cout << "no text specified";
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
usleep(30*1000*1000);
|
cout << "no text specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
int checkCenterCliff() {
|
|
||||||
while(true) {
|
|
||||||
std::cout << "cliffsensordata:" << robot.data.CliffSensorCenter << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user