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