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

How to run ros::spin in the background

asked 2015-05-30 10:07:44 -0500

arjunsurendrans gravatar image

Hi,

I have a qt application and which has many Callbacks. As I dont have and infinite loop, I can't write ros::spin(). I would like to have ros::spin() or spinonce() in the background. How can i achieve using multi-threading. Any help would be highly appreciated

Thanks, Arjun

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-05-30 11:10:55 -0500

gvdhoorn gravatar image

updated 2015-05-30 11:48:25 -0500

ROS, spin() and multi-threading has been asked a few times already. Some earlier questions & answers:

And just for completeness, the authoritative source roscpp/Overview/Callbacks and Spinning.

In your case an AsyncSpinner is probably a good option (from roscpp/Overview/Callbacks and Spinning - Multi-threaded Spinning):

ros::AsyncSpinner spinner(4); // Use 4 threads
spinner.start();
edit flag offensive delete link more

Comments

Thank you for your quick reply

arjunsurendrans gravatar image arjunsurendrans  ( 2015-06-01 03:34:29 -0500 )edit

I read these links, and I do it in the same way,but it doesn't work in my pro. 1.I run spin() in boost::thread,and subscribe in Goal::Goal()(ie: ros::Subscriber sub = nh_.subscribe<actionlib_msgs::goalstatusarray>("/move_base/status",100,fun_cb);) but the thread also block my GUI.Thanks your help

zzzZuo gravatar image zzzZuo  ( 2015-12-30 20:50:32 -0500 )edit

Question Tools

Stats

Asked: 2015-05-30 10:07:44 -0500

Seen: 2,500 times

Last updated: May 30 '15