Gazebo | Ignition | Community
Ask Your Question
0

Get Real Time Factor (RTF) Programmatically?

asked 2017-06-27 09:57:46 -0500

csano gravatar image

Hello,

I've been trying to get the GUI Real Time Factor programmatically, and I had various issues trying to do so. Here were a couple things I found from looking around that did not work:

  1. Subscribing to ~/diagnostics: the rtf given by diagnostics seems to be just simtime/realtime so it is the average RTF, not the current RTF. For example, having the simulator at 0.5x for a couple minutes and then putting it to 3x will still give an RTF of 0.5x, slowly converging to 3x. So this is not an option.
  2. Subscribing to ~/world_stats: had no info about rtf; useless
  3. Gz stats. This thing never stops so I don't think I can call it with popen. One dirty workaround I did (that works but not good enough) is popen("gz stats -p -d 1"), which makes gz stats run for 1 second. Ideally, I want a command line arg that'll make gz stat show one line. I tried decimal seconds but those seem to round down (-d 0.5 would just print nothing)
  4. Manually calculating the RTF. I really don't want to do this unless I know the exact formula the Gazebo GUI uses to calculate the RTF. I don't know how long it polls for.

So tl;dr, I either would want to have a way to run gz stats for one line (and not for one second), the exact algorithm/formula that the Gazebo GUI uses to calculate RTF, or any things I am missing (I did look through all Gazebo topics that were published, but I might be missing some compilation flag for extra topics).

Any suggestions? Thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2017-06-27 14:21:01 -0500

JLiviero gravatar image

updated 2017-06-28 05:27:59 -0500

I had the same problem and went though basically the same attempted solutions. I eventually re-implemented the same algorithm the gz statstool uses (similar to your option #4), which can be found here: https://bitbucket.org/osrf/gazebo/src...

I was able to work a subscription/callback to world_stats (the above-linked method is such a callback) in to this gazebo_ros_pkgs file, but that may not be applicable to your use case, it was just convenient for me. In fact, there is even a commented-out sub to the same topic seen here.

edit flag offensive delete link more

Comments

Ha, you're right @chapulina. I grabbed from my notes quickly and misremembered where in the source it cam from. Edited my post, thanks.

JLiviero gravatar imageJLiviero ( 2017-06-28 05:23:38 -0500 )edit

okay cool! Thanks for the references. So to future readers, it seems like the algorithm in gz stats is to just keep twenty instances of the previous real time and sim time readings from world_stats and then avg(sim_times-sim_times[0])/avg(real_times-real_times[0])

csano gravatar imagecsano ( 2017-06-28 08:32:31 -0500 )edit
0

answered 2017-06-27 12:55:24 -0500

sloretz gravatar image

~/world_stats has fields sim_time and real_time. The real time factor is sim_time / real_time.

edit flag offensive delete link more

Comments

Not exactly. RTF is calculated over several passes. I actually tried what you suggest at one point, and it always produced a value much higher than that of the actual RTF calculated by Gazebo.

JLiviero gravatar imageJLiviero ( 2017-06-27 14:22:49 -0500 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2017-06-27 09:57:46 -0500

Seen: 1,458 times

Last updated: Jun 28 '17