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

Enhance ABA-based FD computation by adding motor dynamics #45

Closed
wants to merge 41 commits into from

Conversation

flferretti
Copy link
Collaborator

@flferretti flferretti commented Aug 1, 2023

This pull request introduces the possibility for the simulator to accept motor inertia, motor viscous friction and gear ratio, which will be saved in the already existing JAX dataclasses:

to be ready for Forward Dynamics computation through a new ABA version which incorporates these motor parameters into the simulation process.

As of now, the PR is marked as a draft since even though it successfully passes the tests against iDynTree, it requires further validation with comprehensive motor dynamics to ensure its robustness and accuracy.

C.C. @diegoferigo @CarlottaSartore @S-Dafarra @traversaro

@traversaro
Copy link
Contributor

traversaro commented Aug 1, 2023

Do you have some reference for the math implemented? In particular, I was a bit mislead by the title "adding motor dynamics", as in the code it does not seem that any new state is added to the simulated dynamic system.

@flferretti
Copy link
Collaborator Author

flferretti commented Aug 1, 2023

The problem formalization and the related pseudocode can be found at https://github.com/ami-iit/element_rl-for-codesign/issues/61#issuecomment-1658609058.

The title refers to the fact that this ABA implementation takes into account motor inertias, viscous friction and transmission ratio. I can change the title to "Enhance ABA-based FD computation by considering motor parameters" if that makes things more clear

@traversaro
Copy link
Contributor

The title refers to the fact that this ABA implementation takes into account motor inertias, viscous friction and transmission ratio. I can change the title to "Enhance ABA-based FD computation by considering motor parameters" if that makes things more clear

No problem, once you clarify it in the description I think it is ok!

@flferretti flferretti force-pushed the motor_dynamics branch 2 times, most recently from 3836a3c to a43274e Compare August 2, 2023 11:08
@flferretti

This comment was marked as outdated.

@flferretti flferretti marked this pull request as ready for review August 3, 2023 07:42
@flferretti flferretti force-pushed the motor_dynamics branch 2 times, most recently from b2e7343 to 551fc7d Compare August 4, 2023 13:23
@diegoferigo
Copy link
Member

diegoferigo commented Aug 10, 2023

xref of this interesting comment full of references ROAM-Lab-ND/spatial_v2_extended#6 (comment), we might have a deeper look at it (original issue ROAM-Lab-ND/spatial_v2_extended#5).

@flferretti flferretti force-pushed the motor_dynamics branch 2 times, most recently from c87ca07 to b0657e7 Compare September 12, 2023 17:44
@flferretti flferretti changed the base branch from main to new_api October 19, 2023 13:34
@flferretti
Copy link
Collaborator Author

Changing the base branch to new_api as I rebased on that

@flferretti flferretti force-pushed the motor_dynamics branch 2 times, most recently from 3ebcaad to fb61a64 Compare October 26, 2023 14:51
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

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

First round of review, it looks good even if I still have some doubts on the updated ABA and RNEA algorithms. If we want to merge into main and the new methods are not yet 100% tested and benchmarked, let's consider to commit them for the time being as aba_motors.py and rnea_motors.py. We can fix the remaining problems in the future without affecting current functionality.

src/jaxsim/high_level/model.py Show resolved Hide resolved
src/jaxsim/high_level/model.py Show resolved Hide resolved
src/jaxsim/high_level/model.py Show resolved Hide resolved
src/jaxsim/high_level/model.py Show resolved Hide resolved
src/jaxsim/high_level/model.py Show resolved Hide resolved
src/jaxsim/high_level/model.py Show resolved Hide resolved
src/jaxsim/high_level/model.py Show resolved Hide resolved
Comment on lines +113 to +114
vJ = S[i] * qd[ii] * (qd.size != 0)
m_vJ = m_S[i] * qd[ii] * (qd.size != 0)
Copy link
Member

Choose a reason for hiding this comment

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

Did you validate jit compilation? I remember I had to use the if/else statement in this way otherwise jax was complaining

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it did not complain, but we can further investigate on this

src/jaxsim/physics/algos/aba.py Show resolved Hide resolved
@diegoferigo diegoferigo deleted the branch ami-iit:new_api December 6, 2023 05:52
@diegoferigo diegoferigo closed this Dec 6, 2023
@flferretti
Copy link
Collaborator Author

Also this has been closed once merged new_api. I'll reopen it with the addressed comments

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

3 participants