ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Controlling gazebo timing?

asked 2017-01-25 15:52:12 -0500

SaturnineSpectator gravatar image

Hey all :)

I'm trying to train a neural network to teach my robot how to do things for a research project. Ideally I'd like to:

  1. Send an action command ("move forward", "move left", etc.) to the robot/simulation.
  2. Wait some time (e.g. 50 in-simulation milliseconds) to let the physics do their thing.
  3. Retrieve the new world state.

I have nodes that listen to action commands (such as setting wheel velocity), so I can send commands just by publishing the right messages.

I also have nodes in place that publish relevant world information (mainly the fitness function).

My question is, how is it possible to configure Gazebo to make this work as fast as possible? If my computer can run 10 seconds of simulation time in 1 second of real-world time, the whole process should not take much more than 1 second.

I managed to set Gazebo to run as fast as possible, ignoring real-world time, but in my python code (the one sending out commands) how should I know how long to wait for before checking the world state resulting from the command I just sent? Ideally there'd be a function "sleepForSimulationMilliseconds(ms)", but I doubt it exists!

Any help would be greatly appreciated... If any parts seem vague/confusing I'd happily try to elaborate. Thank you a lot for the help! :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-01-25 19:51:33 -0500

tfoote gravatar image

If you use the ROS time abstraction and set use_sim_time to true all ROS nodes will follow the simulator time instead of wall time.

For roscpp see the API here: http://wiki.ros.org/roscpp/Overview/Time For rospy see here: http://wiki.ros.org/rospy/Overview/Time

There's an overview of the mechanism here: http://wiki.ros.org/Clock

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-01-25 15:52:12 -0500

Seen: 2,183 times

Last updated: Jan 25 '17