Ask Your Question
7

rospy horrible performance with sim_time

asked 2012-03-09 04:18:34 -0600

Victor Lopez gravatar image

It is widely known that python isn't the best language when it comes to performance. But I've detected that mixing rospy and a simulation environment leads to awful performance.

Here's a quick example, run the following commands with and without gazebo running (or switching /use_sim_time from false to true while the simulator is running):

roscd rospy_tutorials/001_talker_listener/ ./listener.py

If you run a tool like top, you'll see that this listener node (which is doing nothing but waiting for the /chatter topic) is taking up around 10% of cpu time, depending on your computer. But with /use_sim_time = false it uses 0% cpu.

Things get worse if you start an ActionServer, cpu usage with sim time is 15% and cpu usage without it is still 0%.

My guess is that it is because of listening to the /time topic, but it still seems to be that this performance is unacceptable for an application that is doing nothing.

Is there any way to improve this situation? Are there any plans for the future?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2012-03-09 07:41:15 -0600

kwc gravatar image

The app isn't actually "doing nothing." It's having to follow the simulator's time, which will take some CPU.

On my Macbook Pro, 2.2Ghz, I can get the same CPU numbers if the simulator is publishing time at 1Khz, i.e. that is the load of deserializing 1000 clock messages a second. The clock rate is a function of your simulation step size and the speed of the simulation. You may, for example, to consider a smaller step size if you don't need that level of clock fidelity.

There are some tweaks that rospy can use to lower the CPU usage, but these would be small improvements. The fact is, running nodes in simulated time will add CPU load.

edit flag offensive delete link more

Comments

I understand that the application must listen to the time topic, what I meant to point out is that even taking this into account, if you start an Action Server, the cpu consumption with use_sim_time = true increases to 15% but with use_sim_time=false it remains at 0%.

Victor Lopez gravatar imageVictor Lopez ( 2012-03-11 22:18:49 -0600 )edit

Your Answer

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

Add Answer

Question Tools

3 followers

Stats

Asked: 2012-03-09 04:18:34 -0600

Seen: 627 times

Last updated: Mar 09 '12