Skip to content

Commit

Permalink
parameterize the joint
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Aug 10, 2024
1 parent 2113614 commit b2ae510
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ TestControllerWithInterfaces::TestControllerWithInterfaces()
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
TestControllerWithInterfaces::on_init()
{
auto_declare<std::string>("joint_name", "joint1");
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;
}

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#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:
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b2ae510

Please sign in to comment.