実験向きロボットアームxArmとオープンソース自動分注機OT-2を連動させるためのメモ
実際のところ
我流でやっていたのですが、これを機会に公式の方法を採用
xArmのPythonSDKを入手
GitHub - xArm-Developer/xArm-Python-SDK
から、zipファイルを取得
OT-2のJupyter環境に同ファイルをアップロード
このとき、解凍はしないように注意
公式のインストーラー
opentrons-integration-tools/ufactory-xarm at main · Opentrons/opentrons-integration-tools · GitHub
より、ot-ufactory-install.ipynbをOT-2のJupyter環境にコピペ
記事執筆時点では、以下のような内容.
ZIPを解凍してパスを通す
import os import zipfile import subprocess import shlex # Unzip UFACTORY installation file parent_path = os.path.join("/", "var", "lib", "jupyter", "notebooks") zip_name = "xArm-Python-SDK-master.zip" out_name = "xArm-Python-SDK-master" my_zipfile = zipfile.ZipFile(file=os.path.join(parent_path, zip_name)) my_zipfile.extractall(path=parent_path) # Prepare disk for installation: # 1. Make read-write (goes back to read upon reboot) # 2. Uninstall "pandas" to free up space subprocess.run(shlex.split("mount -o remount, rw /")) subprocess.run(shlex.split("pip uninstall pandas")) # Run UFACTORY installation file run_file = os.path.join(parent_path, out_name, "setup.py") subprocess.run( shlex.split("python {} install".format(run_file)), cwd=os.path.join(parent_path, out_name) )
動作確認
別のJupyter Notebookファイルをつくり
import sys sys.path.append("/var/lib/jupyter/notebooks/xArm-Python-SDK-master") from xarm.wrapper import XArmAPI UFACTORY_IP = "192.168.1.XXX" ##使用するxARMのアドレスを入れる my_xarm = XArmAPI(UFACTORY_IP)
コンソールにSDK読み込みの旨が出てくれば成功