From 8a6a2c80acdab8fe3f876ebb0d375697b1ed6599 Mon Sep 17 00:00:00 2001 From: Paul-Winpenny <92634321+Paul-Winpenny@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:54:22 +0000 Subject: [PATCH] Explicit cast to float --- ros2/src/robobin/robobin/message_handler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ros2/src/robobin/robobin/message_handler.py b/ros2/src/robobin/robobin/message_handler.py index 01adeb4d..dd41cdbf 100644 --- a/ros2/src/robobin/robobin/message_handler.py +++ b/ros2/src/robobin/robobin/message_handler.py @@ -50,14 +50,21 @@ class MessageHandler: "S": (-0.5, 0), # Move backward "D": (0, -0.5) # Turn right } - response_data = directions.get(message.strip().upper(), (0, 0)) + + # Get direction data and ensure it's a tuple of floats + raw_response_data = directions.get(message.strip().upper(), (0, 0)) + response_data = (float(raw_response_data[0]), float(raw_response_data[1])) # Explicitly cast to float + + # Send feedback to the client response = f"Manual control command received: {response_data}".encode() if self.testing: print(response.decode()) else: client_socket.sendall(response) + print("Processed manual control command:", response_data) return "cmd_vel", response_data + def handle_unknown_message(self, client_socket, _): """Handles unknown commands.""" -- GitLab