Ask Your Question
1

Using a python node in parallel mode

asked 2011-07-03 08:26:25 -0500

encryptedmaniac gravatar image

updated 2011-11-17 14:55:59 -0500

joq gravatar image

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

edit retag flag offensive close merge delete

Comments

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.
mmwise gravatar image mmwise  ( 2011-07-03 18:14:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-09-02 11:58:38 -0500

Mac gravatar image

updated 2011-11-17 12:40:57 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-07-03 08:26:25 -0500

Seen: 983 times

Last updated: Nov 17 '11