From 7588cdec01ce7cd88ed12829a3c88f475c3fc768 Mon Sep 17 00:00:00 2001 From: bap-0-1 Date: Sat, 1 Jun 2024 08:58:33 +0200 Subject: [PATCH] clear if value = 0 --- TCPServer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/TCPServer.cpp b/TCPServer.cpp index 96a5a3c..b1160b6 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -125,7 +125,7 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) lidarDecetionDistance = stoi(args[0]); // TODO distance de detection proportionnelle a la vitesse - if (lidarDecetionDistance < 300) { + if (lidarDecetionDistance < 400) { stopEmergency = true; this->lidarDectectionAngle = stod(args[1]) / 100; @@ -154,7 +154,7 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) else if (client.name == "lidar") { this->broadcastMessage("strat;lidar;start;1\n"); this->broadcastMessage("strat;lidar;set table;0\n"); - this->broadcastMessage("strat;lidar;set range;300\n"); + this->broadcastMessage("strat;lidar;set range;400\n"); this->broadcastMessage("strat;gc;nonvalid borne;2000\n"); lidarSocket = clientSocket; } @@ -186,7 +186,8 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } } else if (value == 0) { - angle = 0; + this->broadcastMessage("strat;arduino;clear;1\n"); + return; } else { if (value > 0) { @@ -217,7 +218,8 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) speed = static_cast(Modelec::mapValue(value, -25000.0, -4000.0, -310.0, -70.0)); } } else if (value == 0) { - speed = 0; + this->broadcastMessage("strat;arduino;clear;1\n"); + return; } else { if (value > 25000) { speed = 310; @@ -284,6 +286,7 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } else if (tokens[3] == "12") { this->alertLidar = false; + this->handleEmergencyFlag = false; this->broadcastMessage("strat;gc;stop proximity alert;1\n"); } else if (tokens[3] == "13") {