ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

waitForMessage ROS2 equivalent?

asked 2021-05-20 10:17:08 -0500

bvaningen gravatar image

updated 2021-05-20 10:19:29 -0500

In ROS1 there was the useful function ros::topic::waitForMessage(..). Is there an equivalent for ROS2 yet?

I have found the following question from a while ago: https://answers.ros.org/question/3073...

but maybe there is an easier solution available now.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2021-05-20 11:22:16 -0500

updated 2021-05-20 11:23:38 -0500

In short: there is not. Looking at the latest rclcpp API, I can also confirm that there is no equivalent there https://docs.ros2.org/latest/api/rclc....

While I'm not entirely confident to say that it would never be added, I find it highly unlikely that it would be added - though your link suggests it may be possible through the C API so perhaps it will be exposed at the C++ level at some point. Please create a subscriber as you ordinarily would. It would not be terribly difficult to create an object that contains a subscriber, a callback, and a getLatestMsg() function to get the latest message to have a similar effect.

edit flag offensive delete link more

Comments

all right, thanks for the clarification!

bvaningen gravatar image bvaningen  ( 2021-05-21 02:13:53 -0500 )edit
0

answered 2022-11-21 00:15:50 -0500

Huskinu gravatar image
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-05-20 10:17:08 -0500

Seen: 1,626 times

Last updated: Nov 21 '22