0
$\begingroup$

Rosanswers logo

Hi, we are using ROS to simulate planes and run collision avoidance algorithms.

I wrote my collision avoidance algorithm as a python node in ROS that imports parallel python and uses parallel threading to send jobs to the 4 cores of my cpus to speed up computation. When I run this python file independent of ros all 4 cores get used as I see in my system monitor. However when I launch this node from ROS, only one cpu gets used.

This baffles me because I use the following parallel python code,

import pp
job_server = pp.Server()
print "Starting pp with", job_server.get_ncpus(), "workers"

and I get 4 workers (the number of cores my computer has) in both cases. However when I am actually running it through ROS I can clearly tell only 1 core is being used through activity monitor.

Fixing this problem is very important to me because my algorithm is very computationally expensive and I think it freezes up Ros which makes the planes miss their waypoints and run into infinite loops or crash into each other. I would like to enable multi-threading in the ros environment to improve the situation. I went through the documentation online and I could not find any parameters for launching my python node in away that Ros allows it to use all 4 cpus. Or perhaps, I tried using export ROS_PARALLEL_JOBS=-l4 , in my bashrc before doing a rosmake but that was not helpful.

Ultimately, I hope to be able to devote ros to core 0, and my algorithm to cores 1,2,3 so that my planes do not get interruptions in their commands.

Any help or suggestions would be helpful. I am using ros 1.4.8

If you need any additional info from me please let me know.

Thanks,

Waseem


Originally posted by encryptedmaniac on ROS Answers with karma: 11 on 2011-07-03

Post score: 1


Original comments

Comment by mmwise on 2011-07-03:
Please read the guidelines for asking questions: http://www.ros.org/wiki/Support. ROS answers is a community supported forum please be respectful of the community guidelines when posting.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

ROS_PARALLEL_JOBS isn't the right variable; that's used for rosbuild parallelism. Nothing in ROS is going to keep your node from multithreading; nodes are their own OS-level processes. Something is going wrong with your node; I would investigate to make sure you can get data into your node fast enough.


Originally posted by Mac with karma: 4119 on 2011-09-02

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

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