From 7c9bac5d57081b5892a74bb92088c35ee4b31eea Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Tue, 30 Sep 2025 11:05:59 -0500 Subject: [PATCH 1/8] Fix: Removed Optional for IP and PORT in connect_to_robot. This sometimes generates truncation, no need for optional as they are intrinsically optional. --- .gitignore | 5 ++++- server.py | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 92025d1..3220b7a 100644 --- a/.gitignore +++ b/.gitignore @@ -178,4 +178,7 @@ pyrightconfig.json .vs/ # camera -/camera/* +camera/* + +# tests +tests/ \ No newline at end of file diff --git a/server.py b/server.py index eb59097..faba691 100644 --- a/server.py +++ b/server.py @@ -79,8 +79,8 @@ def list_verified_robot_specifications() -> dict: ) ) def connect_to_robot( - ip: Optional[str] = None, - port: Optional[Union[int, str]] = None, + ip: str = ROSBRIDGE_IP, + port: Union[int, str] = ROSBRIDGE_PORT, ping_timeout: float = 2.0, port_timeout: float = 2.0, ) -> dict: @@ -88,8 +88,8 @@ def connect_to_robot( Connect to a robot by setting the IP and port for the WebSocket connection, then testing connectivity. Args: - ip (Optional[str]): The IP address of the rosbridge server. Defaults to "127.0.0.1" (localhost). - port (Optional[int]): The port number of the rosbridge server. Defaults to 9090. + ip (str): The IP address of the rosbridge server. Defaults to "127.0.0.1" (localhost). + port (int): The port number of the rosbridge server. Defaults to 9090. ping_timeout (float): Timeout for ping in seconds. Default = 2.0. port_timeout (float): Timeout for port check in seconds. Default = 2.0. @@ -97,8 +97,8 @@ def connect_to_robot( dict: Connection status with ping and port check results. """ # Set default values if None - actual_ip = ip if ip is not None else "127.0.0.1" - actual_port = int(port) if port is not None else 9090 + actual_ip = str(ip).strip() if ip else ROSBRIDGE_IP + actual_port = int(port) if port else ROSBRIDGE_PORT # Set the IP and port ws_manager.set_ip(actual_ip, actual_port) From 131fae49a48919a9026ac580d9f4ab9e321bd8ce Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Wed, 24 Sep 2025 20:14:23 -0500 Subject: [PATCH 2/8] Added ip and port information on config yaml file --- utils/config_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/config_utils.py b/utils/config_utils.py index 8365f64..b85faaf 100644 --- a/utils/config_utils.py +++ b/utils/config_utils.py @@ -47,12 +47,12 @@ def parse_robot_config(name: str, specs_dir: str = "utils/robot_specifications") raise ValueError(f"No configuration found for robot '{name}'") # Check required fields - for field in ("type", "prompts"): + for field in ("type", "ip", "port", "prompts"): if field not in config or config[field] in (None, ""): raise ValueError(f"Robot '{name}' is missing required field: {field}") # Create configuration with robot name as key - parsed_config[name] = {"type": config["type"], "prompts": config["prompts"]} + parsed_config[name] = {"type": config["type"], "ip": config["ip"], "port": config["port"], "prompts": config["prompts"]} return parsed_config From e4e80ab892efb67a86648b69c502275c4a587283 Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Wed, 24 Sep 2025 20:19:36 -0500 Subject: [PATCH 3/8] Added turtlesim.yaml --- utils/robot_specifications/local_turtlesim.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 utils/robot_specifications/local_turtlesim.yaml diff --git a/utils/robot_specifications/local_turtlesim.yaml b/utils/robot_specifications/local_turtlesim.yaml new file mode 100644 index 0000000..c8459d7 --- /dev/null +++ b/utils/robot_specifications/local_turtlesim.yaml @@ -0,0 +1,15 @@ +# Robot configuration template +# Replace this text with specific instructions and information about your robot. +# Include details on how to control it, important topics, and any special commands. +# For example: +# - Control commands (e.g., movement, actions) +# - Sensor topics (e.g., camera, lidar) +# - Safety guidelines +# - Any custom messages or services used by the robot + +name: local_turtlesim +ip: 127.0.0.1 +port: 9090 +alias: turtlesim # Optional alias for easier reference +type: sim # or 'real' for simulation +prompts: The local_turtlesim is a generic local turtlesim robot. From d545486de53a3f6e09d177e42e195c6c195fcfff Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Tue, 30 Sep 2025 11:08:09 -0500 Subject: [PATCH 4/8] ruff format fix --- utils/config_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/config_utils.py b/utils/config_utils.py index b85faaf..feb7b53 100644 --- a/utils/config_utils.py +++ b/utils/config_utils.py @@ -52,7 +52,12 @@ def parse_robot_config(name: str, specs_dir: str = "utils/robot_specifications") raise ValueError(f"Robot '{name}' is missing required field: {field}") # Create configuration with robot name as key - parsed_config[name] = {"type": config["type"], "ip": config["ip"], "port": config["port"], "prompts": config["prompts"]} + parsed_config[name] = { + "type": config["type"], + "ip": config["ip"], + "port": config["port"], + "prompts": config["prompts"], + } return parsed_config From ebd64b58a52c58ae414d79727f82bf2a7ce37c42 Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Tue, 30 Sep 2025 11:09:45 -0500 Subject: [PATCH 5/8] Added configuration file for local_rosbridge.yaml --- .../{local_turtlesim.yaml => local_rosbridge.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename utils/robot_specifications/{local_turtlesim.yaml => local_rosbridge.yaml} (83%) diff --git a/utils/robot_specifications/local_turtlesim.yaml b/utils/robot_specifications/local_rosbridge.yaml similarity index 83% rename from utils/robot_specifications/local_turtlesim.yaml rename to utils/robot_specifications/local_rosbridge.yaml index c8459d7..706f9c5 100644 --- a/utils/robot_specifications/local_turtlesim.yaml +++ b/utils/robot_specifications/local_rosbridge.yaml @@ -7,9 +7,9 @@ # - Safety guidelines # - Any custom messages or services used by the robot -name: local_turtlesim +name: local_rosbridge ip: 127.0.0.1 port: 9090 alias: turtlesim # Optional alias for easier reference type: sim # or 'real' for simulation -prompts: The local_turtlesim is a generic local turtlesim robot. +prompts: The local_rosbridge is a generic local turtlesim robot. From 012bab47d4a432027669ee6c7dc499f56890633c Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Tue, 30 Sep 2025 11:31:47 -0500 Subject: [PATCH 6/8] trigger ruff check From 254aee8566b384d9c8b8d96b2b11f8072eddd137 Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Tue, 30 Sep 2025 14:57:53 -0500 Subject: [PATCH 7/8] Revert "Added ip and port information on config yaml file" This reverts commit 131fae49a48919a9026ac580d9f4ab9e321bd8ce. --- utils/config_utils.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/utils/config_utils.py b/utils/config_utils.py index feb7b53..8365f64 100644 --- a/utils/config_utils.py +++ b/utils/config_utils.py @@ -47,17 +47,12 @@ def parse_robot_config(name: str, specs_dir: str = "utils/robot_specifications") raise ValueError(f"No configuration found for robot '{name}'") # Check required fields - for field in ("type", "ip", "port", "prompts"): + for field in ("type", "prompts"): if field not in config or config[field] in (None, ""): raise ValueError(f"Robot '{name}' is missing required field: {field}") # Create configuration with robot name as key - parsed_config[name] = { - "type": config["type"], - "ip": config["ip"], - "port": config["port"], - "prompts": config["prompts"], - } + parsed_config[name] = {"type": config["type"], "prompts": config["prompts"]} return parsed_config From eb007215907fcdacc269aae78ba67fc4f7599e10 Mon Sep 17 00:00:00 2001 From: Stefano Dalla Gasperina Date: Tue, 30 Sep 2025 14:58:25 -0500 Subject: [PATCH 8/8] Removed ip/port --- utils/robot_specifications/local_rosbridge.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/robot_specifications/local_rosbridge.yaml b/utils/robot_specifications/local_rosbridge.yaml index 706f9c5..d911e8d 100644 --- a/utils/robot_specifications/local_rosbridge.yaml +++ b/utils/robot_specifications/local_rosbridge.yaml @@ -8,8 +8,6 @@ # - Any custom messages or services used by the robot name: local_rosbridge -ip: 127.0.0.1 -port: 9090 alias: turtlesim # Optional alias for easier reference type: sim # or 'real' for simulation prompts: The local_rosbridge is a generic local turtlesim robot.