mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
test in another branch
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#include "CKobuki.h"
|
#include "CKobuki.h"
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include <thread>
|
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
CKobuki robot;
|
CKobuki robot;
|
||||||
@@ -11,57 +11,56 @@ int command();
|
|||||||
const int forward = 1;
|
const int forward = 1;
|
||||||
const int ROTATE = 2;
|
const int ROTATE = 2;
|
||||||
|
|
||||||
int main()
|
int main() {
|
||||||
{
|
unsigned char *null_ptr(0);
|
||||||
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);
|
thread mv(command);
|
||||||
thread mv(command);
|
usleep(30 * 1000 * 1000);
|
||||||
usleep(30 * 1000 * 1000);
|
mv.join(); // only exit once thread one is done running
|
||||||
mv.join(); //only exit once thread one is done running
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int checkCenterCliff()
|
// int checkCenterCliff()
|
||||||
// {
|
// {
|
||||||
// while (true)
|
// while (true)
|
||||||
// {
|
// {
|
||||||
// std::cout << "cliffsensordata:" << robot.parser.data.CliffSensorCenter << std::endl;
|
// std::cout << "cliffsensordata:" <<
|
||||||
|
// robot.parser.data.CliffSensorCenter << std::endl;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int checkWheelDrop(){
|
// int checkWheelDrop(){
|
||||||
// while (true)
|
// while (true)
|
||||||
// {
|
// {
|
||||||
// std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft << std::endl;
|
// std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft
|
||||||
|
// << std::endl;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int command(){
|
int command() {
|
||||||
cout << "choose between forward and rotate" << endl;
|
std::cout << "choose between forward and rotate" << endl;
|
||||||
cout << "What must the robot do?";
|
std::cout << "What must the robot do?";
|
||||||
cin >> input;
|
cin >> input;
|
||||||
|
|
||||||
switch(input){
|
switch (input) {
|
||||||
case forward:{
|
case forward: {
|
||||||
int distance;
|
int distance;
|
||||||
std::cout >> "Enter distance to move forward: ";
|
std::cout >> "Enter distance to move forward: ";
|
||||||
std::cin >> distance;
|
std::cin >> distance;
|
||||||
robot.goStraight(distance);
|
robot.goStraight(distance);
|
||||||
}
|
} break;
|
||||||
|
|
||||||
case ROTATE:{
|
case ROTATE: {
|
||||||
int angle;
|
int angle;
|
||||||
std::cout >> "Enter angle to rotate: ";
|
std::cout >> "Enter angle to rotate: ";
|
||||||
std::cin >> angle;
|
std::cin >> angle;
|
||||||
robot.doRotation(angle);
|
robot.doRotation(angle);
|
||||||
}
|
robot.goStraight(-1);
|
||||||
robot.goStraight(-1);
|
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cout << "Invalid input" << endl;
|
cout << "Invalid input" << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user