ros::spin() can't work contione

asked 2015-05-26 03:33:08 -0600

cros gravatar image

updated 2015-05-26 03:34:26 -0600

when I subscribe a message (ros::Subscriber sub=nh.subscribe("message",1000,callback);)and I put the ros::spin() in a subprocess(if(fork==0){ros::spin()}), it can't work as expected, it can't subscribe the message contione, only 999 messages can be subscribed,but when I put the spin() out of the If(fork==0),it can work as usual.

edit retag flag offensive close merge delete

Comments

I am asking a stupid question but did you check if fork is equal to zero with as basic printout as example ? What is the variable fork ? Is the code if (fork==0)inside a thread ?

Fleurmond gravatar image Fleurmond  ( 2015-05-26 11:05:24 -0600 )edit

I have checked it. it can work, fork==0 means inside a subprocess,

cros gravatar image cros  ( 2015-05-27 06:20:33 -0600 )edit

Could I suggest you to check this two pages: This question: http://answers.ros.org/question/53055... make me think your could be a duplicate. And the theory http://wiki.ros.org/roscpp/Overview/C... .

Fleurmond gravatar image Fleurmond  ( 2015-05-27 08:44:57 -0600 )edit