Skip to content
Snippets Groups Projects
Commit 121f9b42 authored by jcarpent's avatar jcarpent
Browse files

[C++] Add constructor from Matrix6 for Inertia + unittest

parent a3698a59
No related branches found
No related tags found
No related merge requests found
......@@ -123,14 +123,22 @@ namespace se3
// Constructors
InertiaTpl() : m(), c(), I() {}
InertiaTpl(Scalar_t m_,
const Vector3 &c_,
const Matrix3 &I_)
: m(m_),
c(c_),
I(I_)
InertiaTpl(const Scalar_t m_, const Vector3 &c_, const Matrix3 &I_)
: m(m_), c(c_), I(I_)
{}
InertiaTpl(const Matrix6 & I6)
{
assert((I6 - I6.transpose()).isMushSmallerThan(I6));
m = I6(LINEAR, LINEAR);
const Matrix3 & mc_cross = I6.template block <3,3> (ANGULAR,LINEAR);
c = skewInv(mc_cross);
c /= m;
Matrix3 I3 (mc_cross * mc_cross);
I3 /= m;
I3 += I6.template block<3,3>(ANGULAR,ANGULAR);
I = Symmetric3(I3);
}
InertiaTpl(Scalar_t _m,
......
......@@ -267,6 +267,10 @@ BOOST_AUTO_TEST_CASE ( test_Inertia )
double kinetic_ref = v.toVector().transpose() * aI.matrix() * v.toVector();
double kinetic = aI.vtiv(v);
BOOST_CHECK_SMALL(kinetic_ref - kinetic, 1e-12);
// Test constructor (Matrix6)
Inertia I1_bis(I1.matrix());
is_matrix_absolutely_closed(I1.matrix(), I1_bis.matrix(), 1e-12);
}
BOOST_AUTO_TEST_CASE ( test_ActOnSet )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment