[ros-users] Problems with subscriber and spinOnce

Aslund sebastian.aslund at gmail.com
Thu Feb 17 10:20:00 UTC 2011


Hey everyone

I got a small problem writting a subscriber using the spinOnce command
instead of the spin() used in the tutorial. I do not receive anything from
the subscription, but I know topics are being published. rviz is showing
that the data is published and if I rewrite the code to use spin() like in
the tutorial, then I get plenty of information. I have tried to search the
problem but did not find anything useful and I hope someone here can see the
problem.

My code is:

int main(int argc, char **argv)
{
        init(argc, argv, "testPlayer");
        NodeHandle n;

        Subscriber sub;

        Rate loop_rate(5);

        testPlayer test;

        while ( ok() ) {

            sub = n.subscribe("scan", 1000, &testPlayer::callBack, &test);

            spinOnce();

            loop_rate.sleep();
        }

  return 0;
}

Regards

Sebastian Aslund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20110217/9e54bb53/attachment-0002.html>


More information about the ros-users mailing list