Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step the simulator over horizon #10

Merged
merged 1 commit into from
Sep 20, 2022
Merged

Conversation

diegoferigo
Copy link
Member

@diegoferigo diegoferigo commented Sep 20, 2022

This PR adds the possibility to step the simulator over a time horizon instead of being stepped over only a single $\Delta t$.

Two modalities are supported:

  1. Pure open loop stepping. All the simulated models are integrated over the horizon in open-loop, i.e. their input (joint torques and link external forces) could either be either kept constant or just applied in the first step.
  2. Closed loop stepping. In this case, this PR introduces experimental callbacks that, for example, could include logic of robot controllers. The callback object could be a generic PyTree and could have an internal state.

Callbacks could be useful in any case to extract data from the entire horizon for logging purpose.

Note that this kind of integration over horizon is mostly beneficial when it is combined with jax.jit. In this way, the simulator can maximize runtime performance by compiling together a possibly long forward simulation.

Note: We do not support integrating in parallel multiple cloned models belonging to a single simulation instance. Integration parallelism is performed by creating multiple simulator.JaxSim objects with only one model. The overhead of the simulator instance is almost negligible, and this approach makes calling jax.vmap explicit from the user point-of-view.

Note: The new JaxSim.step_over_horizon method, contrarily to all the other methods that can be either called in an object-oriented or a functional way thanks to JaxsimDataclass, is purely functional. This is due to the logic related to the callbacks.

@diegoferigo diegoferigo self-assigned this Sep 20, 2022
@diegoferigo diegoferigo marked this pull request as ready for review September 20, 2022 08:56
@diegoferigo diegoferigo force-pushed the feature/step_over_horizon branch 2 times, most recently from 1af070b to dd020c3 Compare September 20, 2022 09:13
@diegoferigo diegoferigo merged commit 3702640 into main Sep 20, 2022
@diegoferigo diegoferigo deleted the feature/step_over_horizon branch September 20, 2022 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant