diff --git a/src/nanosaur/main.py b/src/nanosaur/main.py index 55cfcd6..687f023 100644 --- a/src/nanosaur/main.py +++ b/src/nanosaur/main.py @@ -81,7 +81,8 @@ def info(platform, params: Params, args): if ws_path := workspace.get_workspace_path( params, params.get(ws_name) ): - print(f" {TerminalFormatter.color_text(ws_name, bold=True)}: {ws_path}") + ws_name_split = ws_name.split('_')[1] # Split and get the middle part + print(f" {TerminalFormatter.color_text(ws_name_split, bold=True)}: {ws_path}") # Print all robot configurations if args.verbose: diff --git a/src/nanosaur/simulation.py b/src/nanosaur/simulation.py index bde13d0..1a16712 100644 --- a/src/nanosaur/simulation.py +++ b/src/nanosaur/simulation.py @@ -52,11 +52,15 @@ def start_robot_simulation(params): command = simulation_tools[params['simulation_tool']]['robot'] # Load the robot configuration robot = RobotList.get_robot(params) - print(TerminalFormatter.color_text(f"Starting {robot.name} ID={robot.domain_id}", color='green')) + print(TerminalFormatter.color_text(f"Starting {robot}", color='green')) + + # Print the command to be run + print(f"ROS_DOMAIN_ID={robot.domain_id} {command} {robot.config_to_ros()}") + try: # Combine sourcing the bash file with running the command process = subprocess.Popen( - f"source {bash_file} && ROS_DOMAIN_ID={robot.domain_id} {command} namespace:={robot.name}", + f"source {bash_file} && ROS_DOMAIN_ID={robot.domain_id} {command} {robot.config_to_ros()}", shell=True, executable="/bin/bash", stdout=subprocess.PIPE, diff --git a/src/nanosaur/utilities.py b/src/nanosaur/utilities.py index 9bbde74..353e6cb 100644 --- a/src/nanosaur/utilities.py +++ b/src/nanosaur/utilities.py @@ -33,13 +33,13 @@ DEFAULT_ROBOT_CONFIG = { 'name': 'nanosaur', 'domain_id': 0, - 'camera': '', - 'lidar': '', + 'camera_type': '', + 'lidar_type': '', 'engines': [], } CAMERA_CHOICES = ['', 'realsense', 'zed'] -LIDAR_CHOICES = ['', 'rplidar'] +LIDAR_CHOICES = ['', 'LD06', 'rplidar'] ENGINES_CHOICES = ['vlslam', 'nvblox', 'apriltag'] @@ -59,13 +59,23 @@ def __init__(self, robot_config=None, name=None): setattr(self, key, value) def __repr__(self): - # "Nanosaur[DID=](cover=AAA, )" attributes = ', '.join(f"{key}={value}" for key, value in self.__dict__.items() if key not in ['name', 'domain_id'] and value) - return f"{self.name}[DID={self.domain_id}] {attributes}" + return f"{self.name}[DID={self.domain_id}]({attributes})" def to_dict(self) -> dict: return self.__dict__ + def config_to_ros(self) -> str: + ros_params = [] + for key, value in self.__dict__.items(): + if key == 'domain_id' or not value: + continue + param_name = 'robot_name' if key == 'name' else key + if isinstance(value, list): + value = f'"[{", ".join(value)}]"' + ros_params.append(f"{param_name}:={value}") + return ' '.join(ros_params) + def verbose(self): """Print the robot configuration.""" print(TerminalFormatter.color_text("Robot:", bold=True))