Skip to content
Advertisement

What is the correct way to run a pydrake simulation “online”?

In Drake/pydrake, all of the examples I have seen create an instance of Simulator and then advance the simulation by a set duration, e.g. sim.AdvanceTo(10) will step the simulation until it has simulated 10 seconds of activity.

How can I instead run a simulation indefinitely, where I don’t have a specific duration to advance to, just have the simulation running in its own node and step at a fixed interval forever?

My intention is to just have the simulator running, and then send requests to update commands that will be sent to the robot. Is there a straightforward way to achieve this that won’t break the simulation? I figured there would be a public Step function on Simulator, but have only encountered AdvanceTo. My first thought was to try to take the context from a call to AdvanceTo over a short interval, e.g. AdvanceTo(0.01) and then overwrite the context for the next call so that it’s updating from the new context instead of the original, but I’m not sure it will work. Maybe there’s a more official way to achieve this scheme?

Advertisement

Answer

You can do simulator.AdvanceTo(std::numeric_limits<double>::infinity()); to keep the simulation running indefinitely.

https://github.com/RobotLocomotion/drake/tree/master/examples/kuka_iiwa_arm may be helpful as an example.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement