mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
made more debug
This commit is contained in:
@@ -59,25 +59,36 @@ std::mutex connectionMutex;
|
|||||||
void checkKobukiConnection()
|
void checkKobukiConnection()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(connectionMutex);
|
std::lock_guard<std::mutex> lock(connectionMutex);
|
||||||
bool connected = robot.isConnected();
|
if (!robot.isConnected())
|
||||||
if (!connected && kobuki_connected)
|
{
|
||||||
|
if (kobuki_connected)
|
||||||
{
|
{
|
||||||
cout << "Kobuki is disconnected" << endl;
|
cout << "Kobuki is disconnected" << endl;
|
||||||
kobuki_connected = false;
|
kobuki_connected = false;
|
||||||
}
|
}
|
||||||
else if (connected && !kobuki_connected)
|
// Probeer opnieuw te verbinden
|
||||||
{
|
cout << "Attempting to reconnect Kobuki..." << endl;
|
||||||
cout << "Kobuki is reconnecting..." << endl;
|
|
||||||
robot.startCommunication("/dev/ttyUSB0", true, nullptr);
|
robot.startCommunication("/dev/ttyUSB0", true, nullptr);
|
||||||
kobuki_connected = true;
|
kobuki_connected = robot.isConnected();
|
||||||
|
if (kobuki_connected)
|
||||||
|
{
|
||||||
|
cout << "Kobuki reconnected successfully!" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << "Failed to reconnect Kobuki, retrying in 5 seconds..." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5)); // Controleer elke 5 seconden
|
std::this_thread::sleep_for(std::chrono::seconds(5)); // Controleer elke 5 seconden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string readMQTT()
|
std::string readMQTT()
|
||||||
{
|
{
|
||||||
static std::string lastMessage;
|
static std::string lastMessage;
|
||||||
|
Reference in New Issue
Block a user