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

Isolate timer interface #447

Merged
merged 1 commit into from
Mar 24, 2022
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
5 changes: 4 additions & 1 deletion tf2_ros/include/tf2_ros/create_timer_ros.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class CreateTimerROS : public CreateTimerInterface
TF2_ROS_PUBLIC
CreateTimerROS(
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers);
rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers,
rclcpp::CallbackGroup::SharedPtr callback_group = nullptr);

virtual ~CreateTimerROS() = default;

Expand Down Expand Up @@ -123,6 +124,8 @@ class CreateTimerROS : public CreateTimerInterface
TimerHandle next_timer_handle_index_;
std::unordered_map<TimerHandle, rclcpp::TimerBase::SharedPtr> timers_map_;
std::mutex timers_map_mutex_;

rclcpp::CallbackGroup::SharedPtr callback_group_;
}; // class CreateTimerROS

} // namespace tf2_ros
Expand Down
9 changes: 6 additions & 3 deletions tf2_ros/src/create_timer_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ namespace tf2_ros

CreateTimerROS::CreateTimerROS(
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers)
: node_base_(node_base), node_timers_(node_timers), next_timer_handle_index_(0)
rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers,
rclcpp::CallbackGroup::SharedPtr callback_group)
: node_base_(node_base), node_timers_(node_timers), next_timer_handle_index_(0),
callback_group_(callback_group)
{
}

Expand All @@ -61,7 +63,8 @@ CreateTimerROS::createTimer(
node_timers_,
clock,
period,
std::bind(&CreateTimerROS::timerCallback, this, timer_handle_index, callback));
std::bind(&CreateTimerROS::timerCallback, this, timer_handle_index, callback),
callback_group_);
timers_map_[timer_handle_index] = timer;
return timer_handle_index;
}
Expand Down