#!/usr/bin/env bash # Source this file to activate the project's LeRobot environment. if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then echo "This script must be sourced so it can update the current shell:" >&2 echo " source env/activate_lerobot.sh" >&2 exit 1 fi LEROBOT_PROJECT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" LEROBOT_VENV="${ROBOT_WORKDIR:-${HOME}/robot}/.venv-lerobot-0.6.1" if [[ ! -f "$LEROBOT_VENV/bin/activate" ]]; then echo "LeRobot environment not found: $LEROBOT_VENV" >&2 echo "Install it first with: bash $LEROBOT_PROJECT_DIR/env/setup_lerobot.sh" >&2 return 1 fi # shellcheck disable=SC1091 source "$LEROBOT_VENV/bin/activate" export LEROBOT_PROJECT_DIR export FOLLOWER_PORT="/dev/serial/by-id/usb-1a86_USB_Single_Serial_5B91044223-if00" export LEADER_PORT="/dev/serial/by-id/usb-1a86_USB_Single_Serial_5B8E115693-if00" cd "$LEROBOT_PROJECT_DIR" || return 1 show_lerobot_port() { local role="$1" local stable_path="$2" local current_device if [[ -e "$stable_path" ]]; then current_device="$(readlink -f -- "$stable_path")" echo "$role: $stable_path -> $current_device" else echo "$role: $stable_path (not connected)" fi } echo "LeRobot environment activated: $VIRTUAL_ENV" echo "Project: $LEROBOT_PROJECT_DIR" show_lerobot_port "Follower" "$FOLLOWER_PORT" show_lerobot_port "Leader " "$LEADER_PORT" unset -f show_lerobot_port