mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
removed code that didnt work
This commit is contained in:
@@ -15,8 +15,6 @@ CKobuki robot;
|
|||||||
std::string readMQTT();
|
std::string readMQTT();
|
||||||
void parseMQTT(std::string message);
|
void parseMQTT(std::string message);
|
||||||
void CapnSend();
|
void CapnSend();
|
||||||
void reconnectKobuki();
|
|
||||||
void monitorKobukiConnection();
|
|
||||||
// ip, clientID, username, password
|
// ip, clientID, username, password
|
||||||
MqttClient client("ws://145.92.224.21/ws/", "KobukiRPI", "rpi",
|
MqttClient client("ws://145.92.224.21/ws/", "KobukiRPI", "rpi",
|
||||||
"rpiwachtwoordofzo"); // create a client object
|
"rpiwachtwoordofzo"); // create a client object
|
||||||
@@ -32,13 +30,10 @@ void setup() {
|
|||||||
client.connect();
|
client.connect();
|
||||||
client.subscribe("home/commands");
|
client.subscribe("home/commands");
|
||||||
|
|
||||||
std::thread monitorThread(monitorKobukiConnection);
|
|
||||||
monitorThread.detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
setup();
|
setup();
|
||||||
reconnectKobuki();
|
|
||||||
|
|
||||||
std::thread image(CapnSend);
|
std::thread image(CapnSend);
|
||||||
std::thread safety([&]() { robot.robotSafety(&message); });
|
std::thread safety([&]() { robot.robotSafety(&message); });
|
||||||
@@ -56,31 +51,6 @@ int main() {
|
|||||||
image.join();
|
image.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reconnectKobuki() {
|
|
||||||
unsigned char *null_ptr(0);
|
|
||||||
while (true) {
|
|
||||||
if (robot.startCommunication("/dev/ttyUSB0", true, null_ptr) != -1) {
|
|
||||||
std::cout << "Kobuki opnieuw verbonden!" << std::endl;
|
|
||||||
break; // Verlaat de loop als de verbinding succesvol is
|
|
||||||
} else {
|
|
||||||
std::cerr << "Kobuki niet verbonden. Probeer opnieuw over 3 seconden..." << std::endl;
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitorKobukiConnection() {
|
|
||||||
while (true) {
|
|
||||||
// Check regelmatig of de verbinding actief is
|
|
||||||
if (!robot.isConnected()) {
|
|
||||||
std::cerr << "Kobuki verbinding verloren. Reconnectie starten..." << std::endl;
|
|
||||||
reconnectKobuki();
|
|
||||||
}
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5)); // Check iedere 5 seconden
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string readMQTT() {
|
std::string readMQTT() {
|
||||||
static std::string lastMessage;
|
static std::string lastMessage;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user