0
$\begingroup$

Rosanswers logo

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.


Originally posted by Borob on ROS Answers with karma: 111 on 2016-03-08

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2016-03-09

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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