Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

機械学習の人に人気なLeRobot So101を作ってみる その2:環境構築

実際のところ

Ubuntu24.04LTS上のdistroboxに構築する流れでやります

distrobox環境の構築

ミニPC等専用環境つくる方はこの手順は飛ばしてもOK

あとでttyACMにも接続するので、対応デバイスの設定をお忘れなく

$ distrobox create --name lerobotbox --image ubuntu:22.04 \
  --additional-flags "--device=/dev/ttyACM0:/dev/ttyACM0"
$ distrobox enter lerobotbox

コンテナに入ったら、以下のコマンドでボックスから実行できるように
このとき打つパスはdistroboxのヤツなので注意

$ sudo usermod -a -G dialout $USER

いつも通り、まずはシステムパッケージの更新

$ sudo apt update && sudo apt upgrade -y

今回必要なパッケージのインストール

$ sudo apt install -y git python3 python3-pip build-essential curl wget

minicondaの環境構築

何かと魔境になりがちなPython環境なので、lerobot公式の手順にしたがってminicondaで環境分離を試みます

$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3

# PATHに追加

$ echo 'export PATH="$HOME/miniconda3/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

minicondaの初期化

$ conda init bash
$ source ~/.bashrc

lerobotの環境構築

いよいよお待ちかね、lerobotの環境構築です

$ cd $HOME
$ git clone https://github.com/huggingface/lerobot.git
$ cd lerobot
$ conda create -y -n lerobot python=3.10
$ source ~/.bashrc
$ cd lerobot && pip install -e ".[feetech]"

ACM0に実行権限

$ sudo chmod 666 /dev/ttyACM0

モーターの接続

wiki.seeedstudio.com

モーターを繋いだ状態で

$ cd ~/lerobot/
$ python3 lerobot/scripts/find_motors_bus_port.py

モーターIDの設定

python3 lerobot/scripts/configure_motor.py \
  --port /dev/ttyACM0 \
  --brand feetech \
  --model sts3215 \
  --baudrate 1000000 \
  --ID 1

以降、モーター線を抜き差ししてIDを軸ごとに設定

フォロワーアームは6個すべてが 1/345 (C001)型

リーダーアームの設定順は

Base / Shoulder Yaw 1 1 / 191(C044)
Shoulder Pitch 2 1 / 345(C001)
Elbow 3 1 / 191(C044)
Wrist Roll 4 1 / 147(C046)
Wrist Pitch 5 1 / 147(C046)
Gripper 6 1 / 147(C046)