An example showing how to control FRANKA's gripper.
An example showing how to control FRANKA's gripper.
#include <iostream>
#include <sstream>
#include <string>
#include <thread>
int main(int argc, char** argv) {
if (argc != 4) {
std::cerr << "Usage: ./grasp_object <gripper-hostname> <homing> <object-width>" << std::endl;
return -1;
}
try {
double grasping_width = std::stod(argv[3]);
std::stringstream ss(argv[2]);
bool homing;
if (!(ss >> homing)) {
std::cerr << "<homing> can be 0 or 1." << std::endl;
return -1;
}
if (homing) {
}
if (gripper_state.
max_width < grasping_width) {
std::cout << "Object is too large for the current fingers on the gripper." << std::endl;
return -1;
}
if (!gripper.
grasp(grasping_width, 0.1, 60)) {
std::cout << "Failed to grasp object." << std::endl;
return -1;
}
std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(3000));
std::cout << "Object lost." << std::endl;
return -1;
}
std::cout << "Grasped object, will release it now." << std::endl;
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
Maintains a network connection to the gripper, provides the current gripper state,...
Definition gripper.h:27
GripperState readOnce() const
Waits for a gripper state update and returns it.
bool grasp(double width, double speed, double force, double epsilon_inner=0.005, double epsilon_outer=0.005) const
Grasps an object.
bool stop() const
Stops a currently running gripper move or grasp.
bool homing() const
Performs homing of the gripper.
Contains exception definitions.
Contains the franka::Gripper type.
Base class for all exceptions used by libfranka.
Definition exception.h:20
Describes the gripper state.
Definition gripper_state.h:20
bool is_grasped
Indicates whether an object is currently grasped.
Definition gripper_state.h:38
double max_width
Maximum gripper opening width.
Definition gripper_state.h:33