إعداد البرامج

تثبيت orca_core SDK، وإعداد برنامج تشغيل USB، وواجهة برمجة تطبيقات التحكم بالإصبع الفردي، وواجهة اليد ROS2، وقراءة المستشعر اللمسي، ومحاكاة MuJoCo. من تثبيت Python جديد إلى جميع المفاصل الـ 17 المتحركة.

انتقل إلى القسم:

الخطوة 1 – تثبيت SDK

تثبيت orca_core SDK

orca_core هو Python SDK الرسمي لـ Orca Hand. يمكن تثبيته عبر النقطة ويدعم Python 3.9+. لا توجد حاجة لـ ROS للتحكم المشترك الأساسي.

إنشاء بيئة افتراضية

python -m venv ~/.venvs/orca
source ~/.venvs/orca/bin/activate   # Windows: .venvs\orca\Scripts\activate

التثبيت عبر النقطة

pip install orca-core

التثبيت عبر الشعر (موصى به للتطوير)

git clone https://github.com/orcahand/orca_core.git
cd orca_core
poetry install

تحقق من التثبيت وابحث عن يدك

python -c "from orca_core import OrcaHand; print('orca_core installed OK')"

# Find the USB serial port
python -c "
from orca_core import OrcaHand
# Lists available ports
import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
for p in ports:
    print(p)
"
الخطوة 2 – واجهة برمجة تطبيقات التحكم بالإصبع

التحكم بالإصبع الفردي

ال OrcaHand يعرض الفصل جميع المفاصل الـ 17 عبر الإصبع المحدد وملحقات المفاصل. وضع التحكم الافتراضي هو current_based_position.

ربط وقراءة جميع المواقف المشتركة

from orca_core import OrcaHand

hand = OrcaHand(port="/dev/ttyUSB0", handedness="right")
hand.connect()

# Read all joint positions (returns dict of joint_name: position_deg)
positions = hand.get_positions()
print(positions)
# e.g. {'thumb_abduct': 0.0, 'thumb_mcp': 15.2, ...}

hand.disconnect()

تحريك المفاصل الفردية

from orca_core import OrcaHand
import time

hand = OrcaHand(port="/dev/ttyUSB0", handedness="right")
hand.connect()
hand.enable_all()

# Move thumb MCP joint to 45 degrees
hand.set_position("thumb_mcp", 45.0)
time.sleep(0.5)

# Move index finger MCP to 60 degrees
hand.set_position("index_mcp", 60.0)
time.sleep(0.5)

# Open all fingers
hand.open_all()
time.sleep(1.0)

hand.disable_all()
hand.disconnect()

ضبط مفاصل متعددة في وقت واحد

from orca_core import OrcaHand

hand = OrcaHand(port="/dev/ttyUSB0", handedness="right")
hand.connect()
hand.enable_all()

# Command all 17 joints at once (dict of joint_name: target_deg)
pose = {
    "thumb_abduct": 30.0,
    "thumb_mcp":    45.0,
    "thumb_pip":    30.0,
    "thumb_dip":    20.0,
    "index_mcp":    70.0,
    "index_pip":    60.0,
    "index_dip":    40.0,
    # ... remaining joints
}
hand.set_positions(pose)

hand.disable_all()
hand.disconnect()
الخطوة 3 - فهم البدائيات

المدمج في فهم البدائيات

orca_core يأتي مع بدائيات فهم معايرة لمهام المعالجة الشائعة. هذه هي أسرع طريقة لاختبار الاستيعاب الأساسي قبل تنفيذ السياسات المخصصة.

استخدام فهم البدائيات

from orca_core import OrcaHand
from orca_core.grasps import GraspLibrary
import time

hand = OrcaHand(port="/dev/ttyUSB0", handedness="right")
hand.connect()
hand.enable_all()
grasps = GraspLibrary()

# Open hand
hand.execute_grasp(grasps.open)
time.sleep(1.0)

# Power grasp (whole-hand wrap)
hand.execute_grasp(grasps.power_grasp)
time.sleep(1.0)

# Precision pinch (thumb + index tip)
hand.execute_grasp(grasps.precision_pinch)
time.sleep(1.0)

# Tripod grasp (thumb + index + middle)
hand.execute_grasp(grasps.tripod)
time.sleep(1.0)

# Lateral pinch (thumb side against index lateral)
hand.execute_grasp(grasps.lateral_pinch)
time.sleep(1.0)

hand.open_all()
hand.disable_all()
hand.disconnect()

اقحم بين القبضات

from orca_core import OrcaHand
from orca_core.grasps import GraspLibrary
import time, numpy as np

hand = OrcaHand(port="/dev/ttyUSB0", handedness="right")
hand.connect()
hand.enable_all()
grasps = GraspLibrary()

# Smoothly interpolate from open to power grasp over 30 steps
for alpha in np.linspace(0, 1, 30):
    pose = grasps.interpolate(grasps.open, grasps.power_grasp, alpha)
    hand.set_positions(pose)
    time.sleep(0.05)

hand.disable_all()
hand.disconnect()
الخطوة 4 – تكامل ROS2

واجهة اليد ROS2

ال orca_ros2 توفر الحزمة واجهة ROS2 كاملة للتحكم المنسق في الذراع + اليد. تنشر حالات مشتركة وتقبل أوامر المسار المشترك.

قم بتثبيت orca_ros2

mkdir -p ~/orca_ws/src && cd ~/orca_ws/src
git clone https://github.com/orcahand/orca_ros2.git
cd ~/orca_ws
source /opt/ros/humble/setup.bash
colcon build --symlink-install

قم بتشغيل عقدة برنامج التشغيل اليدوي

source ~/orca_ws/install/setup.bash
ros2 launch orca_ros2 orca_hand.launch.py \
  port:=/dev/ttyUSB0 \
  handedness:=right

اشترك في موضوع الدولة المشتركة

ros2 topic echo /orca_hand/joint_states

إرسال أمر الموقف المشترك

ros2 topic pub /orca_hand/joint_command \
  sensor_msgs/msg/JointState \
  '{name: ["index_mcp", "index_pip"], position: [1.22, 1.05]}'

ذراع منسق + إطلاق يدوي (باستخدام OpenArm)

ros2 launch orca_ros2 openarm_orca.launch.py \
  arm_can_interface:=can0 \
  hand_port:=/dev/ttyUSB0 \
  handedness:=right

يؤدي هذا إلى إطلاق كلا من openarm_ros2 سائق الذراع و orca_ros2 سائق يدوي تحت مساحة اسم واحدة، مما يتيح تنفيذ المسار المنسق من خلال MoveIt2.

الخطوة 5 – أجهزة الاستشعار اللمسية

قراءة مستشعر اللمس

تقوم Orca Hand بشكل اختياري بتركيب أجهزة استشعار تعمل باللمس بأطراف الأصابع (Paxini أو متوافقة). تتدفق البيانات اللمسية بشكل مستقل عبر اتصال USB منفصل.

قراءة قوة الاتصال الإصبع

from orca_core import OrcaHand
from orca_core.sensors import TactileSensorArray

hand = OrcaHand(port="/dev/ttyUSB0", handedness="right")
tactile = TactileSensorArray(port="/dev/ttyUSB1")  # separate USB port

hand.connect()
tactile.connect()
hand.enable_all()

import time
for _ in range(100):
    # Returns dict of finger_name: contact_force_N
    forces = tactile.read_forces()
    positions = hand.get_positions()
    print(f"Index force: {forces.get('index', 0):.3f} N | "
          f"Index MCP: {positions['index_mcp']:.1f} deg")
    time.sleep(0.01)

hand.disable_all()
hand.disconnect()
tactile.disconnect()

عتبة الكشف عن الاتصال

from orca_core.sensors import TactileSensorArray

tactile = TactileSensorArray(port="/dev/ttyUSB1")
tactile.connect()

# Set contact detection threshold per finger (in N)
tactile.set_threshold(finger="index", threshold_n=0.1)
tactile.set_threshold(finger="thumb", threshold_n=0.15)

# Returns True when contact exceeds threshold
in_contact = tactile.is_in_contact("index")
print("Index in contact:", in_contact)
اختياري – محاكاة

محاكاة MuJoCo

يتم شحن Orca Hand مع نماذج MuJoCo MJCF المُعايرة - اليد اليسرى واليد اليمنى ومشهد ثنائي اليدين. تشترك المحاكاة في أسماء مشتركة ومساحات عمل متطابقة مع أجهزة حقيقية.

تثبيت وتشغيل المحاكاة

pip install mujoco
pip install orca-core[sim]  # or: pip install orca-mujoco

# Clone the MuJoCo model package
git clone https://github.com/orcahand/orcahand_description.git

# Launch the right-hand sim
python -c "
import mujoco, mujoco.viewer
import numpy as np

model = mujoco.MjModel.from_xml_path('orcahand_description/mjcf/orca_right.xml')
data = mujoco.MjData(model)

with mujoco.viewer.launch_passive(model, data) as viewer:
    while viewer.is_running():
        mujoco.mj_step(model, data)
        viewer.sync()
"

نقل سيم إلى حقيقي

تتطابق الأسماء المشتركة في نموذج MJCF مع orca_core SDK بالضبط. يمكن نشر السياسة التي تم تدريبها على المحاكاة على البدائيات الفهمية مباشرةً على الأجهزة الحقيقية - والفرق الوحيد هو زمن الوصول التسلسلي USB (~ 3 مللي ثانية) مقابل توقيت الخطوات الفيزيائية.

استكشاف الأخطاء وإصلاحها

القضايا المشتركة

خطأ 1 بعض الأصابع لا تستجيب — فحص مؤازر جزئي

عادةً لا يتم تثبيت كبل السلسلة التعاقبية بشكل كامل عند التقاطع بين وحدات الأصابع. ناقل STS عبارة عن سلسلة - يؤدي اتصال واحد سيئ إلى إسقاط جميع الماكينات النهائية.

يصلح:

# Scan to see which servo IDs are found
python -c "
from orca_core import OrcaHand
hand = OrcaHand(port='/dev/ttyUSB0', handedness='right')
hand.connect()
ids = hand.scan_motors()
print('Found IDs:', ids)  # should be 1..17
hand.disconnect()
"
خطأ 2 وصول الإصبع إلى الحدود الصعبة — فرط توتر الأوتار

لا يمكن للإصبع أن يمتد أو ينثني بالكامل. توجيه الأوتار ضيق للغاية على جانب واحد. يحدث بشكل شائع بعد إعادة التجميع.

يصلح:

# Check joint limits — move each joint to its range manually
python -c "
from orca_core import OrcaHand
hand = OrcaHand(port='/dev/ttyUSB0')
hand.connect()
# Enable compliance mode — move finger by hand to feel the limits
hand.set_compliance_mode(finger='index', enabled=True)
"
# If finger hits hard limit below expected range,
# loosen the extensor tendon by 0.5 turns at the tendon anchor
خطأ 3 موضوع ROS2 Joint_states لا ينشر

تم إطلاق عقدة برنامج التشغيل orca_ros2 ولكنها لا تنشر الحالات المشتركة. عادة ما تكون مشكلة في إذن المنفذ أو جلسة orca_core متعارضة.

يصلح:

# 1. Ensure no other orca_core session has the port open
# Close any Python scripts using the hand first

# 2. Add USB serial permissions (Linux)
sudo usermod -aG dialout $USER  # log out and back in

# 3. Re-launch with explicit port
ros2 launch orca_ros2 orca_hand.launch.py port:=/dev/ttyUSB0

# 4. Check topic
ros2 topic hz /orca_hand/joint_states   # should be ~100 Hz

عمل البرمجيات؟ ابدأ بجمع البيانات.

بمجرد أن تتحرك جميع المفاصل الـ 17، فإن الخطوة التالية هي تسجيل حلقات التلاعب الحاذقة.