0
$\begingroup$

Rosanswers logo

Dear all,

a student approached me a day back with a question that I just couldn't answer: "Should a ROS timer be on a a private NodeHandle, or on a global one?" (or any other, obviously...)

We usually do something like the following:

ros::NodeHandle nh_         = ros::NodeHandle(""); // for subscribers/publishers/...
ros::NodeHandle private_nh_ = ros::NodeHandle("~"); // for parameters

For parameters, subscribers etc. there is a clear difference which NodeHandle is used to access/initialize them.

Is there any for Timers?

Thank you for your insights!


Originally posted by mgruhler on ROS Answers with karma: 12390 on 2016-04-29

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

A ROS timer does not have an associated ROS graph name, so the namespace of the nodehandle doesn't affect how the timer functions.

I believe (though I'm not entirely certain), that if your NodeHandles have different callback queues, then the timer callback will get called on queue of the associated NodeHandle. This is a fairly advanced use case and it requires explicit setup, so it's probably not something that most students will encounter.


Originally posted by ahendrix with karma: 47576 on 2016-05-05

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by mgruhler on 2016-05-09:
@ahendrix thanks. This sounds reasonable. And this is actually something nobody could answer here. :-)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.