making a loop so it doesnt stop

This commit is contained in:
ishak jmilou.ishak
2024-10-08 13:10:03 +02:00
parent b5874dbf9e
commit 45bd2196ef

View File

@@ -15,32 +15,30 @@ 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;
while (true) {
std::cout << "choose between forward and rotate" << endl;
std::cout << "What must the robot do?";
std::cin >> input;
@@ -63,4 +61,5 @@ int command() {
cout << "Invalid input" << endl;
break;
}
}
}