Ask Your Question
0

ros publishing without loop?

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

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

Comments

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

bvbdort gravatar imagebvbdort ( 2014-10-17 03:50:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Stats

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

Seen: 602 times

Last updated: Oct 17 '14