< >
Home » ROS2与Interbotix系列机械臂教程 » ROS2与Interbotix系列机械臂教程-pick_and_place例程

ROS2与Interbotix系列机械臂教程-pick_and_place例程

文章说明

  • 本教程主要介绍如何在ros2环境下运行pick_and_place例程
  • 测试环境:Ubuntu 22.04 + ROS2 Humble + wx250s机械臂 + RealSense D435i相机

操作步骤

  • 假设正在现实中使用WidowX-250s机械臂,启动相机和机械臂,运行该命令
$ ros2 launch interbotix_xsarm_perception xsarm_perception.launch.py robot_model:=wx250s
  • 启动脚本
$ cd /home/ubuntu/interbotix_ws/src/interbotix_ros_manipulators/interbotix_ros_xsarms/interbotix_xsarm_perception/demos/
$ python3 pick_place.py
  • 由于脚本中默认的机械臂模型是wx200,当使用其他机械臂时,需要在脚本上进行对应的修改

  • 运行脚本时,在RViz中应该会待抓取的几个物件上会出现看到 TF 标记

  • 这是相机所识别到带抓取物件的位置,同时会通过get_cluster_positions函数反馈这些位置信息 - 物件上的 TF 标记是临时的,一阵间后就会消失

  • 然后,机械臂就会开始抓取物件

请输入图片描述

注意:由于前面的手眼标定流程得出的位姿变换不是百分百准确,位置可能有些许偏差,此时可以在脚本获取到的物件位置值上再添加偏差值修正这个问题

    if success:
        # pick up all the objects and drop them in a virtual basket in front of the robot
        for cluster in clusters:
            x, y, z = cluster['position'] # 相机识别到物件的位置
            print(x, y, z) # 打印位置
            bot.arm.set_ee_pose_components(x=x-0.02, y=y-0.02, z=z+0.1, pitch=0.5)
            bot.arm.set_ee_pose_components(x=x-0.02, y=y-0.02, z=z+0.01, pitch=0.5) # 物件的位置往x轴下方和y轴右边偏移2cm
            bot.gripper.set_pressure(0.5)  # 设置夹具力度
            bot.gripper.grasp()
            time.sleep(1)            
            bot.arm.set_ee_pose_components(x=x, y=y, z=z+0.2, pitch=0.5)
            bot.arm.set_ee_pose_components(x=0.3, z=0.2) 
            bot.gripper.set_pressure(1.0)  
            bot.gripper.release()
            time.sleep(2) 
    else:
        print('Could not get cluster positions.')

演示视频

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: none