From d10aa4baf38e8f1c3675b4a224d929da3552fd53 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 15 May 2024 18:10:17 +0200 Subject: [PATCH] speed --- TCPServer.cpp | 32 ++------------------------------ TCPServer.h | 2 -- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/TCPServer.cpp b/TCPServer.cpp index 7614728..78950d3 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -173,7 +173,7 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } } else if (args[0] == "1") { - int speed = static_cast((- value * 3.2) / 327.670f); + int speed = static_cast((- value * 3.1) / 327.670f); if (!handleEmergecnyFlag) { this->broadcastMessage("strat;arduino;speed;" + std::to_string(speed) + "\n"); } @@ -187,7 +187,7 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } } else if (args[0] == "2") { - double speed = static_cast((value * 3.2) / 327.670f); + double speed = static_cast((value * 3.1) / 327.670f); this->broadcastMessage("start;arduino;rotate;" + std::to_string(speed)); } } @@ -227,13 +227,6 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) this->broadcastMessage("strat;arduino;clear;1\n"); } } - else if (tokens[0] == "arduino") { - if (tokens[2] == "set pos") { - std::vector pos = TCPUtils::split(tokens[3], ","); - this->robotPose = {std::stof(pos[0]), std::stof(pos[1]), std::stof(pos[2]) / 100}; - this->sendToClient("strat;lidar;set pos;" + std::to_string(this->robotPose.pos.x) + "," + std::to_string(this->robotPose.pos.y) + "," + std::to_string(this->robotPose.theta) + "\n", lidarSocket); - } - } } void TCPServer::broadcastMessage(const char* message, int senderSocket) @@ -371,27 +364,6 @@ void TCPServer::checkIfAllClientsReady() { if (allReady) { this->broadcastMessage("strat;all;ready;1\n"); - std::thread([this]() { askArduinoPos(); }).detach(); - this->broadcastMessage("strat;arduino;set pos;0,0,0"); - this->broadcastMessage("strat;arduino;set pos;0,0,0"); - } -} - -void TCPServer::askArduinoPos() { - for (const auto & client : clients) { - if (client.name == "arduino") { - this->arduinoSocket = client.socket; - break; - } - } - - if (this->arduinoSocket == -1) { - return; - } - - while (!this->_shouldStop) { - this->sendToClient("strat;arduino;get pos;1\n", this->arduinoSocket); - usleep(50'000); } } diff --git a/TCPServer.h b/TCPServer.h index 5ac838b..3b4a8e8 100644 --- a/TCPServer.h +++ b/TCPServer.h @@ -106,8 +106,6 @@ public: void stop(); - void askArduinoPos(); - [[nodiscard]] size_t nbClients() const; [[nodiscard]] bool shouldStop() const;