Skip to content

Commit

Permalink
[ForwardCommandController] Fix the duplicate command interface types …
Browse files Browse the repository at this point in the history
…when reconfiguring the controller (backport #1568, #1570) (#1569)
  • Loading branch information
mergify[bot] authored Mar 4, 2025
1 parent 44a6f17 commit 5de2dfa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ TEST_F(JointGroupEffortControllerTest, ActivateWithWrongJointsNamesFails)
// activate failed, 'joint4' is not a valid joint name for the hardware
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

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

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

TEST_F(JointGroupEffortControllerTest, CommandSuccessTest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ controller_interface::CallbackReturn ForwardCommandController::read_parameters()
return controller_interface::CallbackReturn::ERROR;
}

command_interface_types_.clear();
for (const auto & joint : params_.joints)
{
command_interface_types_.push_back(joint + "/" + params_.interface_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ TEST_F(JointGroupPositionControllerTest, ActivateWithWrongJointsNamesFails)
// activate failed, 'joint4' is not a valid joint name for the hardware
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

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

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

TEST_F(JointGroupPositionControllerTest, CommandSuccessTest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ TEST_F(JointGroupVelocityControllerTest, ActivateWithWrongJointsNamesFails)
// activate failed, 'joint4' is not a valid joint name for the hardware
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

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

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

TEST_F(JointGroupVelocityControllerTest, CommandSuccessTest)
Expand Down

0 comments on commit 5de2dfa

Please sign in to comment.