mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
making a loop so it doesnt stop
This commit is contained in:
@@ -15,52 +15,51 @@ int main() {
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
usleep(1 * 1000 * 1000);
|
||||
std::cout << "choose between forward and rotate" << endl;
|
||||
thread mv(command);
|
||||
usleep(30 * 1000 * 1000);
|
||||
mv.join(); // only exit once thread one is done running
|
||||
|
||||
while (true) {
|
||||
command();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int checkCenterCliff() {
|
||||
while (true) {
|
||||
std::cout << "cliffsensordata:" << robot.parser.data.CliffSensorCenter << std::endl;
|
||||
std::cout << "cliffsensordata:" << robot.parser.data.CliffSensorCenter
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int checkWheelDrop() {
|
||||
while (true) {
|
||||
std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft << std::endl;
|
||||
std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int command() {
|
||||
char input;
|
||||
std::cout << "What must the robot do?";
|
||||
std::cin >> input;
|
||||
|
||||
switch (input) {
|
||||
case FORWARD: {
|
||||
int distance;
|
||||
std::cout << "Enter distance to move forward: ";
|
||||
std::cin >> distance;
|
||||
robot.goStraight(distance);
|
||||
} break;
|
||||
while (true) {
|
||||
std::cout << "choose between forward and rotate" << endl;
|
||||
std::cout << "What must the robot do?";
|
||||
std::cin >> input;
|
||||
|
||||
case ROTATE: {
|
||||
int angle;
|
||||
std::cout << "Enter angle to rotate: ";
|
||||
std::cin >> angle;
|
||||
robot.doRotation(angle);
|
||||
} break;
|
||||
switch (input) {
|
||||
case FORWARD: {
|
||||
int distance;
|
||||
std::cout << "Enter distance to move forward: ";
|
||||
std::cin >> distance;
|
||||
robot.goStraight(distance);
|
||||
} break;
|
||||
|
||||
default:
|
||||
cout << "Invalid input" << endl;
|
||||
break;
|
||||
case ROTATE: {
|
||||
int angle;
|
||||
std::cout << "Enter angle to rotate: ";
|
||||
std::cin >> angle;
|
||||
robot.doRotation(angle);
|
||||
} break;
|
||||
|
||||
default:
|
||||
cout << "Invalid input" << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user