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

Increase thread count of Asyncspinner? (Multi-threading)

asked 2016-03-08 16:41:42 -0600

Borob gravatar image

Hey guys,

I have a world_node which offers a service to register_new_robot. Once called, the service creates a new C++ object from Robot.cpp. This Robot object now sets up a few topics mainly for controlling the robot (e.g. goToPose) in its contructor.

Now the problem is, when I create the object in my world_node service callback, my whole world_node blocks. I already used AsyncSpinner for multi-threaded calls already (e.g. the topic listeners in Robot), but here is the problem:

The number of robots is changing, which means that I don't know for how many threads I have to set up AsyncSpinner. The API does not offer adding a new thread, so what would you suggest to do? I could stop the spinner, create a new one with more threads, but that would cancel all the stuff currently done by the robots. I could also have the Robot object be created in the a main of it's class file and simply create a new node. But that seems even more messy than what I already do.

I use jade. Please help me.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-09 02:39:24 -0600

gvdhoorn gravatar image

Threads that don't have anything to do don't consume resources (well, the overhead is probably manageable). Is it an idea to set the nr of threads to some upper bound (say: 20)? Not really a solution ("640k is enough for everybody"), but would probably work well enough in practice.

edit flag offensive delete link more

Question Tools



Asked: 2016-03-08 16:41:42 -0600

Seen: 281 times

Last updated: Mar 08 '16