Skip to content

Commit

Permalink
general fix for Jetson device
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Jan 27, 2025
1 parent 54141bf commit f1c7911
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/nanosaur/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/nanosaur/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/nanosaur/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nanosaur/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nanosaur/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
43 changes: 26 additions & 17 deletions src/nanosaur/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit f1c7911

Please sign in to comment.