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

Removing mx_reduced by creating "biorbd wrapper" #881

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

EveCharbie
Copy link
Collaborator

@EveCharbie EveCharbie commented Jun 21, 2024

This change is Reviewable

@EveCharbie
Copy link
Collaborator Author

@pariterre @Ipuch This is what I was thinking about for the "biorbd wrapper".
I just did a proof of concept for pendulum.py to know what you guys think before I implement it for all biorbd functions.
This way, we do not have to carry around mx_reduced and I think we do not need .mx anymore neither because everything can be called directly with .cx.
It might get less clean when we add arguments which we cannot assume the shape (e.g. contact forces), but will still work.

@Ipuch
Copy link
Collaborator

Ipuch commented Jun 21, 2024

I would advocate for a supplementary interface (BiorbdModelToCasadiFunc ?) to biorbd. An entire class that does this for every function called by biorbd so we don't have to change the current class BiorbdModel, BiorbdMultiModel, Holonomic etc ...

Also, every function of the models that do not through a MX, absolutely need to be fixed. I'm thinking about rotation matrices that are still objects of biorbd for example.

Good Job !

Copy link
Member

@pariterre pariterre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @EveCharbie)


bioptim/models/biorbd/biorbd_model.py line 212 at r1 (raw file):

    def reshape_qdot(self, k_stab=1) -> MX:
        q_mx_reduced = MX.sym("q_mx_reduced", self.nb_q, 1)

If we go this route, which I actually like, all MX should be removed from bioptim altogether (not 100% sure it works). It would be the responsability of the BioModel to keep track (if needed) of extra symbolic MX!


bioptim/models/biorbd/biorbd_model.py line 357 at r1 (raw file):

        q_mx_reduced = MX.sym("q_mx_reduced", self.nb_q, 1)
        qdot_mx_reduced = MX.sym("qdot_mx_reduced", self.nb_qdot, 1)
        tau_mx_reduced = MX.sym("tau_mx_reduced", self.nb_tau, 1)

Same here, it would be the dynamic responsability to declare MX.sym (if for instance they can't use SX, and return something which is dependent on .cx


bioptim/optimization/optimization_variable.py line 565 at r1 (raw file):

    @property
    def mx(self):
        return self.unscaled.mx

This would therefore rendered useless, which would GREATLY simplify bioptim (as only .cx would be useful)

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.

3 participants