Home | Tutorials | Wiki | Issues
Ask Your Question
2

sensors and physics synchronization

asked 2016-03-09 12:50:06 -0500

Clément Pinard gravatar image

Hi, I'm currently working on gazebo, trying to do some reinforcement learning, using only camera for the moment. as a consequence i want gazebo to run as quickly as possible, during learning. As I understood, the best way to do this is to set "real_time_update_rate" to 0 in the world file. I've been doing some tests, and it appears that simulation largely outdistance the camera. When I dump the frames, I see a massive amount of lost frames, which is not very convenient from a stability point of view for reinforced learning. Now as far as I have understood the code behind the sensors, each iteration for the sensor thread, there is a check if simulation time is enough to update the sensor, and if it is too much, it can compensate by updating faster next time.

Apparently the sensor thread is so outdistanced here that it just gives up to catch up and goes on, hence the lost frames.

So is there a way to make the physics engine wait for the sensor to be updated ? It will certainly make the sim slower but it would be useless otherwise.

Furthermore I’ve been playing with real_time_update_rate max_step_size and update_rate for the cam, to check how many engine steps there were between each frame I dumped

In theory, Real time execution is real_time_update_rate*ma_step_size, so if for example I set the three parameters like this

real_time_update_rate = 100
max_step_size = 0.01
update_rate = 10

I should get a frame every 10 steps, which it does. Now when i set it like this

real_time_update_rate = 10
max_step_size = 0.1
update_rate = 10

(parameters are not realistic, that's just for the test) I should get a frame every step right ? In fact I get approx 3 frames per step. How is that ? isn't the sensor supposed to wait for the simulation time to be enough ?

TL;DR How can synchronize the engine and the sensor to make sure that every simulation is deterministic, even with different computing speeds ?

Thanks in advance !

edit retag flag offensive close merge delete

Comments

Hi, I have the same problem. Did you find a solution?

ASeyfi gravatar imageASeyfi ( 2016-04-01 09:23:57 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-04-01 11:19:43 -0500

nkoenig gravatar image

You could make the physics engine wait on a sensor by using a plugin (which you'd have write). Your plugin would control physics by Stepping the world appropriately when a camera sensor is updated.

I suggest that you also create an issue for this on gazebo's issue tracker.

This issue might be related to your experience.

edit flag offensive delete link more

Comments

Hi, following your comment here, I tried creating a Gazebo plugin using this instructions: http://gazebosim.org/tutorials/?tut=plugins_model and modified the OnUpdate() method and added a 1 second delay before returning from the function. When I run the simulation, each simulation step takes one second and the box in the simulation moves a little bit in each step. Doesn't it mean that Gazebo is already pausing the physics engine until all of the plugins' OnUpdate() functions return?

ASeyfi gravatar imageASeyfi ( 2016-04-01 15:59:19 -0500 )edit
Login/Signup to Answer

Question Tools

3 followers

Stats

Asked: 2016-03-09 12:50:06 -0500

Seen: 818 times

Last updated: Apr 01 '16