6 #ifndef LIB_ALMATH_SCENEGRAPH_URDFEIGEN_H
7 #define LIB_ALMATH_SCENEGRAPH_URDFEIGEN_H
10 #include <Eigen/Geometry>
18 return Eigen::AngleAxisd(rpy[2], Eigen::Vector3d::UnitZ()) *
19 Eigen::AngleAxisd(rpy[1], Eigen::Vector3d::UnitY()) *
20 Eigen::AngleAxisd(rpy[0], Eigen::Vector3d::UnitX());
25 Eigen::Vector3d ypr = t.eulerAngles(2, 1, 0);
30 typedef Eigen::Map<const Eigen::Vector3d> Vector3dMap;
31 return Eigen::Translation3d(Vector3dMap(p.xyz().data())) *
36 typedef Eigen::Map<const Eigen::Vector3d> Vector3dMap;
37 return Eigen::Translation3d(Vector3dMap(p.xyz().data())) *
42 typedef Eigen::Map<const Eigen::Vector3d> Vector3dMap;
43 return Eigen::Translation3d(Vector3dMap(p.xyz().data())) *
49 return AL::urdf::Pose({t.translation()[0], t.translation()[1], t.translation()[2]},
56 m(0, 0) = inertial.
ixx();
57 m(0, 1) = m(1, 0) = inertial.
ixy();
58 m(0, 2) = m(2, 0) = inertial.
ixz();
59 m(1, 1) = inertial.
iyy();
60 m(1, 2) = m(2, 1) = inertial.
iyz();
61 m(2, 2) = inertial.
izz();
71 template <
typename Scalar,
typename EPose,
typename Derived1>
73 const Eigen::MatrixBase<Derived1> &inertia_a, Scalar mass_b,
75 const Eigen::MatrixBase<Derived1> &inertia_b,
76 Scalar &mass_c, EPose &pose_c,
77 Eigen::MatrixBase<Derived1> &inertia_c) {
78 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived1, 3, 3)
80 (Eigen::internal::is_same<Scalar, typename EPose::Scalar>::value),
81 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
83 (Eigen::internal::is_same<Scalar, typename Derived1::Scalar>::value),
84 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
85 typedef Eigen::Matrix<Scalar, 3, 3> Matrix3;
86 typedef Eigen::Matrix<Scalar, 3, 1> Vector3;
89 mass_c = mass_a + mass_b;
92 pose_c.translation() =
93 (mass_a * pose_a.translation() + mass_b * pose_b.translation()) / mass_c;
94 pose_c.linear() = pose_a.linear();
97 inertia_c = inertia_a;
98 Vector3 displ = pose_c.translation() - pose_a.translation();
102 Matrix3 rot_cb = pose_c.linear().transpose() * pose_b.linear();
103 inertia_c += rot_cb.transpose() * inertia_b * rot_cb;
104 displ = pose_c.translation() - pose_b.translation();
108 template <
typename Scalar,
typename Derived0,
typename Derived1>
110 Eigen::MatrixBase<Derived0> &com_a,
111 Eigen::MatrixBase<Derived1> &inertia_a) {
112 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived0, 3, 1)
113 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived1, 3, 3)
115 (Eigen::internal::is_same<Scalar, typename Derived0::Scalar>::value),
116 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
118 (Eigen::internal::is_same<Scalar, typename Derived1::Scalar>::value),
119 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
120 typedef Eigen::Transform<Scalar, 3, Eigen::AffineCompact, Eigen::DontAlign> T;
121 typedef Eigen::Matrix<Scalar, 3, 3> Matrix3;
123 mass = inertial.
mass();
125 com_a = t_ab.translation();
127 inertia_a = t_ab.linear().transpose() * inertia_b * t_ab.linear();
void addPointMassInertia(Scalar mass, const Eigen::MatrixBase< Derived0 > &position, Eigen::MatrixBase< Derived1 > &output)
std::array< double, 3 > Array3d
Eigen::Isometry3d toEigenTransform(const AL::urdf::Pose &p)
Eigen::Matrix3f toEigenMatrix3(const Math::Transform &tr)
AL::urdf::Pose urdfPoseFromEigenTransform(const T &t)
Eigen::Quaterniond eigenQuaternionFromUrdfRpy(const AL::urdf::Array3d &rpy)
Eigen::Isometry3d toEigenIsometry3(const AL::urdf::Pose &p)
void urdfInertialToEigen(const AL::urdf::Inertial &inertial, Scalar &mass, Eigen::MatrixBase< Derived0 > &com_a, Eigen::MatrixBase< Derived1 > &inertia_a)
void squashInertial(Scalar mass_a, const EPose &pose_a, const Eigen::MatrixBase< Derived1 > &inertia_a, Scalar mass_b, const EPose &pose_b, const Eigen::MatrixBase< Derived1 > &inertia_b, Scalar &mass_c, EPose &pose_c, Eigen::MatrixBase< Derived1 > &inertia_c)
AL::urdf::Array3d urdfRpyFromEigenMatrix3(const T &t)
Eigen::AffineCompact3f toEigenAffineCompact3(const Math::Transform &tr)