mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 20:35:00 +00:00
avoid busy waiting
This commit is contained in:
@@ -592,6 +592,8 @@ void CKobuki::robotSafety() {
|
||||
std::cout << "Safety condition triggered!" << std::endl; // Debug print
|
||||
forward(-100); // reverse the robot
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(100)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,8 @@
|
||||
#include <iostream>
|
||||
//moet checkenvalue gebruiken of moet kijken naar de payloadlength welke dingen er extra zijn
|
||||
int KobukiParser::parseKobukiMessage(TKobukiData &output, unsigned char *data) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(20))); //avoid busy waiting. The kobuki sends a message every 20ms
|
||||
|
||||
int rtrnvalue = checkChecksum(data);
|
||||
if (rtrnvalue != 0) {
|
||||
// std::cerr << "Invalid checksum" << std::endl;
|
||||
|
@@ -37,6 +37,9 @@ int main()
|
||||
|
||||
while(true){
|
||||
parseMQTT(readMQTT());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(10)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
sendMqtt.join();
|
||||
|
Reference in New Issue
Block a user