Skip to content
Snippets Groups Projects
Commit 402e46b0 authored by Paul-Winpenny's avatar Paul-Winpenny
Browse files

This should now be all that is needed.

parent db24e845
Branches
No related tags found
No related merge requests found
...@@ -227,7 +227,7 @@ namespace RobobinApp.Networking ...@@ -227,7 +227,7 @@ namespace RobobinApp.Networking
Debug.WriteLine("Connected to Robobin via TCP."); Debug.WriteLine("Connected to Robobin via TCP.");
_isConnected = true; _isConnected = true;
await SendMessageAsync("REQMAP"); //await SendMessageAsync("REQMAP");
Task.Run(() => ReceiveMessages()); Task.Run(() => ReceiveMessages());
......
...@@ -98,7 +98,7 @@ namespace RobobinApp.ViewModels ...@@ -98,7 +98,7 @@ namespace RobobinApp.ViewModels
private async Task GetNewGraph() private async Task GetNewGraph()
{ {
await App.WifiManager.SendMessageAsync("REQMAP"); return;
} }
public static (float magnitude, float angle)[,] CalculatePolarConnections(List<Node> nodes, bool[,] connections) public static (float magnitude, float angle)[,] CalculatePolarConnections(List<Node> nodes, bool[,] connections)
......
...@@ -14,13 +14,6 @@ def generate_launch_description(): ...@@ -14,13 +14,6 @@ def generate_launch_description():
), ),
Node(
package='robobin',
executable='uwb_navigation_node',
name='uwb_navigation_node',
output='screen',
emulate_tty=True
),
Node( Node(
package='robobin', package='robobin',
executable='motor_control_node', executable='motor_control_node',
......
...@@ -51,46 +51,14 @@ class ApiNode(Node): ...@@ -51,46 +51,14 @@ class ApiNode(Node):
if self.mode == "Call": if self.mode == "Call":
if len(self.called_locations) > 0: if len(self.called_locations) > 0:
self.get_logger().info("Handling queue operations...") self.get_logger().info("Handling queue operations...")
start_node = self.getNearestNode(self.connection_manager.location)
client_socket, end_location = self.called_locations[0] 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.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): def handle_client_connection(self, client_socket):
"""Handles incoming TCP client connections.""" """Handles incoming TCP client connections."""
try: try:
......
...@@ -69,8 +69,8 @@ class ConnectionManager: ...@@ -69,8 +69,8 @@ class ConnectionManager:
# Send the JSON message over UDP # Send the JSON message over UDP
sock.sendto(json_message, (self.UDP_IP, self.UDP_PORT)) 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("Broadcasting JSON presence.")
self.api_node.get_logger().info(f"Location: {self.location}, Mode: {mode}") # self.api_node.get_logger().info(f"Location: {self.location}, Mode: {mode}")
time.sleep(0.5) time.sleep(0.5)
except OSError: except OSError:
break break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment