From edf2f4554c2ac411bf3378e12632dc11aef5251d Mon Sep 17 00:00:00 2001
From: Paul-Winpenny <92634321+Paul-Winpenny@users.noreply.github.com>
Date: Thu, 14 Nov 2024 14:36:12 +0000
Subject: [PATCH] Added the manual control changes from the BLE branch, I am
 going to prune that branch.

---
 .../RPi_Wifi/WifiControllerRPi.py               | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/Wireless_Communication/RPi_Wifi/WifiControllerRPi.py b/Wireless_Communication/RPi_Wifi/WifiControllerRPi.py
index 0fd7b315..94c4861b 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, _):
         """
-- 
GitLab