Skip to content

Commit

Permalink
Fix usage of rclcpp::ok with a non-default context (#352)
Browse files Browse the repository at this point in the history
* Fix usage of rclcpp::ok with a non-default context

The current implementation calls `rclcpp::ok` without any arguments,
which amounts to verifying that the global default context is valid. In
the case where a node is added to a custom context, and the global
context is not used, `rclcpp::ok` without any arguments will always
return `false` since the global context has never been initialized. To
fix it, pass to rclcpp the context that's available via the node's base
interface.

* Add a test for custom context

Signed-off-by: Christian Henkel <[email protected]>
  • Loading branch information
haudren-woven authored and ct2034 committed Jul 22, 2024
1 parent 3ab8233 commit 423e7f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion diagnostic_updater/src/diagnostic_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void Updater::reset_timer()

void Updater::update()
{
if (rclcpp::ok()) {
if (rclcpp::ok(base_interface_->get_context())) {
bool warn_nohwid = hwid_.empty();

std::vector<diagnostic_msgs::msg::DiagnosticStatus> status_vec;
Expand Down

0 comments on commit 423e7f6

Please sign in to comment.