From 402e46b001917d45baff7d005c7f817cbc6cd9d1 Mon Sep 17 00:00:00 2001 From: Paul-Winpenny <92634321+Paul-Winpenny@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:30:21 +0000 Subject: [PATCH] This should now be all that is needed. --- App/RobobinApp/Networking/WifiManager.cs | 2 +- .../ViewModels/MainPageViewModel.cs | 2 +- .../launch/robobin_no_components_launch.py | 9 +---- ros2/src/robobin/robobin/api_node.py | 38 ++----------------- .../robobin/helpers/connection_manager.py | 4 +- 5 files changed, 8 insertions(+), 47 deletions(-) diff --git a/App/RobobinApp/Networking/WifiManager.cs b/App/RobobinApp/Networking/WifiManager.cs index ac5bd3c6..18631f5b 100644 --- a/App/RobobinApp/Networking/WifiManager.cs +++ b/App/RobobinApp/Networking/WifiManager.cs @@ -227,7 +227,7 @@ namespace RobobinApp.Networking Debug.WriteLine("Connected to Robobin via TCP."); _isConnected = true; - await SendMessageAsync("REQMAP"); + //await SendMessageAsync("REQMAP"); Task.Run(() => ReceiveMessages()); diff --git a/App/RobobinApp/ViewModels/MainPageViewModel.cs b/App/RobobinApp/ViewModels/MainPageViewModel.cs index 52c0b7a0..8ccf1491 100644 --- a/App/RobobinApp/ViewModels/MainPageViewModel.cs +++ b/App/RobobinApp/ViewModels/MainPageViewModel.cs @@ -98,7 +98,7 @@ namespace RobobinApp.ViewModels private async Task GetNewGraph() { - await App.WifiManager.SendMessageAsync("REQMAP"); + return; } public static (float magnitude, float angle)[,] CalculatePolarConnections(List<Node> nodes, bool[,] connections) diff --git a/ros2/src/robobin/launch/robobin_no_components_launch.py b/ros2/src/robobin/launch/robobin_no_components_launch.py index cea86516..256a27f2 100644 --- a/ros2/src/robobin/launch/robobin_no_components_launch.py +++ b/ros2/src/robobin/launch/robobin_no_components_launch.py @@ -13,14 +13,7 @@ def generate_launch_description(): emulate_tty=True ), - - Node( - package='robobin', - executable='uwb_navigation_node', - name='uwb_navigation_node', - output='screen', - emulate_tty=True - ), + Node( package='robobin', executable='motor_control_node', diff --git a/ros2/src/robobin/robobin/api_node.py b/ros2/src/robobin/robobin/api_node.py index 2f05d138..eff4027c 100644 --- a/ros2/src/robobin/robobin/api_node.py +++ b/ros2/src/robobin/robobin/api_node.py @@ -51,46 +51,14 @@ class ApiNode(Node): if self.mode == "Call": if len(self.called_locations) > 0: self.get_logger().info("Handling queue operations...") - start_node = self.getNearestNode(self.connection_manager.location) client_socket, end_location = self.called_locations[0] - self.get_logger().info(f"(Start Node: {start_node}, End Location: {end_location})") + self.get_logger().info(f" End Location: {end_location})") # self.get_logger().info(f"Sending location: {end_location}") - self.publisher_topics["nav_command"].publish(String(data="CALL " + start_node + " " + end_location)) + - def getNearestNode(self, location): - """ - Return the name of the node nearest to the given (x, y) location. - """ - workspace_root = os.getcwd() # Current working directory - self.get_logger().info(f"Workspace root: {workspace_root}") - graph_file_path = os.path.abspath(os.path.join(workspace_root, "src", "robobin", "robobin", "graphs", "graph.json")) - self.get_logger().info(f"Graph file path: {graph_file_path}") - if not os.path.exists(graph_file_path): - self.get_logger().error(f"Graph file not found at: {graph_file_path}") - return None - - x_loc, y_loc = location - try: - with open(graph_file_path, 'r') as f: - graph_data = json.load(f) - - closest_node_name = None - closest_distance = float('inf') - - for node in graph_data["nodes"]: - x_node = node["x"] - y_node = node["y"] - dist = math.sqrt((x_node - x_loc)**2 + (y_node - y_loc)**2) - if dist < closest_distance: - closest_distance = dist - closest_node_name = node["name"] - - return closest_node_name - except Exception as e: - self.get_logger().error(f"Failed to determine nearest node: {str(e)}") - return None + def handle_client_connection(self, client_socket): """Handles incoming TCP client connections.""" try: diff --git a/ros2/src/robobin/robobin/helpers/connection_manager.py b/ros2/src/robobin/robobin/helpers/connection_manager.py index a2498443..769a5969 100644 --- a/ros2/src/robobin/robobin/helpers/connection_manager.py +++ b/ros2/src/robobin/robobin/helpers/connection_manager.py @@ -69,8 +69,8 @@ class ConnectionManager: # Send the JSON message over UDP sock.sendto(json_message, (self.UDP_IP, self.UDP_PORT)) - self.api_node.get_logger().info("Broadcasting JSON presence.") - self.api_node.get_logger().info(f"Location: {self.location}, Mode: {mode}") + # self.api_node.get_logger().info("Broadcasting JSON presence.") + # self.api_node.get_logger().info(f"Location: {self.location}, Mode: {mode}") time.sleep(0.5) except OSError: break -- GitLab