Ask Your Question

ros publishing without loop?

asked 2014-10-17 03:35:33 -0500

Robot gravatar image

If I am publishing a "geometry_msgs::Twist" with out a while(n.ok()) loop it is not affecting the topic. But I can not use a infinite loop. Everytime according the scan data I have to modify the linear and angular velocity of the Twist msgs. Is there any way out to affect the topic without using the loop.. Thanks in advance

edit retag flag offensive close merge delete


can you write more about issue , also if possible the code.

bvbdort gravatar image bvbdort  ( 2014-10-17 03:50:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-17 04:58:47 -0500

Wolf gravatar image

There are some possiblities to publish outside the while loop, e. g.

--> publishing in a subcriber callback (suitable if your node dows only few processing and your published out message only depends on the incoming messages, e. g. for any kind of republishers) --> publishing in a timer callback (if you want to publish at constant rate outside the while (ros::ok()) loop )

Note that you should set up your publisher before initializing the Subscriber/Timer and your publisher should be visible inside the callback (local publisher object not possible anymore).

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

1 follower


Asked: 2014-10-17 03:35:33 -0500

Seen: 742 times

Last updated: Oct 17 '14