From b2ae510e975ad56941626ac0f8851684eb13d37c Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Sat, 10 Aug 2024 13:16:54 +0200 Subject: [PATCH] parameterize the joint --- .../test_controller_with_interfaces.cpp | 2 ++ .../test_controller_with_interfaces.hpp | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.cpp b/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.cpp index d5695e41e53..16ca7f898a0 100644 --- a/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.cpp +++ b/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.cpp @@ -24,6 +24,7 @@ TestControllerWithInterfaces::TestControllerWithInterfaces() rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn TestControllerWithInterfaces::on_init() { + auto_declare("joint_name", "joint1"); return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; } @@ -36,6 +37,7 @@ controller_interface::return_type TestControllerWithInterfaces::update( rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn TestControllerWithInterfaces::on_configure(const rclcpp_lifecycle::State & /*previous_state&*/) { + get_node()->get_parameter("joint_name", joint_name_); return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; } diff --git a/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.hpp b/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.hpp index a7f5da1ef39..418ab699e90 100644 --- a/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.hpp +++ b/controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.hpp @@ -15,16 +15,16 @@ #ifndef TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_ #define TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_ +#include #include "controller_interface/controller_interface.hpp" #include "controller_manager/visibility_control.h" +#include "hardware_interface/types/hardware_interface_type_values.hpp" namespace test_controller_with_interfaces { // Corresponds to the name listed within the pluginglib xml constexpr char TEST_CONTROLLER_WITH_INTERFACES_CLASS_NAME[] = "controller_manager/test_controller_with_interfaces"; -// Corresponds to the command interface to claim -constexpr char TEST_CONTROLLER_COMMAND_INTERFACE[] = "joint1/effort"; class TestControllerWithInterfaces : public controller_interface::ControllerInterface { public: @@ -38,7 +38,7 @@ class TestControllerWithInterfaces : public controller_interface::ControllerInte { return controller_interface::InterfaceConfiguration{ controller_interface::interface_configuration_type::INDIVIDUAL, - {TEST_CONTROLLER_COMMAND_INTERFACE}}; + {joint_name_ + "/" + hardware_interface::HW_IF_EFFORT}}; } controller_interface::InterfaceConfiguration state_interface_configuration() const override @@ -61,6 +61,9 @@ class TestControllerWithInterfaces : public controller_interface::ControllerInte CONTROLLER_MANAGER_PUBLIC rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_cleanup( const rclcpp_lifecycle::State & previous_state) override; + +protected: + std::string joint_name_; }; } // namespace test_controller_with_interfaces