SO-101 ロボットアームを稼働させる【5】RaspberryPiへの移行
独立した機器かどうかという観点で、パソコンと繋いだ状態でこれ以上進めると不便なことが多い。そこで、ここまでWindowsPCを使ってできるようになったことを、RaspberryPiへ移行することにしました。
RaspberryPiの立ち上げ
キットはRaspberryPi 4 model Bを購入。周辺機器の揃ったキットにしました。RaspberryPiの公式HPのガイドにしたがって、WindowsPC上でmicroSDカードにOS (Raspberry Pi OS 64-bit) を焼き、これをRaspberryPiにセットして起動。特に問題ありませんでした。はるかむかし、FreeBSD時代に外部メディアがないパソコンをネットワーク経由でbootしたのに比べれば(遠い目)
Lerobotのインストール
次にlerobotをインストールしていきます。こちら今回は、公式HPのInstallation guide にしたがって進めました。
:uv python install 3.12
--> 問題なくインストールされた
:uv venv --python 3.12
--> 問題なく.venv/が生成された
:source .venv/bin/activate
--> 問題なく仮想環境に入れた
:sudo apt install ffmpeg
--> 問題なくffmpegがインストールされた
:git clone https://github.com/huggingface/lerobot.git
--> 問題なくlerobotリポジトリがcloneされた
:cd lerobot
--> lerobotフォルダに入った
:uv pip install -e .
--> すべてのモジュールが正常インストールされた
:uv pip install lerobot
--> すべてのlerobot関連モジュールが正常にインストールされたここまでがInstallation guideに従って実施したところで、これに加えてfeeteck SDKのインストールをするようにSO-101のInstallation guideのページに指示があるため、これも実行。
: uv pip install -e ".[feetech]"
--> すべてのモジュールが正常にインストールされたillegal instruction エラーと対策
これで準備が整ったはずで、前回と同様にlerobot-find-portでアームを探そうとしたところ、問題が発生しました。
:lerobot-find-port
Finding all available ports for the MotorsBus.
Illegal instruction
:"Finding ~ "という部分までは正常なのですが、そのあとでillegal instructionと出て止まってしまう。lerobot-info, lerobot-calibrate, lerobot-replayなど試してもすべてIllegal instructionと出てしまうため、正常に動きません。これはなんだ。
chatGPTが知ったかぶりモードに入ってしまったため、HuggingFaceのHPでdocumentを探そうとしたところ(下の窓枠)、AIのchatbotが対応するのでsing inしなされ的な案内があり、accountを作って質問をしました。

結果的に、回答が的確だったので大変助かりました。CPUが命令を受けつけていないときに発生するもので、よくあるトラブルとのこと(↓)。
The "Illegal instruction" error typically indicates that your CPU doesn't support certain instruction sets required by the compiled libraries that LeRobot depends on. This is often related to SIMD (Single Instruction, Multiple Data) extensions like AVX, AVX2, or SSE4.
Based on my research, the "Illegal instruction" error you're experiencing is a common issue with LeRobot and PyTorch on older CPUs. Here's what's happening and how to fix it:
で、以下のコマンドでavx, avx2というのがgrepされなかったらそうだろう
First, check what instruction sets your CPU supports:
If you don't see avx or avx2 in the output, your CPU doesn't support these instruction sets.
# On Linux
grep -m1 flags /proc/cpuinfo | grep -o 'avx[^ ]*'
# On macOS
sysctl -a | grep machdep.cpu.featuresで、たしかに何も引っかかて来なかった。その場合は、今入っているPyTorchを一回アンインストールして、CPU-only versionをインストールしたらよし(↓)
The standard PyTorch installation might have AVX instructions. Try reinstalling with the CPU-only version:
で、以下言われた通りに実行したところ、lerobot-find-portが期待通り動くようになりました。
# First uninstall existing PyTorch
pip uninstall torch torchvision torchaudio
# Install CPU-only version
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpuまとめ
アームの稼働まで確認したかったのですが、PyTorchのバージョンの部分でてこずったので、ここでいったん切ります。次の記事ではRaspberryPi上でのアームの認識とキャリブレーションをまとめたいと思います。
まいど、ここまで読んでいただいて、ありがとうございます。