Skip to content

Commit

Permalink
Little improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Jan 27, 2025
1 parent 6b993c4 commit 60574c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/nanosaur/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def docker_info(platform):
print(f"{TerminalFormatter.color_text(' Docker compose:', bold=True)} {TerminalFormatter.color_text('not installed', color='red', bold=True)}")

if version := check_nvidia_container_cli():
print(f"{TerminalFormatter.color_text(' Nvidia container:', bold=True)} {version}")
print(f"{TerminalFormatter.color_text(' NVIDIA container:', bold=True)} {version}")
else:
print(f"{TerminalFormatter.color_text(' Nvidia container:', bold=True)} {TerminalFormatter.color_text('not installed', color='red', bold=True)}")
print(f"{TerminalFormatter.color_text(' NVIDIA container:', bold=True)} {TerminalFormatter.color_text('not installed', color='red', bold=True)}")


def is_docker_installed():
Expand Down
6 changes: 3 additions & 3 deletions src/nanosaur/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,19 @@ def main():
parser_workspace = parser_workspace_menu(subparsers)

# Subcommand: simulation (with a sub-menu for simulation types)
if device_type == 'desktop' and 'mode' in params:
if device_type == 'desktop':
# Add simulation subcommand
parser_simulation = parser_simulation_menu(subparsers, params)

# Add robot subcommand
parser_robot, parser_config = parser_robot_menu(subparsers, params)
parser_robot, parser_config = parser_robot_menu(platform, subparsers, params)

if device_type == 'desktop':
# Subcommand: swarm (with a sub-menu for swarm operations)
parser_swarm = parser_swarm_menu(subparsers, params)

# Subcommand: wakeup (with a sub-menu for wakeup operations)
if 'mode' in params and 'robots' in params:
if 'robots' in params:
robot_control(params, subparsers)

# Enable tab completion
Expand Down
12 changes: 7 additions & 5 deletions src/nanosaur/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
logger = logging.getLogger(__name__)


def add_robot_config_subcommands(subparsers: argparse._SubParsersAction, params: Params) -> argparse.ArgumentParser:
def add_robot_config_subcommands(platform, subparsers: argparse._SubParsersAction, params: Params) -> argparse.ArgumentParser:
# Get the robot data
robot_data = RobotList.current_robot(params)
parser_robot_config = subparsers.add_parser('config', help=f"Configure the robot settings [{robot_data.name}]")
Expand All @@ -51,8 +51,10 @@ def add_robot_config_subcommands(subparsers: argparse._SubParsersAction, params:
parser_robot_domain_id = config_subparsers.add_parser('domain_id', help=f"Set robot domain ID [{robot_data.domain_id}]")
parser_robot_domain_id.set_defaults(func=robot_set_domain_id)
# Add robot simulation subcommand
parser_robot_simulation = config_subparsers.add_parser('simulation', help=f"Set robot real or simulation [{'simulation' if robot_data.simulation else 'real'}]")
parser_robot_simulation.set_defaults(func=robot_set_simulation)
device_type = "robot" if platform['Machine'] == 'aarch64' else "desktop"
if device_type == 'desktop':
parser_robot_simulation = config_subparsers.add_parser('simulation', help=f"Set robot real or simulation [{'simulation' if robot_data.simulation else 'real'}]")
parser_robot_simulation.set_defaults(func=robot_set_simulation)
# Add robot camera subcommand
parser_robot_camera = config_subparsers.add_parser('camera', help=f"Set robot camera type [{robot_data.camera_type or 'NOT SELECTED'}]")
parser_robot_camera.add_argument('--new', type=str, help=f"Specify the new camera type (options: {', '.join(CAMERA_CHOICES)})")
Expand All @@ -73,7 +75,7 @@ def add_robot_config_subcommands(subparsers: argparse._SubParsersAction, params:
return parser_robot_config


def parser_robot_menu(subparsers: argparse._SubParsersAction, params: Params) -> argparse.ArgumentParser:
def parser_robot_menu(platform, subparsers: argparse._SubParsersAction, params: Params) -> argparse.ArgumentParser:
try:
robot_data = RobotList.current_robot(params)
parser_robot = subparsers.add_parser('robot', help=f"Manage the Nanosaur robot [{robot_data.name}]")
Expand All @@ -96,7 +98,7 @@ def parser_robot_menu(subparsers: argparse._SubParsersAction, params: Params) ->
parser_robot_stop.set_defaults(func=docker.docker_robot_stop)

# Add robot config subcommand
parser_config = add_robot_config_subcommands(robot_subparsers, params)
parser_config = add_robot_config_subcommands(platform, robot_subparsers, params)

return parser_robot, parser_config
except IndexError:
Expand Down

0 comments on commit 60574c1

Please sign in to comment.