Skip to content

Commit c8c1088

Browse files
committed
Update chainable controller for tests.
1 parent bc84cf6 commit c8c1088

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

controller_manager/test/test_chainable_controller/test_chainable_controller.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,8 @@ TestChainableController::state_interface_configuration() const
6161
}
6262
}
6363

64-
controller_interface::return_type TestChainableController::update(
65-
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
64+
controller_interface::return_type TestChainableController::update_reference_from_subscribers()
6665
{
67-
++internal_counter;
68-
6966
for (size_t i = 0; i < reference_interfaces_.size(); ++i)
7067
{
7168
RCLCPP_INFO(
@@ -75,20 +72,25 @@ controller_interface::return_type TestChainableController::update(
7572
reference_interfaces_[i]);
7673
}
7774

78-
if (!is_in_chained_mode())
75+
auto joint_commands = rt_command_ptr_.readFromRT();
76+
reference_interfaces_ = (*joint_commands)->data;
77+
for (size_t i = 0; i < reference_interfaces_.size(); ++i)
7978
{
80-
auto joint_commands = rt_command_ptr_.readFromRT();
81-
reference_interfaces_ = (*joint_commands)->data;
82-
for (size_t i = 0; i < reference_interfaces_.size(); ++i)
83-
{
84-
RCLCPP_INFO(
85-
get_node()->get_logger(),
86-
"Updated value of reference interface '%s' after applying external input is %f",
87-
(std::string(get_node()->get_name()) + "/" + reference_interface_names_[i]).c_str(),
88-
reference_interfaces_[i]);
89-
}
79+
RCLCPP_INFO(
80+
get_node()->get_logger(),
81+
"Updated value of reference interface '%s' after applying external input is %f",
82+
(std::string(get_node()->get_name()) + "/" + reference_interface_names_[i]).c_str(),
83+
reference_interfaces_[i]);
9084
}
9185

86+
return controller_interface::return_type::OK;
87+
}
88+
89+
controller_interface::return_type TestChainableController::update_and_write_commands(
90+
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
91+
{
92+
++internal_counter;
93+
9294
for (size_t i = 0; i < command_interfaces_.size(); ++i)
9395
{
9496
command_interfaces_[i].set_value(reference_interfaces_[i] - state_interfaces_[i].get_value());

controller_manager/test/test_chainable_controller/test_chainable_controller.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ class TestChainableController : public controller_interface::ChainableController
4848

4949
controller_interface::InterfaceConfiguration state_interface_configuration() const override;
5050

51-
CONTROLLER_MANAGER_PUBLIC
52-
controller_interface::return_type update(
53-
const rclcpp::Time & time, const rclcpp::Duration & period) override;
54-
5551
CONTROLLER_MANAGER_PUBLIC
5652
CallbackReturn on_init() override;
5753

@@ -67,6 +63,11 @@ class TestChainableController : public controller_interface::ChainableController
6763
CONTROLLER_MANAGER_PUBLIC
6864
std::vector<hardware_interface::CommandInterface> on_export_reference_interfaces() override;
6965

66+
controller_interface::return_type update_reference_from_subscribers() override;
67+
68+
controller_interface::return_type update_and_write_commands(
69+
const rclcpp::Time & time, const rclcpp::Duration & period) override;
70+
7071
// Testing-relevant methods
7172
CONTROLLER_MANAGER_PUBLIC
7273
void set_command_interface_configuration(

0 commit comments

Comments
 (0)