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

Subcriber callback within a while loop?

asked 2015-03-18 15:50:53 -0500

215 gravatar image

Is it possible for a subscriber to make a callback within a while loop?... if so how then..

In my case i am Subscribing to topic which giving me a position of a robot. I have a array of 8 positions.

double position[8] = {2.0 , 3, 3.0, ...}

And in a while in a loop, I make to robot walk to those position, one after one. i

nt  i = 0
while(i<8)
{
    robotposition = position[i];
   if(real_position == robotposition){
    i++;
   }
}

Here is the real_position, the real position of the robot, which I receive from a callback function.. The problem here is though that this value doesn't get updated when it is in the while loop.. and i don't why.. how do i do that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-03-18 16:57:01 -0500

Jim Rothrock gravatar image

Call ros::spinOnce() in the loop. That will cause callbacks to be called.

edit flag offensive delete link more

Comments

I just love you <3

215 gravatar image 215  ( 2015-03-18 17:09:22 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-18 15:50:53 -0500

Seen: 1,831 times

Last updated: Mar 18 '15