Hi, Your subscriber should be instantiated outside of your loop: int main(int argc, char **argv) { init(argc, argv, "testPlayer"); NodeHandle n; Subscriber sub; sub = n.subscribe("scan", 1000, &testPlayer::callBack, &test); Rate loop_rate(5); testPlayer test; while ( ok() ) { spinOnce(); loop_rate.sleep(); } return 0; } This should work normally. Cheers, Ugo On Thu, Feb 17, 2011 at 10:20 AM, Aslund wrote: > 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: > > > Regards > > Sebastian Aslund > > > > _______________________________________________ > ros-users mailing list > ros-users@code.ros.org > https://code.ros.org/mailman/listinfo/ros-users > > -- Ugo Cupcic | Shadow Robot Company | ugo@shadowrobot.com Software Engineer | 251 Liverpool Road | need a Hand? | London N1 1LX | +44 20 7700 2487 http://www.shadowrobot.com/hand/ @shadowrobot