7.2.4 关节控制
执行以下案例前,请固定机械臂并清空运动区域。
1. 回零
import time
from pymycobot import MyCobot280
mc = MyCobot280(unoq_bridge=True)
time.sleep(2)
if mc.is_controller_connected() != 1:
raise RuntimeError("请检查机械臂连接")
mc.send_angles([0, 0, 0, 0, 0, 0], 30)
2. 单关节运动
send_angle(joint_id, angle, speed) 中,关节编号为 1–6,速度范围为 0–100。
import time
from pymycobot import MyCobot280
mc = MyCobot280(unoq_bridge=True)
time.sleep(2)
mc.send_angles([0, 0, 0, 0, 0, 0], 40)
time.sleep(3)
mc.send_angle(3, 70, 40)
time.sleep(3)
mc.send_angle(4, -70, 40)
time.sleep(3)
mc.go_home()
3. 多关节运动
import time
from pymycobot import MyCobot280
mc = MyCobot280(unoq_bridge=True)
time.sleep(2)
mc.send_angles([0, 0, 0, 0, 0, 0], 40)
time.sleep(2.5)
mc.send_angles([90, 45, -90, 90, -90, 90], 50)
time.sleep(2.5)
mc.send_angles([0, 0, 0, 0, 0, 0], 50)
角度必须在机械臂允许范围内。不要为了测试而直接使用未经确认的极限姿态。
← 上一节 | 返回 Python 开发 | 下一节 →