Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ robotiq_gripper_controller:
max_effort: 50.0 # TODO tune

allow_stalling: true
stall_timeout: 0.05
stall_timeout: 1.0
goal_tolerance: 0.02

robotiq_activation_controller:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ robotiq_gripper_controller:
# Optional (recommended)
state_interfaces: ["position", "velocity"]
allow_stalling: true
stall_timeout: 0.05
stall_timeout: 1.0
goal_tolerance: 0.02

robotiq_activation_controller:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#pragma once

#include <chrono>
#include <future>
#include <limits>
#include <memory>
Expand All @@ -50,6 +51,7 @@
#include <robotiq_driver/ros2_control_compat.hpp>

#include <Robotiq/gripper.hpp>
#include <Robotiq/gripper/velocity_estimator.hpp>

#include <hardware_interface/handle.hpp>
#include <hardware_interface/hardware_info.hpp>
Expand All @@ -62,6 +64,8 @@
namespace robotiq_driver {

inline constexpr const char* kObjectStatusInterface = "object_status";

inline constexpr std::chrono::milliseconds kVelocityTimeConstant{100};
inline constexpr const char* kMotorCurrentInterface = "motor_current";
inline constexpr const char* kGripperFaultInterface = "gripper_fault";
inline constexpr const char* kGripperFaultSeverityInterface = "gripper_fault_severity";
Expand Down Expand Up @@ -188,6 +192,7 @@ class RobotiqGripperHardwareInterface : public hardware_interface::SystemInterfa

double gripper_position_ = 0.0;
double gripper_velocity_ = 0.0;
Robotiq::VelocityEstimator velocity_estimator_{kVelocityTimeConstant};

// gCU in amperes, and gOBJ verbatim. Doubles to match the other
// interfaces: Jazzy can carry a uint8_t, but only through the
Expand Down
7 changes: 3 additions & 4 deletions grippers/robotiq_driver/src/hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ hardware_interface::CallbackReturn RobotiqGripperHardwareInterface::on_activate(
// Seed both sides from that settled reading so the first exported state, and
// any hold target derived from it, describe where the fingers actually are.
gripper_position_ = jointPositionFromRegister(status.position, parameters_.closed_position);
velocity_estimator_.reset();
gripper_velocity_ = 0.0;
gripper_motor_current_ = motorCurrentFromRegister(status.current);
gripper_object_status_ = static_cast<double>(status.gripperStatus.objectDetection());
Expand Down Expand Up @@ -437,7 +438,7 @@ hardware_interface::CallbackReturn RobotiqGripperHardwareInterface::on_deactivat
return CallbackReturn::SUCCESS;
}

hardware_interface::return_type RobotiqGripperHardwareInterface::read(const rclcpp::Time& /*time*/,
hardware_interface::return_type RobotiqGripperHardwareInterface::read(const rclcpp::Time& time,
const rclcpp::Duration& /*period*/)
{
if(!gripper_)
Expand All @@ -447,9 +448,7 @@ hardware_interface::return_type RobotiqGripperHardwareInterface::read(const rclc

const Robotiq::GripperStatus status = gripper_->getStatus();
gripper_position_ = jointPositionFromRegister(status.position, parameters_.closed_position);
// The status block carries no velocity — the gripper reports position and
// motor current only.
gripper_velocity_ = 0.0;
gripper_velocity_ = velocity_estimator_.update(gripper_position_, std::chrono::nanoseconds{time.nanoseconds()});
gripper_motor_current_ = motorCurrentFromRegister(status.current);
gripper_object_status_ = static_cast<double>(status.gripperStatus.objectDetection());
gripper_fault_ = {gripperFaultFromRegister(status.faultStatus),
Expand Down
Loading