From f1c791157330d5c861dc2f398be1805c74d93a62 Mon Sep 17 00:00:00 2001 From: Raffaello Bonghi Date: Mon, 27 Jan 2025 17:13:02 +0000 Subject: [PATCH] general fix for Jetson device --- src/nanosaur/docker.py | 8 +++---- src/nanosaur/main.py | 7 ++++--- src/nanosaur/robot.py | 4 ++-- src/nanosaur/simulation.py | 2 +- src/nanosaur/utilities.py | 2 +- src/nanosaur/workspace.py | 43 +++++++++++++++++++++++--------------- 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/nanosaur/docker.py b/src/nanosaur/docker.py index 9742275..998de4d 100644 --- a/src/nanosaur/docker.py +++ b/src/nanosaur/docker.py @@ -97,7 +97,7 @@ def docker_service_run_command(platform, params: Params, service, command=None, command = [] if volumes is None: volumes = [] - workspace_type = "robot" if platform['Machine'] == 'jetson' else "simulation" + workspace_type = "robot" if platform['Machine'] == 'aarch64' else "simulation" docker_compose = f"docker-compose.{workspace_type}.yml" nanosaur_home_path = get_nanosaur_home() # Create the full file path @@ -120,7 +120,7 @@ def docker_service_run_command(platform, params: Params, service, command=None, def docker_robot_start(platform, params: Params, args): """Start the docker container.""" - workspace_type = "robot" if platform['Machine'] == 'jetson' else "simulation" + workspace_type = "robot" if platform['Machine'] == 'aarch64' else "simulation" docker_compose = f"docker-compose.{workspace_type}.yml" nanosaur_home_path = get_nanosaur_home() # Create the full file path @@ -156,7 +156,7 @@ def docker_robot_start(platform, params: Params, args): def docker_simulator_start(platform, params: Params, args): """Start the simulation tools.""" - workspace_type = "robot" if platform['Machine'] == 'jetson' else "simulation" + workspace_type = "robot" if platform['Machine'] == 'aarch64' else "simulation" docker_compose = f"docker-compose.{workspace_type}.yml" nanosaur_home_path = get_nanosaur_home() # Create the full file path @@ -187,7 +187,7 @@ def docker_simulator_start(platform, params: Params, args): def docker_robot_stop(platform, params: Params, args): """Stop the docker container.""" - workspace_type = "robot" if platform['Machine'] == 'jetson' else "simulation" + workspace_type = "robot" if platform['Machine'] == 'aarch64' else "simulation" docker_compose = f"docker-compose.{workspace_type}.yml" nanosaur_home_path = get_nanosaur_home() # Create the full file path diff --git a/src/nanosaur/main.py b/src/nanosaur/main.py index e3f91a4..2dd4862 100644 --- a/src/nanosaur/main.py +++ b/src/nanosaur/main.py @@ -88,7 +88,7 @@ def info(platform, params: Params, args): """Print version information.""" - device_type = "robot" if platform['Machine'] == 'jetson' else "desktop" + device_type = "robot" if platform['Machine'] == 'aarch64' else "desktop" # Print version information package_info(params, args.verbose) # Print mode if it exists in params @@ -161,11 +161,12 @@ def install(platform, params: Params, args): return False # Check if the user wants to continue if answers['confirm'] is False: - print(TerminalFormatter.color_text("Installation cancelled", color='red')) + print(TerminalFormatter.color_text("Installation cancelled", color='yellow')) return False # Get the selected install type print(TerminalFormatter.color_text(f"Installing {install_type} workspace...", bold=True)) if not NANOSAUR_INSTALL_OPTIONS_RULES[install_type]['function'](platform, params, args): + print(TerminalFormatter.color_text(f"Installation of {install_type} failed", color='red')) return False # Set params in maintainer mode current_mode = params.get('mode', 'simple') @@ -211,7 +212,7 @@ def main(): sys.exit(1) # Determine the device type - device_type = "robot" if platform['Machine'] == 'jetson' else "desktop" + device_type = "robot" if platform['Machine'] == 'aarch64' else "desktop" # Create the argument parser parser = argparse.ArgumentParser( diff --git a/src/nanosaur/robot.py b/src/nanosaur/robot.py index be3f8ff..d86e821 100644 --- a/src/nanosaur/robot.py +++ b/src/nanosaur/robot.py @@ -108,9 +108,9 @@ def parser_robot_menu(subparsers: argparse._SubParsersAction, params: Params) -> def wizard(platform, params: Params, args): # Get the device type (robot or desktop) - device_type = "robot" if platform['Machine'] == 'jetson' else "desktop" + device_type = "robot" if platform['Machine'] == 'aarch64' else "desktop" # Build the list of functions to run - functions_list = [robot_set_name] + [robot_set_simulation] if device_type == 'desktop' else [] + functions_list = [robot_set_name] + ([robot_set_simulation] if device_type == 'desktop' else []) functions_list += [robot_set_domain_id, robot_set_camera, robot_set_lidar, robot_configure_engines] # Set new argument to None args.new = None diff --git a/src/nanosaur/simulation.py b/src/nanosaur/simulation.py index 2ecb5c0..399c363 100644 --- a/src/nanosaur/simulation.py +++ b/src/nanosaur/simulation.py @@ -130,7 +130,7 @@ def simulation_info(platform, params: Params, verbose): isaac_sim_version = params['isaac_sim_path'].split("isaac-sim-")[-1] # Extract version after "isaac-sim-" text_message = f"{TerminalFormatter.color_text(' selected:', bold=True)} {params['simulation_tool']} {isaac_sim_version}" print(text_message) - elif platform['Machine'] != 'jetson': + elif platform['Machine'] != 'aarch64': print(TerminalFormatter.color_text(" No simulation tool selected", color='red')) # Check if Isaac Sim is installed diff --git a/src/nanosaur/utilities.py b/src/nanosaur/utilities.py index 979dc06..4d15d8d 100644 --- a/src/nanosaur/utilities.py +++ b/src/nanosaur/utilities.py @@ -426,7 +426,7 @@ def download_file(url, folder_path, file_name, force=False) -> str: logger.debug(TerminalFormatter.color_text(f"File '{file_name}' downloaded successfully to '{folder_path}'.", color='green')) return file_path else: - logger.debug(TerminalFormatter.color_text(f"Failed to download file. Status code: {response.status_code}", color='red')) + print(TerminalFormatter.color_text(f"Failed to download file. Status code: {response.status_code}", color='red')) return None diff --git a/src/nanosaur/workspace.py b/src/nanosaur/workspace.py index 0c2999f..47dd9ad 100644 --- a/src/nanosaur/workspace.py +++ b/src/nanosaur/workspace.py @@ -95,7 +95,8 @@ def ros_info(params): ros2_path = ros.get_ros2_path(ROS_DISTRO) ros2_version_color = TerminalFormatter.color_text(ROS_DISTRO.capitalize(), color='blue', bold=True) ros2_string = TerminalFormatter.color_text(f"ROS 2 {ros2_version_color}:", bold=True) - print(f"{ros2_string} {TerminalFormatter.clickable_link(ros2_path)}") + version = TerminalFormatter.clickable_link(ros2_path) if ros2_path else TerminalFormatter.color_text('Not installed', color='red') + print(f"{ros2_string}: {version}") # Print Isaac ROS installation path isaac_ros_version = params.get('isaac_ros_branch', ISAAC_ROS_RELEASE) isaac_ros_string = TerminalFormatter.color_text("Isaac ROS:", bold=True) @@ -231,6 +232,7 @@ def update_workspace(params, workspace_type, workspace_name_key, force, skip_ros print(TerminalFormatter.color_text(f"Update {workspace_type}.rosinstall", bold=True)) else: print(TerminalFormatter.color_text(f"Failed to download {workspace_type}.rosinstall", color='red')) + return False # run vcs import to sync the workspace if os.path.exists(rosinstall_path): print(TerminalFormatter.color_text(f"Found rosinstall file: {rosinstall_path}", bold=True)) @@ -424,7 +426,7 @@ def deploy_simulation(image_name): def deploy_perception(image_name): """ Deploy the perception workspace """ # determine the device type - device_type = "robot" if platform['Machine'] == 'jetson' else "desktop" + device_type = "robot" if platform['Machine'] == 'aarch64' else "desktop" # Get the path to the perception workspace perception_ws_path = get_workspace_path(params, 'ws_perception_name') # Get the release tag name @@ -572,14 +574,13 @@ def create_simple(platform, params: utilities.Params, args) -> bool: # Store nanosaur distro and Isaac ROS distro params['nanosaur_branch'] = params.get('nanosaur_branch', utilities.NANOSAUR_MAIN_BRANCH) # Determine the device type - workspace_type = "robot" if platform['Machine'] == 'jetson' else "simulation" + workspace_type = "robot" if platform['Machine'] == 'aarch64' else "simulation" docker_compose = f"docker-compose.{workspace_type}.yml" # Get the Nanosaur home folder and branch nanosaur_raw_url = utilities.get_nanosaur_raw_github_url(params) url = f"{nanosaur_raw_url}/nanosaur/compose/{docker_compose}" # Download the docker-compose file - utilities.download_file(url, nanosaur_home_path, docker_compose, force=args.force) - return True + return utilities.download_file(url, nanosaur_home_path, docker_compose, force=args.force) is not None def create_developer_workspace(platform, params: utilities.Params, args, password=None) -> bool: @@ -606,7 +607,7 @@ def create_maintainer_workspace(platform, params: utilities.Params, args, passwo # Check if ROS 2 is installed ros2_installed = ros.get_ros2_path(ROS_DISTRO) # determine the device type - device_type = "robot" if platform['Machine'] == 'jetson' else "desktop" + device_type = "robot" if platform['Machine'] == 'aarch64' else "desktop" # Create the Nanosaur home folder nanosaur_home_path = utilities.create_nanosaur_home() # Store nanosaur distro and Isaac ROS distro @@ -624,6 +625,17 @@ def create_maintainer_workspace(platform, params: utilities.Params, args, passwo # Make the perception workspace create_workspace(nanosaur_home_path, params.get('ws_perception_name', DEFAULT_WORKSPACE_PERCEPTION)) + # set all workspaces to be updated + args.all = True + if args.force: + clean(platform, params, args) + # Update all workspaces + if not update(platform, params, args): + return False + # Build all workspaces + if ros2_installed is not None: + build(platform, params, args) + # Check if docker-compose files exist def handle_docker_compose_file(docker_compose_file): # Check if the docker-compose file exists @@ -634,25 +646,22 @@ def handle_docker_compose_file(docker_compose_file): print(TerminalFormatter.color_text(f"Renamed existing {docker_compose_file} to {old_path}", color='yellow')) # Create a symlink to the new docker-compose file new_path = os.path.join(nanosaur_home_path, 'shared_src', 'nanosaur', 'nanosaur', 'compose', docker_compose_file) + if not os.path.exists(new_path): + print(TerminalFormatter.color_text(f"Could not find {docker_compose_file} in {new_path}", color='red')) + return False if os.path.exists(docker_compose_path): os.remove(docker_compose_path) os.symlink(new_path, docker_compose_path) print(TerminalFormatter.color_text(f"Created symlink for {docker_compose_file} to {new_path}", color='green')) + return True # Check if docker-compose files exist if device_type == "robot" or args.all: - handle_docker_compose_file('docker-compose.robot.yml') + if not handle_docker_compose_file('docker-compose.robot.yml'): + return False if device_type == "desktop" or args.all: - handle_docker_compose_file('docker-compose.simulation.yml') + if not handle_docker_compose_file('docker-compose.simulation.yml'): + return False - # set all workspaces to be updated - args.all = True - if args.force: - clean(platform, params, args) - # Update all workspaces - update(platform, params, args) - # Build all workspaces - if ros2_installed is not None: - build(platform, params, args) return True # EOF