ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to use spin_once for ROS2 foxy rclcpp?

asked 2022-12-14 13:19:31 -0500

dvy gravatar image

updated 2022-12-14 13:20:41 -0500


System used: ROS2 foxy on Ubuntu 20.04 on amd64 architecture.

I use VS Code. In python, I have easily used rospy.spin_once as VS Code provides me the suggestions as soon as I type dot. In python, I see rclpy.spin, rclpy.spin_once, and rclpy.spin_until_future_complete But when I try to do the same for a C++ code, I don't find rclcpp::spin_once. Instead, I see rclcpp::spin, rclcpp::spin_some, and rclcpp::spin_until_future_complete only. So, this makes me think that spin_some is absent in rclpy and spin_once is absent in rclcpp.

I found one example on the internet which used spin_once with rclcpp here but don't understand it.

Any idea how to use the functionality provided by rclpy.spin_once in rclcpp?

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2022-12-15 07:17:49 -0500

ljaniec gravatar image

I think these links have all the info you need.

You can see in the rclcpp documentation that you have spin_once, but I couldn't find many use in some projects I skimmed on Github - usually you would use spin_until_future_complete (e.g. Nav2 uses it a lot).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2022-12-14 13:19:31 -0500

Seen: 83 times

Last updated: Dec 15 '22