Danfoa / robotiq_2finger_grippers

ROS packages enabling the control, visualization and simulation of the Robotiq 2 Fingers Adaptive Grippers model version C3
106 stars 55 forks source link
actionlib grippers robotiq robotiq-140mm robotiq-85mm robotiq-gripper robotiq-grippers ros ros-kinetic ros-melodic

This package contains the necesary files to connect and control the Robotiq 2 finger adaptive grippers (85mm and 140mm stroke) of the C series through a USB port using the Modbus RTU communication protocol. (Currently only URDF descriptions of models C3 are available)

C3 models

Note: This package is based on waypointrobotics/robotiq_85_gripper and ros-industrial/robotiq, with many code changes and feature inclusions as:

A pull request to this packages requires further analysis since I performed many structural changes, which will create conflict for previous users.

Ros Distro

This package has been tested on Kinetic and Melodic.

Contents

Prior to executing control of the grippers make sure you have connected a 2-finger adaptive gripper model to a USB port of your computer. The RS-485 to USB converter ACC-ADT-USB-RS485 that comes by default when you order these grippers allow connecting the 2-finger gripper directly to a computer through a USB 2.0 port using Modbus RTU communication protocol.

Serial Port Configuration

To control the gripper over a serial port, you may need to give proper privileges to the user:

sudo adduser <YOUR_USERNAME> dialout

To find out the port on which the controller is connected, use:

dmesg | grep tty

The output should look something similar to:

[####.#####] USB 1-2: FTDI USB Serial Device converter now attached to ttyUSB0

Test communication and control

On a new terminal type the following line:

# Connect and move 85 mm gripper  
roslaunch robotiq_2f_gripper_control test_85mm_gripper.launch comport:="<YOUR GRIPPER TTY PORT NAME>"
# Simulate 85mm gripper 
roslaunch robotiq_2f_gripper_control test_85mm_gripper.launch sim:=true

This launch file starts a robotiq_action_server and an example action client which recursively commands the the real gripper *or simulated one) with diferent poses/speeds while updating the gripper joints on rviz.

gripper operation

Documentation

Control Robotiq gripper/s

The control of both 140mm and 85mm stroke robotiq grippers is done though an actionlib client-server interaction (see actionlib documentation).

robotiq_actionlib_structure


Node robotiq_2f_action_server

This node creates an instance of an action server that will handle the gripper connection, initialization, joint state publishing, and control by listening for incoming goals on the action name command_robotiq_action. It offers also the option to simulate a gripper response to incoming goals.

Arguments:

Action type:

CommandRobotiqGripper.action (see action declaration for goal, feedback and result message fields)

or

FollowJointTrajectory.action (see action declaration for goal, feedback and result message fields): This is the default control scheme from MoveIt!, meaning that with the appropiate configuration you can plan and command the gripper through the MoveIt!-Rviz GUI, and through Pick and Place operations.

Note: The Action Server will only become active and ready after Robotiq gripper has been propertly initialized (see robotiq documentation).


Command gripper through an instance of a SimpleActionClient in Python

An example action client implementation is provided on the script robotiq_2f_action_client_example.py, showing how to initialize the client, create custom goals, and use predefined functions for fast control of the gripper, position, speed and force. But basically you just need to:

Import the Action messages and actionlib library

import actionlib
from robotiq_2f_gripper_msgs.msg import CommandRobotiqGripperFeedback, CommandRobotiqGripperResult, CommandRobotiqGripperAction, CommandRobotiqGripperGoal
from robotiq_2f_gripper_control.robotiq_2f_gripper_driver import Robotiq2FingerGripperDriver as Robotiq

Instantiate the action client

action_name = 'command_robotiq_action'    # Use your action server namespace if necesary
# Create an action client
robotiq_client = actionlib.SimpleActionClient(action_name, CommandRobotiqGripperAction)   
# Wait until grippers are ready to take command (communication is stablished and gripper is activated)
robotiq_client.wait_for_server()   

Command your robotiq gripper

# Use pre-defined functions for robot gripper manipulation.
Robotiq.close(robotiq_client, block=True)   # Close and wait until completion
Robotiq.open(robotiq_client, block=False)   # Open and do not block thread while completing goal
Robotiq.goto(robotiq_client, pos=0.04, speed=0.1, force=10, block=True)  # Send command Pose[m], speed[m/s], force [%]
Robotiq.emergency_release(robotiq_client)   # Slowly open gripper and deactivate it

Command gripper through an instance of a SimpleActionClient in C++

Import the Action messages and actionlib library

#include <actionlib/client/simple_action_client.h>
#include <robotiq_2f_gripper_msgs/CommandRobotiqGripperAction.h>
#include <robotiq_2f_gripper_control/robotiq_gripper_client.h>

typedef robotiq_2f_gripper_control::RobotiqActionClient RobotiqActionClient;

Instantiate a RobotiqActionClient class

std::string action_name = "/command_robotiq_action";  
bool wait_for_server = true;                  // Wait for Action Server connection (gripper is ready and activated)
RobotiqActionClient* gripper = new RobotiqActionClient(action_name, wait_for_server);

Command your robotiq gripper

gripper.close(speed, force, false);    // Close and do not wait
gripper.close();                       // Block thread until gripper is closed.
gripper.open();
gripper.goToPosition( position, speed, force, true);

Operation of Multiple Grippers

To control multiple grippers simultaneously you need to correctly namespace the grippers Action service and client nodes. A correct example is provided in the robotiq_dual_action_server.launch file.