mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79
This commit is contained in:
@@ -23,10 +23,8 @@ void setup(){
|
||||
|
||||
int main(){
|
||||
setup();
|
||||
client.run();
|
||||
while(true){
|
||||
parseMQTT(readMQTT());
|
||||
cout << readMQTT() << endl; //debugging
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -37,9 +35,7 @@ std::string readMQTT()
|
||||
if (!message.empty()) {
|
||||
std::cout << "MQTT Message: " << message << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "No message received" << std::endl;
|
||||
}
|
||||
|
||||
// Add a small delay to avoid busy-waiting
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
return message;
|
||||
@@ -48,12 +44,19 @@ std::string readMQTT()
|
||||
void parseMQTT(std::string message){
|
||||
if(message == "up"){
|
||||
robot.forward(600);
|
||||
message = 0;
|
||||
}
|
||||
else if(message == "left"){
|
||||
robot.Rotate(90);
|
||||
message = 0;
|
||||
|
||||
}
|
||||
else if(message == "down"){
|
||||
robot.Rotate(-90);
|
||||
message = 0;
|
||||
}
|
||||
else if(message = 0){
|
||||
robot.sendNullMessage();
|
||||
}
|
||||
else{
|
||||
std::cout << "Invalid command" << std::endl;
|
||||
|
Reference in New Issue
Block a user