mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
fix: streamline Kobuki communication startup and reconnection logic
This commit is contained in:
@@ -20,7 +20,8 @@ void sendKobukiData(TKobukiData &data);
|
||||
void setup() {
|
||||
unsigned char *null_ptr(0);
|
||||
std::cout << "Attempting to start communication with Kobuki..." << std::endl;
|
||||
if (!robot.startCommunication("/dev/ttyUSB0", true, null_ptr)) {
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
if (!robot.isConnected()) {
|
||||
std::cerr << "Failed to start communication with Kobuki." << std::endl;
|
||||
} else {
|
||||
std::cout << "Successfully started communication with Kobuki." << std::endl;
|
||||
@@ -41,9 +42,7 @@ int main() {
|
||||
while (true) {
|
||||
if (!robot.isConnected()) {
|
||||
std::cout << "Kobuki is not connected anymore. Reconnecting..." << std::endl;
|
||||
if (!robot.startCommunication("/dev/ttyUSB0", true, nullptr)) {
|
||||
std::cerr << "Failed to reconnect to Kobuki." << std::endl;
|
||||
}
|
||||
robot.startCommunication("/dev/ttyUSB0", true, nullptr);
|
||||
while (!robot.isConnected()) {
|
||||
std::cout << "Attempting to reconnect..." << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
Reference in New Issue
Block a user