ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Long initialization in nodelet

asked 2018-02-19 10:45:51 -0500

Tibor Takacs gravatar image

On page http://wiki.ros.org/nodelet#Threading... the following is written:

1.6.1 onInit

This method is called on init and should not block or do significant work.

If the nodelet initialization process takes longer (e.g. reading data from database and process it etc.) what is the best practice to execute the long initialization process without blocking the onInit() call? One possible solution is to create a worker thread in the onInit() method which does the long initialization without blocking the call but I am wondering is there any "ROS pattern" to do this job?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-19 12:16:21 -0500

ahendrix gravatar image

onInit() is called on the nodelet manager's callback thread, so it will block all other nodelets if you are using a single-threaded nodelet manager.

If you need to do a long-running initialization you could use a separate loader thread, or if you have C++11 you could use some of the async or futures primitives that were introduced in C++11.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-02-19 10:45:51 -0500

Seen: 333 times

Last updated: Feb 19 '18