Skip to content

Commit

Permalink
remove one of the redundant checks with the new approach
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jun 20, 2024
1 parent bbca8ac commit 4f97b54
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
27 changes: 0 additions & 27 deletions controller_interface/src/chainable_controller_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ std::vector<hardware_interface::StateInterface>
ChainableControllerInterface::export_state_interfaces()
{
auto state_interfaces = on_export_state_interfaces();
// check if the "state_interfaces_values_" variable is resized to number of interfaces
if (state_interfaces_values_.size() != state_interfaces.size())
{
RCLCPP_FATAL(
get_node()->get_logger(),
"The internal storage for exported state values 'state_interfaces_values_' variable has size "
"'%zu', but it is expected to have the size '%zu' equal to the number of exported state "
"interfaces. No state interface will be exported. Please correct and recompile "
"the controller with name '%s' and try again.",
state_interfaces_values_.size(), state_interfaces.size(), get_node()->get_name());
state_interfaces.clear();
}

// check if the names of the controller state interfaces begin with the controller's name
for (const auto & interface : state_interfaces)
Expand All @@ -85,21 +73,6 @@ ChainableControllerInterface::export_reference_interfaces()
{
auto reference_interfaces = on_export_reference_interfaces();

// check if the "reference_interfaces_" variable is resized to number of interfaces
if (reference_interfaces_.size() != reference_interfaces.size())
{
// TODO(destogl): Should here be "FATAL"? It is fatal in terms of controller but not for the
// framework
RCLCPP_FATAL(
get_node()->get_logger(),
"The internal storage for reference values 'reference_interfaces_' variable has size '%zu', "
"but it is expected to have the size '%zu' equal to the number of exported reference "
"interfaces. No reference interface will be exported. Please correct and recompile "
"the controller with name '%s' and try again.",
reference_interfaces_.size(), reference_interfaces.size(), get_node()->get_name());
reference_interfaces.clear();
}

// check if the names of the reference interfaces begin with the controller's name
for (const auto & interface : reference_interfaces)
{
Expand Down
21 changes: 0 additions & 21 deletions controller_interface/test/test_chainable_controller_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,6 @@ TEST_F(ChainableControllerInterfaceTest, export_reference_interfaces)
EXPECT_EQ(reference_interfaces[0].get_value(), INTERFACE_VALUE);
}

TEST_F(ChainableControllerInterfaceTest, interfaces_storage_not_correct_size)
{
TestableChainableControllerInterface controller;

// initialize, create node
const auto node_options = controller.define_custom_node_options();
ASSERT_EQ(
controller.init(TEST_CONTROLLER_NAME, "", 50.0, "", node_options),
controller_interface::return_type::OK);
ASSERT_NO_THROW(controller.get_node());

// expect empty return because storage is not resized
controller.reference_interfaces_.clear();
auto reference_interfaces = controller.export_reference_interfaces();
ASSERT_THAT(reference_interfaces, IsEmpty());
// expect empty return because storage is not resized
controller.state_interfaces_values_.clear();
auto exported_state_interfaces = controller.export_state_interfaces();
ASSERT_THAT(exported_state_interfaces, IsEmpty());
}

TEST_F(ChainableControllerInterfaceTest, interfaces_prefix_is_not_node_name)
{
TestableChainableControllerInterface controller;
Expand Down

0 comments on commit 4f97b54

Please sign in to comment.