robomechanics / quad-sdk

Software tools for agile quadrupeds, developed by the Robomechanics Lab at Carnegie Mellon University.
https://robomechanics.github.io/quad-sdk/
MIT License
694 stars 132 forks source link

Complex system dynamics with a custom robot #382

Closed Kate88L closed 1 year ago

Kate88L commented 1 year ago

As far as I understand, when updating the matlab script main, one can modify the parameters in the dynamics model for a custom robot and generate new casadi functions. However, this matlab script generates simple model only. Is there currently I "simple" way to generate casadi functions for the complex dynamics model in the existing matlab script? What have you used to generate the necessary casadi functions for complex dynamics model for the spirit robot?

ardalantj commented 1 year ago

Hi, thanks for using Quad-SDK. I am not sure if I understand what you mean by simple vs complex models here. I am assuming you are referring to centroidal model vs full body model. Currently, we compute the desired ground reaction forces using the centroidal model and pass it to an inverse dynamics controller to realize those as joint torques. In theory, you could customize the existing framework and use the full-body model instead to directly compute joint torques. However, that would require bypassing some of the existing functionality in the robot driver.

In casadi, we have defined the Lagrangian dynamics of our model and it automatically generates c-code that the NMPC uses from the gen folder, so you could do the same for a different dynamics model.

Kate88L commented 1 year ago

Thank you for a clear answer. However, when you implemented adaptive and mixed complexity for the Spirit robot, you in fact allowed for a full body model in NMPC. Yet, in the available matlab script, I can see only model where legs don't have any specifi geometry. I assume you had to generate casadi functions and c-code for the full body model. Did you also use matlab for this code generation? Is there a tool you would recommend to define the dynamic model for a full body dynamics (with urdf support, probably)?

Czworldy commented 1 year ago

i have the same question @ardalantj

ardalantj commented 1 year ago

@Kate88L and @Czworldy I see, you are looking at the code that was used for the adaptive complexity MPC paper (https://arxiv.org/abs/2209.02849). That is not the default controller we use on hardware and using the more complex model in its current state is not able to run in real-time. If you want to run a robust controller on a quadruped hardware platform, I suggest using the existing NMPC controller as it does run pretty well under various disturbances.

ardalantj commented 1 year ago

I will close this issue, but feel free to open a new one for any follow ups.