C650&Pro630遥操作案例

功能:C650遥控Pro630抓取码垛木块

1 夹爪安装

先将夹爪的法兰安装到630的末端上

然后将夹爪安装在夹爪的法兰上

然后用夹爪线将夹爪盒机械臂末端IO连接起来,连接时注意先将机械臂断电,避免热插补损坏夹爪

2 夹爪测试

from pymycobot import ElephantRobot
import time

elephant_client = ElephantRobot("192.168.1.127", 5001)# 将ip更改成Pro630树莓派的实时ip
elephant_client.start_client()# 启动机器人必要指令
time.sleep(1)
while elephant_client.state_check()==False:
    elephant_client.state_off()
    time.sleep(2)
    elephant_client.power_on()
    time.sleep(2)
    elephant_client.state_on()
    time.sleep(2)

elephant_client.set_gripper_mode(0)
time.sleep(1)
for i in range(2):
    elephant_client.set_gripper_state(0,100)#夹爪张开
    time.sleep(1)
    elephant_client.set_gripper_state(1,100)#夹爪闭合
    time.sleep(1)

3 准备工作

先将机械臂调成下图姿态,机械臂周围不要有杂物,避免发生碰撞

确保底C650的座屏幕显示ok

在运行程序前,先手动将C650调整到下图姿态,再运行程序

4 案例程序

from pymycobot import ElephantRobot,MyArmC,utils
import time
arm=ElephantRobot("192.168.1.159",5001)# 将ip更改成Pro630树莓派的实时ip
arm.start_client()# 启动机器人必要指令
time.sleep(1)
while arm.state_check()==False:
    arm.state_off()
    time.sleep(2)
    arm.power_on()
    time.sleep(2)
    arm.state_on()
    time.sleep(2)
    print(arm.state_check())

arm.set_gripper_mode(0)
time.sleep(0.3)
c=MyArmC(utils.get_port_list()[0])
fact_angle = [0, 0, 0, 0, 0, 0]

def jointlimit(angles):
  max = [180.0, 90.0, 150.0, 80.0, 168.0, 175.0]
  min = [-180.0, -270, -150.0, -260.0, -168.0, -175.0]
  for i in range(6):
    if(angles[i] > max[i]):
       angles[i] = max[i]
    if(angles[i] < min[i]):
       angles[i] = min[i]

try:
    while 1:
        angle=c.get_joints_angle()
        if len(angle)==7:
            fact_angle[0]=angle[0]
            fact_angle[1]=-angle[1]-90
            fact_angle[2]=angle[2]+110
            fact_angle[4]=angle[3]-90
            fact_angle[5]=angle[5]
            if angle[4]<90:
                fact_angle[3]=90-angle[4]
                fact_angle[3]=-90-fact_angle[3]
            elif angle[4]>90:
                fact_angle[3]=90-angle[4]
                fact_angle[3]=-90+fact_angle[3]
            else:
                fact_angle[3]=-angle[4]
            for i in range(len(fact_angle)):
                fact_angle[i]=round(fact_angle[i],2)
            jointlimit(fact_angle)
            grip_value = int(-angle[6])
            if grip_value < 0:
                grip_value = 0
            if grip_value > 100:
                grip_value = 100
            arm.write_angles(fact_angle,5999)
            arm.set_gripper_value(grip_value,100)
            time.sleep(0.25)
        else:
            print("None")
except:
    arm.stop_client()
    print("end")

5 效果展示

results matching ""

    No results matching ""