xArm-Developer / xarm_ros

ROS packages for robotic products from UFACTORY
https://www.ufactory.cc/
BSD 3-Clause "New" or "Revised" License
213 stars 158 forks source link

Baud rate error with Robotiq 2F-140 gripper #112

Closed adamanov closed 2 years ago

adamanov commented 2 years ago

Hello, we have xArm 6dof and attached Robotiq 2F-140 gripper on it. We recevied them as already gripper connected on controller box.

I try to to activate a gripper with already provided action server /xarm/xarm_gripper/gripper_action/goal by setting a target position of gripper. Whenever I publish on the topic I receive

[ERROR] [1657728750.422428506]: [ns: /xarm/] Controller Error detected! C19: [ End Module Communication Error ]
[ WARN] [1657727846.071932294]: set_gripper_mode, ret=22, err=0, cur_pos=0.000000
[ INFO] [1657727846.798460302]: gripper_action_goal handle, position: 0.500000

Which means the error is related to modbus baudrate not correct. However whenever I execute a example script /example/thirdparty-set_robotiq_gripper.cc, the gripper works fine (by default baud rate for robotiq gripper is 115200 ) I dont undestand why i got baud rate error whenever I send an action goal command. Bellow you can find my launch file.

I would appreciate if you could help me. Thanks in advance.

<?xml version="1.0"?>
<launch>
    <arg name="xarm_hw_ns" default="xarm" />
    <arg name="ext_ns" default="/" />

    <arg name="robot_ip" default="192.168.132.1" />
    <arg name="report_type" default="normal" />
    <arg name="baud_checkset" default="true" />
    <arg name="default_gripper_baud" default="115200" />
    <arg name="velocity_control" default="false" />
    <arg name="enforce_limits" default="true" />
    <arg name="add_gripper" value="true" />

    <!-- ==================== Load Arm HW ====================  -->
    <!-- common: bring up node to enable real xArm control -->
    <param name="$(arg xarm_hw_ns)/uf_model" value="XARM" />
    <param name="$(arg xarm_hw_ns)/DOF" value="6" />

    <!-- common: bring up node to collect robot feedback -->
    <param name="$(arg xarm_hw_ns)/xarm_robot_ip" type="str" value="$(arg robot_ip)" />
    <param name="$(arg xarm_hw_ns)/xarm_report_type" type="str" value="$(arg report_type)" />
    <param name="$(arg xarm_hw_ns)/baud_checkset" type="bool" value="$(arg baud_checkset)" />
    <param name="$(arg xarm_hw_ns)/default_gripper_baud" type="int" value="$(arg default_gripper_baud)" />
    <param name="$(arg xarm_hw_ns)/velocity_control" type="bool" value="$(arg velocity_control)" />
    <param name="$(arg xarm_hw_ns)/enforce_limits" type="bool" value="$(arg enforce_limits)" />
    <param name="$(arg xarm_hw_ns)/add_gripper" type="bool" value="$(arg add_gripper)" />

    <node name="uf_ros_controller" pkg="xarm_controller" type="uf_ros_controller" args="ip=$(arg robot_ip)" ns="$(arg xarm_hw_ns)" respawn="false" output="screen" />

</launch>
penglongxiang commented 2 years ago

Hi @adamanov, the provided xarm_gripper/gripper_action is targeted for the gripper from UFACTROY, the underlying communication protocol is customized and requires a baudrate of 2M. You may need to write another action server for Robotiq gripper.

adamanov commented 2 years ago

Thank you for your reply and hi @penglongxiang

Hi @adamanov, the provided xarm_gripper/gripper_action is targeted for the gripper from UFACTROY, the underlying communication protocol is customized and requires a baudrate of 2M.

Yes I saw it, and therefore I edited it to 115200 and respectively changed the argument for the below function ( to type=3 for robotiq gripper, default is 1 for Ufactroy arm). arm->set_checkset_default_baud(3, default_gripper_baud)

Shouldn`t it work after that? Or did you write a xarm_driver.cpp purely based on your gripper from Ufactroy? I though that you created a more general cpp script to make it work with different grippers based on needs. Because you provide already many implemented function for other grippers in your API

You may need to write another action server for Robotiq gripper.

Yeah it seems so, but I am not sure if we should create an action server based on your API or not.

vimior commented 2 years ago

Hi @adamanov

  1. At present, the gripper_action in ros is only for the control and feedback of xarm_gripper
  2. The different peripherals set by set_checkset_default_baud are the default values of the baud rate to be checked (type corresponds to the peripheral type, and different types are only valid for different APIs), because gripper_action uses xarm_gripper-related APIs, so even if set_checkset_default_baud (3, 115200) is also useless. The APIs related to robotiq should be similar to robotiq_xxx, but these APIs are only in the SDK and not provided in ros.
  3. If you want to control robotiq through gripper_action without changing the code of xarm_api, you can customize gripper_action and communicate with robotiq through the set_tool_modbus service in xarm_api
adamanov commented 2 years ago

Hi @adamanov

1. At present, the gripper_action in ros is only for the control and feedback of xarm_gripper

2. The different peripherals set by set_checkset_default_baud are the default values of the baud rate to be checked (type corresponds to the peripheral type, and different types are only valid for different APIs), because gripper_action uses xarm_gripper-related APIs, so even if set_checkset_default_baud (3, 115200) is also useless. The APIs related to robotiq should be similar to robotiq_xxx, but these APIs are only in the SDK and not provided in ros.

3. If you want to control robotiq through gripper_action without changing the code of xarm_api, you can customize gripper_action and communicate with robotiq through the set_tool_modbus service in xarm_api

Hi @vimior Thank you very much for your detailed answer, and sorry for late response. I fixed the the problem by writing my own Gripper Action Service which communicate with Gripper Hardware over xArm_API and also published a joint states of gripper for Moveit in order to send commands over Rviz Moviet.