From 66a9b7ffa4486790d5d73f297a3c845034423aa1 Mon Sep 17 00:00:00 2001 From: Paul Gesel Date: Thu, 1 Feb 2024 16:09:28 -0700 Subject: [PATCH] add deprecation warning + fix test Signed-off-by: Paul Gesel --- .../antipodal_gripper_action_controller.hpp | 4 ++-- .../ros_control_plugins.xml | 2 +- .../antipodal_gripper_action_controller.cpp | 4 +++- .../test_antipodal_gripper_controller.cpp | 24 +++++-------------- .../test_antipodal_gripper_controller.hpp | 12 ++++++---- .../gripper_action_controller_impl.hpp | 5 ++++ 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/antipodal_gripper_controller/include/antipodal_gripper_controller/antipodal_gripper_action_controller.hpp b/antipodal_gripper_controller/include/antipodal_gripper_controller/antipodal_gripper_action_controller.hpp index 9581dce2dd..1f76c5c6d0 100644 --- a/antipodal_gripper_controller/include/antipodal_gripper_controller/antipodal_gripper_action_controller.hpp +++ b/antipodal_gripper_controller/include/antipodal_gripper_controller/antipodal_gripper_action_controller.hpp @@ -27,14 +27,14 @@ #include "rclcpp/rclcpp.hpp" // ROS messages -#include "control_msgs/action/gripper_command.hpp" +#include "control_msgs/action/gripper_command_velocity.hpp" // rclcpp_action #include "rclcpp_action/create_server.hpp" // ros_controls -#include "controller_interface/controller_interface.hpp" #include "antipodal_gripper_controller/visibility_control.hpp" +#include "controller_interface/controller_interface.hpp" #include "hardware_interface/loaned_command_interface.hpp" #include "hardware_interface/loaned_state_interface.hpp" #include "realtime_tools/realtime_buffer.h" diff --git a/antipodal_gripper_controller/ros_control_plugins.xml b/antipodal_gripper_controller/ros_control_plugins.xml index a276f3dd1b..5c55800f49 100644 --- a/antipodal_gripper_controller/ros_control_plugins.xml +++ b/antipodal_gripper_controller/ros_control_plugins.xml @@ -1,7 +1,7 @@ diff --git a/antipodal_gripper_controller/src/antipodal_gripper_action_controller.cpp b/antipodal_gripper_controller/src/antipodal_gripper_action_controller.cpp index 949388cd66..f7b6c651a8 100644 --- a/antipodal_gripper_controller/src/antipodal_gripper_action_controller.cpp +++ b/antipodal_gripper_controller/src/antipodal_gripper_action_controller.cpp @@ -20,4 +20,6 @@ #include "pluginlib/class_list_macros.hpp" -PLUGINLIB_EXPORT_CLASS(antipodal_gripper_action_controller::GripperActionController, controller_interface::ControllerInterface) \ No newline at end of file +PLUGINLIB_EXPORT_CLASS( + antipodal_gripper_action_controller::GripperActionController, + controller_interface::ControllerInterface) diff --git a/antipodal_gripper_controller/test/test_antipodal_gripper_controller.cpp b/antipodal_gripper_controller/test/test_antipodal_gripper_controller.cpp index 63a48fa41e..ba205616f8 100644 --- a/antipodal_gripper_controller/test/test_antipodal_gripper_controller.cpp +++ b/antipodal_gripper_controller/test/test_antipodal_gripper_controller.cpp @@ -34,18 +34,9 @@ using GoalHandle = rclcpp_action::ServerGoalHandle; using testing::SizeIs; using testing::UnorderedElementsAre; +void GripperControllerTest::SetUpTestCase() { rclcpp::init(0, nullptr); } -void GripperControllerTest::SetUpTestCase() -{ - rclcpp::init(0, nullptr); -} - - -void GripperControllerTest::TearDownTestCase() -{ - rclcpp::shutdown(); -} - +void GripperControllerTest::TearDownTestCase() { rclcpp::shutdown(); } void GripperControllerTest::SetUp() { @@ -53,12 +44,7 @@ void GripperControllerTest::SetUp() controller_ = std::make_unique(); } - -void GripperControllerTest::TearDown() -{ - controller_.reset(nullptr); -} - +void GripperControllerTest::TearDown() { controller_.reset(nullptr); } void GripperControllerTest::SetUpController() { @@ -109,7 +95,9 @@ TEST_F(GripperControllerTest, ConfigureParamsSuccess) // check interface configuration auto cmd_if_conf = this->controller_->command_interface_configuration(); ASSERT_THAT(cmd_if_conf.names, SizeIs(1lu)); - ASSERT_THAT(cmd_if_conf.names, UnorderedElementsAre(std::string("joint_1/") + hardware_interface::HW_IF_POSITION)); + ASSERT_THAT( + cmd_if_conf.names, + UnorderedElementsAre(std::string("joint_1/") + hardware_interface::HW_IF_POSITION)); EXPECT_EQ(cmd_if_conf.type, controller_interface::interface_configuration_type::INDIVIDUAL); auto state_if_conf = this->controller_->state_interface_configuration(); ASSERT_THAT(state_if_conf.names, SizeIs(2lu)); diff --git a/antipodal_gripper_controller/test/test_antipodal_gripper_controller.hpp b/antipodal_gripper_controller/test/test_antipodal_gripper_controller.hpp index 53daf48acc..7b3a7036f7 100644 --- a/antipodal_gripper_controller/test/test_antipodal_gripper_controller.hpp +++ b/antipodal_gripper_controller/test/test_antipodal_gripper_controller.hpp @@ -28,8 +28,7 @@ namespace { // subclassing and friending so we can access member variables -class FriendGripperController -: public antipodal_gripper_action_controller::GripperActionController +class FriendGripperController : public antipodal_gripper_action_controller::GripperActionController { FRIEND_TEST(GripperControllerTest, CommandSuccessTest); }; @@ -54,9 +53,12 @@ class GripperControllerTest : public ::testing::Test std::vector joint_states_ = {1.1, 2.1}; std::vector joint_commands_ = {3.1}; - hardware_interface::StateInterface joint_1_pos_state_{joint_name_, hardware_interface::HW_IF_POSITION, &joint_states_[0]}; - hardware_interface::StateInterface joint_1_vel_state_{joint_name_, hardware_interface::HW_IF_VELOCITY, &joint_states_[1]}; - hardware_interface::CommandInterface joint_1_cmd_{joint_name_, hardware_interface::HW_IF_POSITION, &joint_commands_[0]}; + hardware_interface::StateInterface joint_1_pos_state_{ + joint_name_, hardware_interface::HW_IF_POSITION, &joint_states_[0]}; + hardware_interface::StateInterface joint_1_vel_state_{ + joint_name_, hardware_interface::HW_IF_VELOCITY, &joint_states_[1]}; + hardware_interface::CommandInterface joint_1_cmd_{ + joint_name_, hardware_interface::HW_IF_POSITION, &joint_commands_[0]}; }; } // anonymous namespace diff --git a/gripper_controllers/include/gripper_controllers/gripper_action_controller_impl.hpp b/gripper_controllers/include/gripper_controllers/gripper_action_controller_impl.hpp index 77598591ae..2b1e0d1fe2 100644 --- a/gripper_controllers/include/gripper_controllers/gripper_action_controller_impl.hpp +++ b/gripper_controllers/include/gripper_controllers/gripper_action_controller_impl.hpp @@ -40,6 +40,11 @@ void GripperActionController::preempt_active_goal() template controller_interface::CallbackReturn GripperActionController::on_init() { + RCLCPP_WARN( + get_node()->get_logger(), + "[Deprecated]: the `position_controllers/GripperActionController` and " + "`effort_controllers::GripperActionController` controllers are replaced by " + "'antipodal_position_controllers/GripperActionController' controller"); try { param_listener_ = std::make_shared(get_node());