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

تثبيت SDK، وإعداد برنامج التشغيل CAN، وتكوين وحدة التحكم ROS2، وتكامل LeRobot لـ O6، وأمثلة Python API، وأهم مشكلات استكشاف الأخطاء وإصلاحها. من تثبيت Ubuntu جديد إلى ذراع متحركة.

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

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

تثبيت SDK

يوفر LinkerBot O6 SDK روابط Python لواجهة ناقل CAN الخاصة بالذراع. يتم تضمينه في حزمة النظام الأساسي RoboticsCenter.

إنشاء بيئة افتراضية (مستحسن)

python3 -m venv ~/.venvs/linkerbot-o6
source ~/.venvs/linkerbot-o6/bin/activate

قم بتثبيت SDK

pip install roboticscenter

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

python3 -c "from linkerbot import LinkerBotO6; print('SDK ready')"

التثبيت من المصدر (اختياري)

git clone https://github.com/linkerbot/linkerbot_sdk.git
cd linkerbot_sdk
pip install -e .
الخطوة 2 – إعداد برنامج التشغيل CAN

يمكن إعداد برنامج التشغيل

يستخدم LinkerBot O6 نفس بنية SwitchCAN مثل OpenArm 101. إذا قمت بإعداد CAN لـ OpenArm، فإن هذه العملية متطابقة. برامج تشغيل ناقل CAN مدمجة في Linux kernel.

تحميل وحدات النواة

sudo modprobe can
sudo modprobe can_raw
sudo modprobe slcan   # for USB CAN adapters (CANable)

إظهار واجهة CAN

# Find the USB serial device
ls /dev/ttyACM*

# Bring up CAN interface at 1 Mbps
sudo slcand -o -c -s8 /dev/ttyACM0 can0
sudo ip link set up can0

تحقق من أن الواجهة قيد التشغيل

ip link show can0
# Expected: can0: <NOARP,UP,LOWER_UP> mtu 16 ...

اختبار يمكن الاتصال

sudo apt install can-utils -y
candump can0
# Power on the O6 and look for motor heartbeat packets

جعل المستمر عبر عمليات إعادة التشغيل

إنشاء خدمة systemd أو إضافتها إلى /etc/rc.local. انظر دليل إعداد المقبس — الإجراء مطابق لـ O6.

الخطوة 3 – وحدات تحكم ROS2

إعداد وحدة تحكم ROS2

ال linkerbot_ros2 توفر الحزمة واجهة جهاز ros2_control كاملة لـ O6. يتضمن وضع الأجهزة المزيف للاختبار بدون الذراع.

تثبيت ROS2 المتواضع

sudo apt update && sudo apt install software-properties-common curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | \
  sudo apt-key add -
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu jammy main" \
  > /etc/apt/sources.list.d/ros2.list'
sudo apt update
sudo apt install ros-humble-desktop ros-humble-ros2-control \
  ros-humble-ros2-controllers ros-humble-joint-state-publisher-gui -y

استنساخ وبناء linkerbot_ros2

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

التشغيل في وضع الأجهزة المزيفة (لا يلزم وجود ذراع)

source ~/o6_ws/install/setup.bash
ros2 launch linkerbot_ros2 o6.launch.py use_fake_hardware:=true

ابدأ باستخدام أجهزة حقيقية

ros2 launch linkerbot_ros2 o6.launch.py \
  use_fake_hardware:=false \
  can_interface:=can0

التحقق من الدول المشتركة

ros2 topic echo /joint_states
الخطوة 4 – LeRobot لـ O6

تكامل LeRobot لـ O6

يدعم LeRobot LinkerBot O6 أصلاً. قم بتكوين نوع الروبوت الخاص بك واتبع سير عمل LeRobot القياسي للتسجيل والتدريب.

تثبيت ليروبوت

pip install lerobot

قم بتكوين الروبوت O6 الخاص بك

# ~/.lerobot/robots/linkerbot_o6.yaml
robot_type: linkerbot_o6
can_interface: can0
num_joints: 6
camera_names:
  - wrist_cam
  - overhead_cam

تسجيل مجموعة بيانات

python -m lerobot.scripts.control_robot \
  --robot.type=linkerbot_o6 \
  --control.type=record \
  --control.fps=30 \
  --control.repo_id=your-username/o6-pick-place \
  --control.num_episodes=50 \
  --control.single_task="Pick up the red cube"

تحميل إلى HuggingFace Hub

huggingface-cli login
python -m lerobot.scripts.push_dataset_to_hub \
  --repo_id=your-username/o6-pick-place

انظر صفحة جمع البيانات لسير العمل الكامل بما في ذلك اختبارات الجودة.

الخطوة 5 - واجهة برمجة تطبيقات بايثون

أمثلة على واجهة برمجة تطبيقات بايثون

يوفر LinkerBot Python SDK تحكمًا مشتركًا مباشرًا دون الحاجة إلى ROS2. نفس نمط OpenArm SDK.

السيطرة المشتركة الأساسية

from linkerbot import LinkerBotO6

# Connect to the arm
arm = LinkerBotO6(can_interface="can0")
arm.connect()
arm.enable_all()

# Move joint 1 to 45 degrees (0.785 rad)
arm.set_position(joint_id=1, position=0.785, kp=50, kd=1)

# Read current state
state = arm.get_state()
print(f"Positions (rad): {state.positions}")
print(f"Velocities (rad/s): {state.velocities}")
print(f"Torques (Nm): {state.torques}")

# Safe shutdown
arm.disable_all()
arm.disconnect()

قراءة كافة المفاصل في حلقة التحكم

import time
from linkerbot import LinkerBotO6

arm = LinkerBotO6(can_interface="can0", control_rate_hz=500)
arm.connect()
arm.enable_all()

for _ in range(500):  # 1 second at 500 Hz
    state = arm.get_state()
    print(state.positions)
    time.sleep(1 / 500)

arm.disable_all()
arm.disconnect()

تنفيذ المسار

from linkerbot import LinkerBotO6, JointTrajectory
import numpy as np

arm = LinkerBotO6(can_interface="can0")
arm.connect()
arm.enable_all()

# Define a waypoint trajectory
waypoints = [
    [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
    [0.5, -0.3, 0.8, 0.0, 0.4, 0.0],
    [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
]
durations = [2.0, 2.0, 2.0]  # seconds per segment

traj = JointTrajectory(waypoints=waypoints, durations=durations)
arm.execute_trajectory(traj)

arm.disable_all()
arm.disconnect()
استكشاف الأخطاء وإصلاحها

أعلى 3 قضايا مشتركة

خطأ 1 لم يتم العثور على واجهة CAN: no such device can0

واجهة SwitchCAN ليست قيد التشغيل. دائمًا تقريبًا لأن محول USB CAN غير متصل أو لم يتم تحميل وحدات kernel.

يصلح:

# 1. Verify USB adapter is detected
lsusb | grep -i "can\|serial"

# 2. Load the kernel modules
sudo modprobe can && sudo modprobe can_raw && sudo modprobe slcan

# 3. Bring up the interface
sudo slcand -o -c -s8 /dev/ttyACM0 can0
sudo ip link set up can0

# 4. Verify
ip link show can0
خطأ 2 عدم استجابة المفاصل بعد ذلك arm.enable_all()

المحركات لا تتلقى الأوامر. السبب الأكثر شيوعًا هو معرفات CAN غير الصحيحة، أو إطارات خطأ ناقل CAN، أو عدم كفاية جهد مصدر الطاقة.

يصلح:

# 1. Check for CAN error frames
candump can0 | grep -i "error"

# 2. Check power supply — O6 requires 24V @ 150W minimum

# 3. Scan for motors and verify IDs
python3 -c "from linkerbot import LinkerBotO6; a=LinkerBotO6('can0'); a.scan_motors()"

# 4. Power cycle the arm and retry
خطأ 3 فشل LeRobot في الاتصال: robot not found

لا يمكن لـ LeRobot العثور على تكوين الروبوت O6 أو أن واجهة CAN لا تعمل عند بدء تشغيل LeRobot.

يصلح:

# 1. Verify CAN interface is up before starting LeRobot
ip link show can0

# 2. Verify config file path and format
cat ~/.lerobot/robots/linkerbot_o6.yaml

# 3. Test direct SDK connection first
python3 -c "
from linkerbot import LinkerBotO6
a = LinkerBotO6(can_interface='can0')
a.connect()
print('Connected:', a.get_state())
a.disconnect()"

# 4. Then retry LeRobot
python -m lerobot.scripts.control_robot \
  --robot.type=linkerbot_o6 \
  --control.type=teleoperate

لا تزال عالقة؟ مشاركة في منتدى SVRC أو زيارة O6 ويكي.

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

بمجرد تحرك O6، فإن الخطوة التالية هي التشغيل عن بعد وتسجيل مجموعة البيانات باستخدام LeRobot.