Skip to content

Commit 5de2dfa

Browse files
authored
[ForwardCommandController] Fix the duplicate command interface types when reconfiguring the controller (backport #1568, #1570) (#1569)
1 parent 44a6f17 commit 5de2dfa

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

effort_controllers/test/test_joint_group_effort_controller.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ TEST_F(JointGroupEffortControllerTest, ActivateWithWrongJointsNamesFails)
8989
// activate failed, 'joint4' is not a valid joint name for the hardware
9090
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9191
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
92+
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9293

9394
controller_->get_node()->set_parameter({"joints", std::vector<std::string>{"joint1", "joint2"}});
9495

95-
// activate failed, 'acceleration' is not a registered interface for `joint1`
96+
// activate should succeed now
9697
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
97-
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
98+
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9899
}
99100

100101
TEST_F(JointGroupEffortControllerTest, CommandSuccessTest)

forward_command_controller/src/forward_command_controller.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ controller_interface::CallbackReturn ForwardCommandController::read_parameters()
5353
return controller_interface::CallbackReturn::ERROR;
5454
}
5555

56+
command_interface_types_.clear();
5657
for (const auto & joint : params_.joints)
5758
{
5859
command_interface_types_.push_back(joint + "/" + params_.interface_name);

position_controllers/test/test_joint_group_position_controller.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ TEST_F(JointGroupPositionControllerTest, ActivateWithWrongJointsNamesFails)
8989
// activate failed, 'joint4' is not a valid joint name for the hardware
9090
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9191
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
92+
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9293

9394
controller_->get_node()->set_parameter({"joints", std::vector<std::string>{"joint1", "joint2"}});
9495

95-
// activate failed, 'acceleration' is not a registered interface for `joint1`
96+
// activate should succeed now
9697
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
97-
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
98+
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9899
}
99100

100101
TEST_F(JointGroupPositionControllerTest, CommandSuccessTest)

velocity_controllers/test/test_joint_group_velocity_controller.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ TEST_F(JointGroupVelocityControllerTest, ActivateWithWrongJointsNamesFails)
8989
// activate failed, 'joint4' is not a valid joint name for the hardware
9090
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9191
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
92+
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9293

9394
controller_->get_node()->set_parameter({"joints", std::vector<std::string>{"joint1", "joint2"}});
9495

95-
// activate failed, 'acceleration' is not a registered interface for `joint1`
96+
// activate should succeed now
9697
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
97-
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
98+
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9899
}
99100

100101
TEST_F(JointGroupVelocityControllerTest, CommandSuccessTest)

0 commit comments

Comments
 (0)