Skip to content

Handle cases of state interfaces with different data types #1783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions joint_state_broadcaster/src/joint_state_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,29 @@ controller_interface::CallbackReturn JointStateBroadcaster::on_activate(
return CallbackReturn::ERROR;
}

// Erase the interfaces that are not castable to double
std::vector<hardware_interface::LoanedStateInterface> state_interfaces_to_keep;
std::for_each(
state_interfaces_.begin(), state_interfaces_.end(),
[&state_interfaces_to_keep](hardware_interface::LoanedStateInterface & si)
{
if (si.is_castable_to_double())
{
state_interfaces_to_keep.push_back(std::move(si));
}
else
{
RCLCPP_ERROR(
rclcpp::get_logger("JointStateBroadcaster"),
"State interface '%s' is not castable to double. "
"It will not be used in JointStateBroadcaster.",
si.get_name().c_str());
}
});

state_interfaces_.clear();
state_interfaces_ = std::move(state_interfaces_to_keep);

init_auxiliary_data();
init_joint_state_msg();
init_dynamic_joint_state_msg();
Expand Down
Loading