diff --git a/TCPServer.cpp b/TCPServer.cpp index 9bb9d63..483abfa 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -287,7 +287,9 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } else 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->setPosition(this->robotPose, lidarSocket); + if (!awaitForLidar) { + this->setPosition(this->robotPose, lidarSocket); + } } } else if (tokens[2] == "test aruco") { int pince = std::stoi(tokens[3]); @@ -664,13 +666,13 @@ void TCPServer::goToAruco(const ArucoTag &arucoTag, const int pince) { switch (pince) { case 0: - decalage = 85; + decalage = 75; break; case 1: decalage = 0; break; case 2: - decalage = -85; + decalage = -75; break; default: decalage = 0; @@ -741,7 +743,7 @@ void TCPServer::awaitRobotIdle() { } } -void TCPServer::handleArucoTag(ArucoTag &tag) { +void TCPServer::handleArucoTag(const ArucoTag &tag) { if (!TCPUtils::contains(tag.name(), "flower")) { return; } @@ -766,8 +768,8 @@ void TCPServer::handleArucoTag(ArucoTag &tag) { this->arucoTags.push_back(tag); } -std::optional TCPServer::getBiggestArucoTag(float borneMinX, float borneMaxX, float borneMinY, - float borneMaxY) { +std::optional TCPServer::getBiggestArucoTag(const float borneMinX, const float borneMaxX, const float borneMinY, + const float borneMaxY) { bool found = false; ArucoTag biggestTag = ArucoTag(); for (const auto & tag : arucoTags) { @@ -781,7 +783,7 @@ std::optional TCPServer::getBiggestArucoTag(float borneMinX, float bor } -std::optional TCPServer::getMostCenteredArucoTag(float borneMinX, float borneMaxX, float borneMinY, float borneMaxY) { +std::optional TCPServer::getMostCenteredArucoTag(const float borneMinX, const float borneMaxX, const float borneMinY, const float borneMaxY) { bool found = false; ArucoTag mostCenteredTag = ArucoTag(); for (const auto & tag : arucoTags) { @@ -827,7 +829,7 @@ void TCPServer::handleEmergency(int distance, double angle) { this->gameThread.detach(); } -void TCPServer::startTestAruco(int pince) { +void TCPServer::startTestAruco(const int pince) { this->arucoTags.clear(); std::optional tag = std::nullopt; @@ -1000,7 +1002,7 @@ void TCPServer::dropPurpleFlowers() { this->baisserBras(); - for (auto & toDrop : pinceHavePurpleFlower) { + for (const auto & toDrop : pinceHavePurpleFlower) { this->openPince(toDrop); usleep(200'000); @@ -1023,7 +1025,7 @@ void TCPServer::dropPurpleFlowers() { this->setSpeed(200); } -void TCPServer::dropWhiteFlowers(StratPattern sp) { +void TCPServer::dropWhiteFlowers(const StratPattern sp) { std::vector pinceHaveWhiteFlower; pinceHaveWhiteFlower.reserve(3); @@ -1138,7 +1140,7 @@ void TCPServer::dropWhiteFlowers(StratPattern sp) { this->transportBras(); } -void TCPServer::goAndTurnSolarPanel(StratPattern sp) { +void TCPServer::goAndTurnSolarPanel(const StratPattern sp) { int previousSpeed = this->speed; this->setSpeed(200); if (team == BLUE) { @@ -1224,7 +1226,7 @@ void TCPServer::goAndTurnSolarPanel(StratPattern sp) { this->setSpeed(previousSpeed); } -void TCPServer::checkpoint(StratPattern sp) { +void TCPServer::checkpoint(const StratPattern sp) { this->setSpeed(200); if (team == BLUE) { switch (sp) { @@ -1276,7 +1278,7 @@ void TCPServer::getLidarPos() { // ReSharper disable once CppDFAConstantConditions // ReSharper disable once CppDFAEndlessLoop while (awaitForLidar) { - usleep(200'000); + usleep(100'000); } // ReSharper disable once CppDFAUnreachableCode diff --git a/TCPServer.h b/TCPServer.h index 9ac90a7..48f1e16 100644 --- a/TCPServer.h +++ b/TCPServer.h @@ -112,15 +112,12 @@ private: TAKE_FLOWER_BOTTOM, TAKE_FLOWER_BOTTOM, CHECKPOINT_BOTTOM_TO_TOP, - // DROP_FLOWER, DROP_PURPLE_FLOWER, DROP_WHITE_FLOWER_J1, // GET_LIDAR_POS, TAKE_FLOWER_TOP, TAKE_FLOWER_TOP, TAKE_FLOWER_TOP, - // GET_LIDAR_POS, - // DROP_FLOWER, DROP_PURPLE_FLOWER, DROP_WHITE_FLOWER_J2, // GET_LIDAR_POS, @@ -186,7 +183,7 @@ public: void awaitRobotIdle(); - void handleArucoTag(ArucoTag &tag); + void handleArucoTag(const ArucoTag &tag); std::optional getBiggestArucoTag(float borneMinX, float borneMaxX, float borneMinY, float borneMaxY);