Skip to content

Commit

Permalink
Also add size checks similar to the reference interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Oct 8, 2024
1 parent 59a38e8 commit c48e3c7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions controller_interface/src/chainable_controller_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ ChainableControllerInterface::export_state_interfaces()
std::const_pointer_cast<const hardware_interface::StateInterface>(state_interface));
}

if (exported_state_interfaces_.size() != state_interfaces.size())
{
std::string error_msg =
"The internal storage for state interface ptrs 'exported_state_interfaces_' variable has "
"size '" +
std::to_string(exported_state_interfaces_.size()) +
"', but it is expected to have the size '" + std::to_string(state_interfaces.size()) +
"' equal to the number of exported reference interfaces. Please correct and recompile the "
"controller with name '" +
get_node()->get_name() + "' and try again.";
throw std::runtime_error(error_msg);
}

return state_interfaces_ptrs_vec;
}

Expand Down

0 comments on commit c48e3c7

Please sign in to comment.