diff --git a/TCPServer.cpp b/TCPServer.cpp index 349e4af..7a35a20 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -165,14 +165,13 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } if (tokens[2] == "get pos") { std::string toSend = "strat;all;set pos;" + std::to_string(this->robotPose.pos.x) + "," + std::to_string(this->robotPose.pos.y) + "," + std::to_string(this->robotPose.theta * 100) + "\n"; - this->broadcastMessage(toSend.c_str(), clientSocket); + this->broadcastMessage(toSend, clientSocket); } if (tokens[2] == "spawn") { // TODO change that to handle spawn point this->robotPose = {500, 500, -1.57079}; std::string toSend = "strat;all;set pos;" + std::to_string(this->robotPose.pos.x) + "," + std::to_string(this->robotPose.pos.y) + "," + std::to_string(this->robotPose.theta * 100) + "\n"; this->broadcastMessage(toSend, clientSocket); - } if (tokens[2] == "start") { @@ -345,6 +344,8 @@ void TCPServer::goToAruco(const ArucoTagPos &arucoTagPos, const int pince) { double x = (xPrime * std::cos(robotPose.theta) + yPrime * std::sin(robotPose.theta)) + this->robotPose.pos.x; double y = (-xPrime * std::sin(robotPose.theta) + yPrime * std::cos(robotPose.theta)) + this->robotPose.pos.y; + std::cout << x << " " << y << std::endl; + toSend = "strat;arduino;go;" + std::to_string(static_cast(x)) + "," + std::to_string(static_cast(y)) + "\n"; this->broadcastMessage(toSend); usleep(3'000'000);