diff --git a/Wireless_Communication/RPi_Wifi/WifiControllerRPi.py b/Wireless_Communication/RPi_Wifi/WifiControllerRPi.py index 0fd7b315ed659f7655074e687615b745fa08b17c..94c4861b3209469970d53bddba1d00a427846be1 100644 --- a/Wireless_Communication/RPi_Wifi/WifiControllerRPi.py +++ b/Wireless_Communication/RPi_Wifi/WifiControllerRPi.py @@ -33,7 +33,8 @@ class RoboBinConnectionHandler: "CALLOVER": self.handle_call_over, "CUSTOM": self.handle_custom_message, "REQUEST_MAP": self.handle_request_map, - "SET_LAYOUT": self.handle_set_layout + "SET_LAYOUT": self.handle_set_layout, + "MANUALCTRL": self.handle_manual_control } @@ -112,15 +113,25 @@ class RoboBinConnectionHandler: print(f"Loaded map '{self.current_layout}' successfully.") return map_data - # Attempt to load the default layout if the specified layout is missing map_data = self.load_layout(self.default_layout) if map_data: print(f"Specified layout not found. Loaded default layout '{self.default_layout}'.") return map_data - # Both the specified and default layouts are missing print("Error: Neither specified nor default layout found.") return None + def handle_manual_control(self, client_socket, message): + directions = { + "W": (1,0,0), + "A": (0,0,1), + "S": (-1,0,0), + "D": (0,0,-1) + } + print("Manual control message received: {}".format(message)) + #EIther W,A,S,D + #Format into cmd_vel(linear,angular) for ros2 node + response = b"Manual control message received."+ str(directions[message.decode()[0]]) + print("Sending response to manual control message.") def handle_request_map(self, client_socket, _): """