Using a python node in parallel mode
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