From 8b667026057509b8eab858540849fb275b2e330a Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Tue, 14 Jan 2025 16:50:11 +0100 Subject: [PATCH] changed function --- src/C++/Driver/src/main.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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 }