leggedrobotics / ocs2

Optimal Control for Switched Systems
https://leggedrobotics.github.io/ocs2
BSD 3-Clause "New" or "Revised" License
874 stars 225 forks source link

Offline optimization and elastic joints #38

Closed mvanlobensels closed 2 years ago

mvanlobensels commented 2 years ago

Dear authors,

First of all, thank you for making this great toolbox open source! Does this toolbox support offline optimization? Is it as simple as solving the optimal control problem once instead of repeatedly online? My plan is to generate an energy optimal gait offline and to track it with a custom controller.

And second (although I do not know if this is the correct place to ask), I would like to model the dynamic effects of elastic actuators, i.e. series elastic actuators, variable stiffness actuators, etc., but URDF nor Pinocchio support this natively. I know that ANYmal has SEAs, but its dynamics do not seem to be considered. Do you know if it is possible to change the auto-generated code by Pinocchio to incorporate the elastic joints?

rubengrandia commented 2 years ago

Does this toolbox support offline optimization? Is it as simple as solving the optimal control problem once instead of repeatedly online?

Yes, just create a solver object and call the solve method yourself. Make sure to set to increase the amount of allowed iterations.

Do you know if it is possible to change the auto-generated code by Pinocchio to incorporate the elastic joints?

You will have to do this yourself, but this should not be to hard if you are using automatic differentiation, for example via 'SystemDynamicsBaseAD'. You can compute the torque with your elastic model, and feed this to Pinocchio. Autodiff should them take care of linearizing through the series of models.