Robotics StackExchange | Archived questions

How to use spin_once for ROS2 foxy rclcpp?

Hi,

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!

Asked by dvy on 2022-12-14 14:19:31 UTC

Comments

Answers

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).

Asked by ljaniec on 2022-12-15 08:17:49 UTC

Comments