Ask Your Question

Nodelet Publisher

asked 2016-11-18 09:57:10 -0500

ROSfc gravatar image
 virtual void onInit()
    ros::NodeHandle & private_nh = getPrivateNodeHandle();
    pub = private_nh.advertise<nodelet_test::buff>("chatter2", 10);
    nodelet_test::buff buffer;


I have the example code above for nodelet publisher only. Since I do not use callbacks (no subscriber ), is the way its done ? adding while loop inside onInit () ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-11-18 11:04:44 -0500

Dirk Thomas gravatar image

Reading the documentation of onInit it should not block. Basically it prevent the surrounding nodelet manager to continue initializing the other nodelets.

Instead you should create a timer in the onInit function and then publish your message in the triggered callback of the timer.

edit flag offensive delete link more


I would require 36Hz frequency of published messages, do you advice using a timer ? or do you see any problems arising ?

ROSfc gravatar image ROSfc  ( 2016-11-20 13:43:32 -0500 )edit

As you suggested I used createTimer and in that i could specify the frequency using ros::Duration

ROSfc gravatar image ROSfc  ( 2016-11-21 07:43:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-11-18 09:57:10 -0500

Seen: 784 times

Last updated: Nov 18 '16