mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
26 lines
1.1 KiB
Python
Executable file
26 lines
1.1 KiB
Python
Executable file
# -*- coding: utf-8 -*-
|
||
from pymycobot.genre import Angle
|
||
from pymycobot import PI_PORT, PI_BAUD # 当使用树莓派版本的mycobot时,可以引用这两个变量进行MyCobot初始化
|
||
import time
|
||
import pymycobot
|
||
from packaging import version
|
||
|
||
# min low version require
|
||
MIN_REQUIRE_VERSION = '3.6.0'
|
||
|
||
current_verison = pymycobot.__version__
|
||
print('current pymycobot library version: {}'.format(current_verison))
|
||
if version.parse(current_verison) < version.parse(MIN_REQUIRE_VERSION):
|
||
raise RuntimeError('The version of pymycobot library must be greater than {} or higher. The current version is {}. Please upgrade the library version.'.format(MIN_REQUIRE_VERSION, current_verison))
|
||
else:
|
||
print('pymycobot library version meets the requirements!')
|
||
from pymycobot.mycobot320 import MyCobot320
|
||
mc = MyCobot320("/dev/ttyUSB0", 115200)
|
||
# 通过传递角度参数,让机械臂每个关节移动到对应[0, 0, 0, 0, 0, 0]的位置
|
||
mc.send_angles([0, 0, 0, 0, 0, 0], 50)
|
||
|
||
# 设置等待时间,确保机械臂已经到达指定位置
|
||
time.sleep(2.5)
|
||
|
||
# 让关节1移动到90这个位置
|
||
# mc.send_angle(Angle.J1.value, 90, 50)
|