diff --git a/src/C++/Driver/src/main.cpp b/src/C++/Driver/src/main.cpp index 71c85d1..b8e6571 100644 --- a/src/C++/Driver/src/main.cpp +++ b/src/C++/Driver/src/main.cpp @@ -33,16 +33,13 @@ void setup() void checkKobukiConnection() { while (true) { bool connected = robot.isConnected(); - if (connected && !kobuki_connected) { - cout << "Kobuki is connected" << endl; - kobuki_connected = true; - // Start de Kobuki automatisch - robot.startCommunication("/dev/ttyUSB0", true, nullptr); - } else if (!connected && kobuki_connected) { + if (!connected && kobuki_connected) { cout << "Kobuki is disconnected" << endl; kobuki_connected = false; - // Stop de Kobuki automatisch - robot.sendNullMessage(); + } else if (connected && !kobuki_connected) { + cout << "Kobuki is connecting..." << endl; + // Start de Kobuki automatisch + robot.startCommunication("/dev/ttyUSB0", true, nullptr); } std::this_thread::sleep_for(std::chrono::seconds(5)); // Controleer elke 5 seconden }