0
$\begingroup$

Rosanswers logo

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! :)


Originally posted by SaturnineSpectator on ROS Answers with karma: 3 on 2017-01-25

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by tfoote with karma: 58457 on 2017-01-25

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.