Skip to content
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

Remove use of get_callback_groups(). #320

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class PongNode : public rclcpp::Node
rclcpp::CallbackGroup::SharedPtr get_low_prio_callback_group();

private:
rclcpp::CallbackGroup::SharedPtr low_prio_callback_group_;

rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr high_ping_subscription_;
rclcpp::Publisher<std_msgs::msg::Int32>::SharedPtr high_pong_publisher_;
void high_ping_received(const std_msgs::msg::Int32::SharedPtr msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ PongNode::PongNode()
"high_ping", rclcpp::SensorDataQoS(),
std::bind(&PongNode::high_ping_received, this, _1));

auto second_cb_group = this->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
assert(second_cb_group == get_low_prio_callback_group());
low_prio_callback_group_ = this->create_callback_group(
rclcpp::CallbackGroupType::MutuallyExclusive);

declare_parameter<double>("low_busyloop", 0.01);
low_pong_publisher_ = this->create_publisher<Int32>("low_pong", rclcpp::SensorDataQoS());
rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>> options;
options.callback_group = second_cb_group;
options.callback_group = low_prio_callback_group_;
low_ping_subscription_ = this->create_subscription<Int32>(
"low_ping", rclcpp::SensorDataQoS(),
std::bind(&PongNode::low_ping_received, this, _1), options);
}

rclcpp::CallbackGroup::SharedPtr PongNode::get_high_prio_callback_group()
{
return get_callback_groups()[0].lock(); // ... the default callback group.
return get_node_base_interface()->get_default_callback_group(); // the default callback group.
}

rclcpp::CallbackGroup::SharedPtr PongNode::get_low_prio_callback_group()
{
return get_callback_groups()[1].lock(); // ... the second callback group created in the ctor.
return low_prio_callback_group_; // the second callback group created in the ctor.
}

void PongNode::high_ping_received(const std_msgs::msg::Int32::SharedPtr msg)
Expand Down