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
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
60051c1
[New function] to compute the cetroidal inertia and average centroida…
wyqsnddd Aug 17, 2020
c521fa7
More comments on the centroidal inertia computation.
wyqsnddd Aug 17, 2020
fad794a
[Minor] Use Eigen::Vector6d instead of sva::ForceVecd
wyqsnddd Aug 19, 2020
c99d108
[clang-format]
wyqsnddd Aug 21, 2020
c56ddf7
[cmake] Restore submodule to current RBDyn master
gergondet Aug 22, 2020
b076d81
[comment-fix] according to issue: #75.
wyqsnddd Aug 22, 2020
e639239
[Improvement] matrix inversion and the for-loop for computing centroi…
wyqsnddd Aug 24, 2020
e8e4218
[Improvement] matrix inversion and the for-loop for computing centroi…
wyqsnddd Aug 24, 2020
0f4c318
Fix the commit message to link to #75
wyqsnddd Aug 24, 2020
4dd27a9
[New function] to compute the cetroidal inertia and average centroida…
wyqsnddd Aug 17, 2020
08893b4
More comments on the centroidal inertia computation.
wyqsnddd Aug 17, 2020
b8f80d9
[Minor] Use Eigen::Vector6d instead of sva::ForceVecd
wyqsnddd Aug 19, 2020
8263384
[clang-format]
wyqsnddd Aug 21, 2020
eaad080
[cmake] Restore submodule to current RBDyn master
gergondet Aug 22, 2020
0737a19
[comment-fix] according to issue: #75.
wyqsnddd Aug 22, 2020
ecf3faf
[Improvement] matrix inversion and the for-loop for computing centroi…
wyqsnddd Aug 24, 2020
5da5f10
Fix warning
gergondet Aug 27, 2020
456756d
Add a test for computeCentroidalInertia
gergondet Aug 27, 2020
22d4cf0
Merge branch 'whole-body-inertia' of github.com:wyqsnddd/RBDyn into w…
wyqsnddd Oct 24, 2020
e0f18aa
[WIP] [Medium] Tried to implement the improved CMM matrix computation…
wyqsnddd Dec 1, 2020
7d98488
[Minor]
wyqsnddd Jan 19, 2022
1315f28
[Unknown modifications]
wyqsnddd Jan 19, 2022
f7cb24f
Merge branch 'whole-body-inertia' of github.com:wyqsnddd/RBDyn into w…
wyqsnddd Jan 19, 2022
8d0613b
Merge branch 'master' into whole-body-inertia
wyqsnddd Jan 19, 2022
7cdee58
[Debug] see #75
ywang-robotics Sep 28, 2022
e3f71b9
Fixed the alpha calculation.
ywang-robotics Oct 3, 2022
0625ae6
Update submodule cmake
ywang-robotics Jun 12, 2024
fab9934
Merge branch 'master' into whole-body-inertia
ywang-robotics Jun 12, 2024
3ba4ae8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/RBDyn/Momentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,47 @@

namespace rbd
{
void computeCentroidalInertia(const MultiBody & mb,
const MultiBodyConfig & mbc,
const Eigen::Vector3d & com,
Eigen::Matrix6d & ci,
Eigen::Vector6d & cm)
{

using namespace Eigen;

const std::vector<Body> & bodies = mb.bodies();
cm = Vector6d::Zero();

ci = Matrix6d::Identity();

sva::PTransformd X_com_0(Vector3d(-com));
for(int i = 0; i < mb.nrBodies(); ++i)
{
// body momentum in body coordinate
sva::ForceVecd hi = bodies[i].inertia() * mbc.bodyVelB[i];

// momentum at CoM for link i : {}^iX_{com}^T {}^iI_i {}^iV_i
cm += (mbc.bodyPosW[i] * X_com_0).transMul(hi).vector();

// sum: X^T_com_i*I_i*X_com_i
// X_com_i = X_i_0 * X_com_0
ci += ((mbc.bodyPosW[i] * X_com_0).matrix().transpose()) * (bodies[i].inertia().matrix())
* (mbc.bodyPosW[i] * X_com_0).matrix();
}
}

void computeCentroidalInertia(const MultiBody & mb,
const MultiBodyConfig & mbc,
const Eigen::Vector3d & com,
Eigen::Matrix6d & ci,
Eigen::Vector6d & cm,
Eigen::Vector6d & av)
{
computeCentroidalInertia(mb, mbc, com, ci, cm);
// Compute the average velocity: inertia.inverse()*momentum
av = ci.llt().solve(cm);
}

sva::ForceVecd computeCentroidalMomentum(const MultiBody & mb, const MultiBodyConfig & mbc, const Eigen::Vector3d & com)
{
Expand Down
34 changes: 34 additions & 0 deletions src/RBDyn/RBDyn/Momentum.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,40 @@ struct Block;
using Blocks = std::vector<Block>;
class Jacobian;

/**
* Compute the centroidal inertia (ci), and centroidal momentum (cm)
* at the CoM frame as describe in [Orin and Gosawami 2008].
* @param mb MultiBody used has model.
* @param mbc Use bodyPosW, bodyVelB.
* @param com CoM position.
* @param ci Centroidal inertia at the Centroidal frame.
* @param cm centroidal momentum at the Centroidal frame.
* @param av Average velocity is inverse(centroidalInertia)*centroidalMomentum
*/
RBDYN_DLLAPI void computeCentroidalInertia(const MultiBody & mb,
const MultiBodyConfig & mbc,
const Eigen::Vector3d & com,
Eigen::Matrix6d & ci,
Eigen::Vector6d & cm);

/**
* Compute the centroidal inertia (ci), centroidal momentum (cm),
* and the average velocity (av = ci^-1*cm)
* at the CoM frame as describe in [Orin and Gosawami 2008].
* @param mb MultiBody used has model.
* @param mbc Use bodyPosW, bodyVelB.
* @param com CoM position.
* @param ci Centroidal inertia at the Centroidal frame.
* @param cm centroidal momentum at the Centroidal frame.
* @param av Average velocity is inverse(centroidalInertia)*centroidalMomentum
gergondet marked this conversation as resolved.
Show resolved Hide resolved
*/
RBDYN_DLLAPI void computeCentroidalInertia(const MultiBody & mb,
const MultiBodyConfig & mbc,
const Eigen::Vector3d & com,
Eigen::Matrix6d & ci,
Eigen::Vector6d & cm,
Eigen::Vector6d & av);

/**
* Compute the centroidal momentum at the CoM frame
* as describe in [Orin and Gosawami 2008].
Expand Down