Skip to content
Merged
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
5 changes: 3 additions & 2 deletions robotiq_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ target_include_directories(${PROJECT_NAME} PRIVATE
include
)

ament_target_dependencies(${PROJECT_NAME}
${THIS_PACKAGE_INCLUDE_DEPENDS}
target_link_libraries(${PROJECT_NAME}
controller_interface::controller_interface
${std_srvs_TARGETS}
)

pluginlib_export_plugin_description_file(controller_interface controller_plugins.xml)
Expand Down
15 changes: 11 additions & 4 deletions robotiq_controllers/src/robotiq_activation_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@ rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn Roboti
bool RobotiqActivationController::reactivateGripper(std_srvs::srv::Trigger::Request::SharedPtr /*req*/,
std_srvs::srv::Trigger::Response::SharedPtr resp)
{
command_interfaces_[REACTIVATE_GRIPPER_RESPONSE].set_value(ASYNC_WAITING);
command_interfaces_[REACTIVATE_GRIPPER_CMD].set_value(1.0);
resp->success = command_interfaces_[REACTIVATE_GRIPPER_RESPONSE].set_value(ASYNC_WAITING);
resp->success &= command_interfaces_[REACTIVATE_GRIPPER_CMD].set_value(1.0);

while (command_interfaces_[REACTIVATE_GRIPPER_RESPONSE].get_value() == ASYNC_WAITING)
while (true)
{
const auto maybe_value = command_interfaces_[REACTIVATE_GRIPPER_RESPONSE].get_optional();
if (maybe_value && maybe_value.value() != ASYNC_WAITING)
{
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
resp->success = command_interfaces_[REACTIVATE_GRIPPER_RESPONSE].get_value();
// NOTE: This was previously using get_value() and implicitly casting to bool, so keeping the old behavior.
// However, note that the value of this result is actually a double, so this should be revised in the future.
resp->success &= static_cast<bool>(command_interfaces_[REACTIVATE_GRIPPER_RESPONSE].get_optional().value_or(false));

return resp->success;
}
Expand Down
8 changes: 6 additions & 2 deletions robotiq_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(
target_link_libraries(
robotiq_driver
${THIS_PACKAGE_INCLUDE_DEPENDS}
hardware_interface::hardware_interface
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
serial::serial
)

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions robotiq_driver/include/robotiq_driver/hardware_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ class RobotiqGripperHardwareInterface : public hardware_interface::SystemInterfa
/**
* Initialization of the hardware interface from data parsed from the
* robot's URDF.
* @param hardware_info Structure with data from URDF.
* @param params Structure with parameters for initializing this hardware component.
* @returns CallbackReturn::SUCCESS if required data are provided and can be
* parsed or CallbackReturn::ERROR if any error happens or data are missing.
*/
ROBOTIQ_DRIVER_PUBLIC
CallbackReturn on_init(const hardware_interface::HardwareInfo& info) override;
CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams& params) override;

/**
* Connect to the hardware.
Expand Down
19 changes: 10 additions & 9 deletions robotiq_driver/src/hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,31 @@ RobotiqGripperHardwareInterface::RobotiqGripperHardwareInterface(std::unique_ptr
{
}

hardware_interface::CallbackReturn RobotiqGripperHardwareInterface::on_init(const hardware_interface::HardwareInfo& info)
hardware_interface::CallbackReturn
RobotiqGripperHardwareInterface::on_init(const hardware_interface::HardwareComponentInterfaceParams& params)
{
RCLCPP_DEBUG(kLogger, "on_init");

if (hardware_interface::SystemInterface::on_init(info) != CallbackReturn::SUCCESS)
if (hardware_interface::SystemInterface::on_init(params) != CallbackReturn::SUCCESS)
{
return CallbackReturn::ERROR;
}

// Read parameters.
gripper_closed_pos_ = stod(info_.hardware_parameters["gripper_closed_position"]);
gripper_closed_pos_ = stod(info_.hardware_parameters.at("gripper_closed_position"));
gripper_max_speed_ = info_.hardware_parameters.count("gripper_max_speed") ?
stod(info_.hardware_parameters["gripper_max_speed"]) :
stod(info_.hardware_parameters.at("gripper_max_speed")) :
kGripperMaxSpeed;
gripper_max_force_ = info_.hardware_parameters.count("gripper_max_force") ?
stod(info_.hardware_parameters["gripper_max_force"]) :
stod(info_.hardware_parameters.at("gripper_max_force")) :
kGripperMaxforce;
gripper_position_ = std::numeric_limits<double>::quiet_NaN();
gripper_velocity_ = std::numeric_limits<double>::quiet_NaN();
gripper_position_command_ = std::numeric_limits<double>::quiet_NaN();
reactivate_gripper_cmd_ = NO_NEW_CMD_;
reactivate_gripper_async_cmd_.store(false);

const hardware_interface::ComponentInfo& joint = info_.joints[0];
const hardware_interface::ComponentInfo& joint = info_.joints.at(0);

// There is one command interface: position.
if (joint.command_interfaces.size() != 1)
Expand All @@ -105,10 +106,10 @@ hardware_interface::CallbackReturn RobotiqGripperHardwareInterface::on_init(cons
return CallbackReturn::ERROR;
}

if (joint.command_interfaces[0].name != hardware_interface::HW_IF_POSITION)
if (joint.command_interfaces.at(0).name != hardware_interface::HW_IF_POSITION)
{
RCLCPP_FATAL(kLogger, "Joint '%s' has %s command interfaces found. '%s' expected.", joint.name.c_str(),
joint.command_interfaces[0].name.c_str(), hardware_interface::HW_IF_POSITION);
joint.command_interfaces.at(0).name.c_str(), hardware_interface::HW_IF_POSITION);
return CallbackReturn::ERROR;
}

Expand All @@ -126,7 +127,7 @@ hardware_interface::CallbackReturn RobotiqGripperHardwareInterface::on_init(cons
joint.state_interfaces[i].name == hardware_interface::HW_IF_VELOCITY))
{
RCLCPP_FATAL(kLogger, "Joint '%s' has %s state interface. Expected %s or %s.", joint.name.c_str(),
joint.state_interfaces[i].name.c_str(), hardware_interface::HW_IF_POSITION,
joint.state_interfaces.at(i).name.c_str(), hardware_interface::HW_IF_POSITION,
hardware_interface::HW_IF_VELOCITY);
return CallbackReturn::ERROR;
}
Expand Down
7 changes: 5 additions & 2 deletions robotiq_driver/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ ament_add_gmock(test_robotiq_gripper_hardware_interface
target_include_directories(test_robotiq_gripper_hardware_interface
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(test_robotiq_gripper_hardware_interface robotiq_driver)
ament_target_dependencies(test_robotiq_gripper_hardware_interface)
target_link_libraries(
test_robotiq_gripper_hardware_interface
robotiq_driver
hardware_interface::hardware_interface
)

###############################################################################
# test_default_serial_factory
Expand Down
2 changes: 1 addition & 1 deletion robotiq_hardware_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ add_executable(full_test
src/command_line_utility.hpp
src/command_line_utility.cpp
)
ament_target_dependencies(full_test robotiq_driver)
target_link_libraries(full_test robotiq_driver::robotiq_driver)

ament_package()
Loading