xArm-Developer / xarm_ros2

ROS2 developer packages for robotic products from UFACTORY
https://www.ufactory.cc/pages/xarm
BSD 3-Clause "New" or "Revised" License
118 stars 74 forks source link

How can we teleop the Gripper from xarm_moveit_servo? #104

Open bchandaka opened 1 week ago

bchandaka commented 1 week ago

We are using xarm_moveit_servo to teleop control our xarm 7 using an xbox controller, but we found that the gripper controller is not launched from the servo nodes. How can we open/close the xarm gripper in the servoing mode?

penglongxiang commented 1 week ago

Hi @bchandaka there are two ways currently to control gripper while using moveit servo to control the arm.

(1) Use the ros2 service defined in xarm_api package. You should first enable the gripper related services in the config yaml if you have not done so. Please follow the instruction here and enable set_gripper_mode, set_gripper_enable, set_gripper_speed, set_gripper_position and clean_gripper_error services. After colcon build, You can check if gripper can be successfully controlled by following terminal command:

$ ros2 service call /xarm/set_gripper_mode xarm_msgs/srv/SetInt16 "data: 0"
$ ros2 service call /xarm/set_gripper_enable xarm_msgs/srv/SetInt16 "data: 1"
$ ros2 service call /xarm/set_gripper_speed xarm_msgs/srv/SetFloat32 "data: 3000"
$ ros2 service call /xarm/set_gripper_position xarm_msgs/srv/GripperMove "{pos: 200, wait: false, timeout: 10.0}"

The position range (in pulses for our API) of the gripper is from 0 (CLOSED) to 850 (fully OPEN). You can adjust the speed and target position, the first three configuration only needs to be done once upon application start, then you can just change the position command afterwards.

(2) Use self-implemented move_group interface program to control the gripper. As you can see in the robot_description_semantic param of /servo_server node, there is a pre-defined planning group named "xarm_gripper" with 2 states "open" and "close", you can implement a moveit node for planning and execution of the gripper, if moveit planning way is preferred on your side.