Skip to content

Add wait_for_message overload using node interfaces (backport #3230) - #3233

Open
mergify[bot] wants to merge 2 commits into
lyricalfrom
mergify/bp/lyrical/pr-3230
Open

Add wait_for_message overload using node interfaces (backport #3230)#3233
mergify[bot] wants to merge 2 commits into
lyricalfrom
mergify/bp/lyrical/pr-3230

Conversation

@mergify

@mergify mergify Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Description

Add a rclcpp::wait_for_message overload that takes NodeParametersInterface and NodeTopicsInterface instead of rclcpp::Node::SharedPtr.

The existing topic convenience overload requires a Node::SharedPtr, so it cannot be used with rclcpp_lifecycle::LifecycleNode, or during node construction when shared_from_this() is unavailable. The new overload uses the same rclcpp::create_subscription interface path already used elsewhere in rclcpp. The Node::SharedPtr overload now delegates to it.

Also extend coverage with:

  • unit tests for the explicit-interfaces overload in rclcpp
  • an isolated gtest in rclcpp_lifecycle that waits via a LifecycleNode held in a unique_ptr (no shared_from_this)

Related to #1953 (LifecycleNode / non-Node::SharedPtr support from the original proposal). This does not address the still-open executor / wait-set concern discussed there (calling wait_for_message from inside a node already managed by an executor).

Is this user-facing behavior change?

Yes. Callers can wait for a topic message using node interfaces, which enables LifecycleNode and construction-time use without shared_from_this(). Existing Node::SharedPtr and subscription+context overloads are unchanged in behavior.

Did you use Generative AI?

Yes. Cursor (Grok) was used to help draft the overload, tests, and this PR description. Changes were reviewed, adjusted and tested manually.

Additional Information

Example:

std_msgs::msg::String msg;
rclcpp::wait_for_message(
  msg,
  this->get_node_parameters_interface(),
  this->get_node_topics_interface(),
  "my_topic",
  std::chrono::seconds(1));

Tested via:

colcon test \
  --packages-select rclcpp rclcpp_lifecycle \
  --ctest-args -R 'wait_for_message' \
  --event-handlers console_direct+
```<hr>This is an automatic backport of pull request #3230 done by [Mergify](https://mergify.com).

Signed-off-by: Yadunund Vijay <yadunund@gmail.com>
(cherry picked from commit 5dd47aa)

# Conflicts:
#	rclcpp_lifecycle/CMakeLists.txt
@mergify mergify Bot added the conflicts label Aug 22, 2026
@mergify

mergify Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 5dd47aa has failed:

On branch mergify/bp/lyrical/pr-3230
Your branch is up to date with 'origin/lyrical'.

You are currently cherry-picking commit 5dd47aa.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   rclcpp/include/rclcpp/wait_for_message.hpp
	modified:   rclcpp/test/rclcpp/test_wait_for_message.cpp
	new file:   rclcpp_lifecycle/test/test_lifecycle_wait_for_message.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   rclcpp_lifecycle/CMakeLists.txt

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify

mergify Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Signed-off-by: Tomoya.Fujita <fujita.tomoya@triorb.co.jp>
@fujitatomoya
fujitatomoya requested a review from Yadunund August 22, 2026 06:33
@fujitatomoya fujitatomoya self-assigned this Aug 22, 2026
@fujitatomoya

Copy link
Copy Markdown
Collaborator

@Yadunund i need your approval on this before merge, since i resolved the conflicts.

@fujitatomoya

Copy link
Copy Markdown
Collaborator

Pulls: #3233
Gist: https://gist.githubusercontent.com/fujitatomoya/0a44e99cdcef71ae57bea53098b94462/raw/4539a435d037796c90f5ba4a71801e396a801da4/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: lyrical
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20160

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants