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

Compute the whole-body-inertia and the average-angular-velocity. #75

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

Conversation

wyqsnddd
Copy link

As I discussed in the mc_rtc issue 245, these commit provide additional computations.

Copy link
Member

@gergondet gergondet left a comment

Choose a reason for hiding this comment

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

This looks great, thanks!

Can you add some tests to check the computations are ok?

src/RBDyn/Momentum.cpp Outdated Show resolved Hide resolved
src/RBDyn/RBDyn/Momentum.h Outdated Show resolved Hide resolved
src/RBDyn/RBDyn/Momentum.h Show resolved Hide resolved
src/RBDyn/Momentum.cpp Outdated Show resolved Hide resolved
  * Replace matrix inverse with 'llt().solve(m)'
  * Function parameter overloading
  * Clean the comments
…dal inertia.

  * Improve the average velocity computation: ci.llt().solveInPlace(av)
  * Simplify the for loop computation with the intermediate term: X_com_i
…dal inertia in issue jrl-umi3218#75

  * Improve the average velocity computation: ci.llt().solveInPlace(av)
  * Simplify the for loop computation with the intermediate term: X_com_i
@wyqsnddd
Copy link
Author

In my other repo, I made a quick assertion to make sure the COM velocity is equal to the Average Linear Velocity. Thus I think the computation should be correct.

wyqsnddd and others added 8 commits August 27, 2020 11:17
@gergondet
Copy link
Member

In my other repo, I made a quick assertion to make sure the COM velocity is equal to the Average Linear Velocity. Thus I think the computation should be correct.

Hi Yuquan,

I added a test that test that but the test is failing. Could you have a look at it?

I also rebased your branch on master and fixed warnings on clang to get the build to run correctly, I had to force push to your branch so please be careful when you pull on your side

@wyqsnddd
Copy link
Author

In my other repo, I made a quick assertion to make sure the COM velocity is equal to the Average Linear Velocity. Thus I think the computation should be correct.

Hi Yuquan,

I added a test that test that but the test is failing. Could you have a look at it?

I also rebased your branch on master and fixed warnings on clang to get the build to run correctly, I had to force push to your branch so please be careful when you pull on your side

Yes, sure! I'll look into the test.

@wyqsnddd
Copy link
Author

@gergondet Hi Pierre,

I am revisiting this issue again. I found something fishy with the comVelocity. Basically, I failed the following:

    BOOST_CHECK_SMALL((av.tail(3) - comVelocity).norm(), TOL);

but passed:

    BOOST_CHECK_SMALL((ci*av - cm.vector()).norm(), TOL);

I computed the centroidal inertia ci here, which is mathematically correct according to the following equations. The computation of av should be fine too.

Reference equations (I can provide further reference on this point if necessary):

  • Inertia transform from frame $F_i$ to $F_c$: $Adg^\top_{i,c} I_i Adg_{i,c}$, where $I_i$ denotes the inertia in frame $F_i$.
  • Force / Momentum transform from $F_i$ to $F_c$: $Adg^\top_{i,c} h_i$, where $h_i$ denotes the momentum in frame $F_i$.

Further, the linear momentum should be equal to the product of the COM velocity and the mass. But RBDyn can not pass such a test and the difference is huge if I do the following:

cmm.computeMatrix(mb, mbc, com);

    Eigen::MatrixXd cmmMatrix = cmm.matrix();

    Eigen::VectorXd alpha(mb.nrDof());
    double mass = 6.0;
    std::cout<<" Momemtum diff is: "<<((cmmMatrix * alpha).tail(3) - mass*comVelocity).transpose();

In the above example, I found the mass from other computations.

@gergondet
Copy link
Member

Hi Yuquan,

cmm.computeMatrix(mb, mbc, com);

    Eigen::MatrixXd cmmMatrix = cmm.matrix();

    Eigen::VectorXd alpha(mb.nrDof());
    double mass = 6.0;
    std::cout<<" Momemtum diff is: "<<((cmmMatrix * alpha).tail(3) - mass*comVelocity).transpose();

This sample as such is not correct, your alpha vector is a vector of size mb.nrDof() of unitialized values not the velocity vector.

@wyqsnddd
Copy link
Author

wyqsnddd commented Oct 3, 2022

Hi Pierre,

Sorry for the mistake. It is a redundant comment. Now I have removed it.

Could you please run the example? The issue remains there.

@wyqsnddd
Copy link
Author

Hi Pierre,

This is a kind reminder of the open issue. Maybe we can look at it together if you want.

Yuquan

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.

4 participants