Skip to content

Commit 1f83254

Browse files
committed
parameterize the joint name in the controller with interfaces
1 parent 2113614 commit 1f83254

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TestControllerWithInterfaces::TestControllerWithInterfaces()
2424
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
2525
TestControllerWithInterfaces::on_init()
2626
{
27+
auto_declare<std::string>("joint_name", "joint1");
2728
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;
2829
}
2930

@@ -36,6 +37,7 @@ controller_interface::return_type TestControllerWithInterfaces::update(
3637
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
3738
TestControllerWithInterfaces::on_configure(const rclcpp_lifecycle::State & /*previous_state&*/)
3839
{
40+
get_node()->get_parameter("joint_name", joint_name_);
3941
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;
4042
}
4143

controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
#ifndef TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_
1616
#define TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_
1717

18+
#include <string>
1819
#include "controller_interface/controller_interface.hpp"
1920
#include "controller_manager/visibility_control.h"
21+
#include "hardware_interface/types/hardware_interface_type_values.hpp"
2022

2123
namespace test_controller_with_interfaces
2224
{
2325
// Corresponds to the name listed within the pluginglib xml
2426
constexpr char TEST_CONTROLLER_WITH_INTERFACES_CLASS_NAME[] =
2527
"controller_manager/test_controller_with_interfaces";
26-
// Corresponds to the command interface to claim
27-
constexpr char TEST_CONTROLLER_COMMAND_INTERFACE[] = "joint1/effort";
2828
class TestControllerWithInterfaces : public controller_interface::ControllerInterface
2929
{
3030
public:
@@ -38,7 +38,7 @@ class TestControllerWithInterfaces : public controller_interface::ControllerInte
3838
{
3939
return controller_interface::InterfaceConfiguration{
4040
controller_interface::interface_configuration_type::INDIVIDUAL,
41-
{TEST_CONTROLLER_COMMAND_INTERFACE}};
41+
{joint_name_ + "/" + hardware_interface::HW_IF_EFFORT}};
4242
}
4343

4444
controller_interface::InterfaceConfiguration state_interface_configuration() const override
@@ -61,6 +61,9 @@ class TestControllerWithInterfaces : public controller_interface::ControllerInte
6161
CONTROLLER_MANAGER_PUBLIC
6262
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_cleanup(
6363
const rclcpp_lifecycle::State & previous_state) override;
64+
65+
protected:
66+
std::string joint_name_;
6467
};
6568

6669
} // namespace test_controller_with_interfaces

0 commit comments

Comments
 (0)