mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
feat: implement automatic reconnection for Kobuki when disconnected
This commit is contained in:
@@ -238,7 +238,7 @@ void CKobuki::setSound(int noteinHz, int duration) {
|
||||
pocet = write(HCom, &message, 9);
|
||||
}
|
||||
|
||||
void CKobuki::startCommunication(const char *portname, bool CommandsEnabled,
|
||||
void CKobuki::startCommunication(char *portname, bool CommandsEnabled,
|
||||
void *userDataL) {
|
||||
if(connect(portname) != -1){
|
||||
enableCommands(CommandsEnabled);
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
long loop(void *user_data, TKobukiData &Kobuki_data);
|
||||
|
||||
void startCommunication(const char *portname,bool CommandsEnabled,void *userDataL);
|
||||
void startCommunication(char *portname,bool CommandsEnabled,void *userDataL);
|
||||
int measure(); //thread function, contains an infinite loop and reads data
|
||||
void setLed(int led1 = 0, int led2 = 0); //led1 green/red 2/1, //led2 green/red 2/1
|
||||
void setTranslationSpeed(int mmpersec);
|
||||
|
@@ -39,7 +39,7 @@ void setup()
|
||||
{
|
||||
std::string port = findKobukiPort();
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication((port.c_str()), true, null_ptr);
|
||||
robot.startCommunication(const_cast<char*>(port.c_str()), true, null_ptr);
|
||||
// connect mqtt server and sub to commands
|
||||
client.connect();
|
||||
client.subscribe("home/commands");
|
||||
@@ -95,7 +95,7 @@ void checkKobukiConnection()
|
||||
}
|
||||
|
||||
cout << "Attempting to reconnect Kobuki..." << endl;
|
||||
robot.startCommunication((port.c_str()), true, nullptr);
|
||||
robot.startCommunication(const_cast<char*>(port.c_str()), true, nullptr);
|
||||
|
||||
if (robot.isConnected()){
|
||||
cout << "Kobuki reconnected successfully!" << endl;
|
||||
|
Reference in New Issue
Block a user