双臂机器人UDP获取关节状态
Ron 2024-10-08
双臂机器人采用UDP的方式,可以通过IP过滤信息,判断关节信息来自哪一个机械臂,两条机械臂都为RM75,左臂IP为192.168.0.31,右臂IP为192.168.0.18,示例程序如下。
from robotic_arm_package.robotic_arm import *
num_step = 0
def robotstatus_1(data):
ip = data.arm_ip
value = data.joint_status.joint_position[:7]
if ip == b "192.168.0.18":
print("right",value)
elif ip == b"192.168.0.21":
print("left",value)
else:
print(ip)
left_robot = Arm(RM75, "192.168.0.21")
right_robot = Arm(RM75,"192.168.0.18")
print(left_robot.API_Version())
callback_left = RealtimePush_Callback(robotstatus_1)
callback_right = RealtimePush_Callback(robotstatus_1)
right_robot.Realtime_Arm_Joint_State(callback_right)
left_robot.Realtime_Arm_Joint_State(callback_left)
time.sleep(1)
撰写评论