13 #include "pinocchio/multibody/model.hpp" 14 #include "pinocchio/multibody/data.hpp" 15 #include "pinocchio/algorithm/crba.hpp" 16 #include "pinocchio/algorithm/centroidal.hpp" 17 #include "pinocchio/algorithm/rnea.hpp" 18 #include "pinocchio/algorithm/jacobian.hpp" 19 #include "pinocchio/algorithm/center-of-mass.hpp" 20 #include "pinocchio/algorithm/joint-configuration.hpp" 21 #include "pinocchio/parsers/sample-models.hpp" 22 #include "pinocchio/utils/timer.hpp" 26 #include <boost/test/unit_test.hpp> 27 #include <boost/utility/binary.hpp> 29 template<
typename Jo
intModel>
32 const std::string & parent_name,
33 const std::string &
name,
35 bool setRandomLimits =
true)
38 typedef typename JointModel::ConfigVector_t CV;
39 typedef typename JointModel::TangentVector_t TV;
47 TV::Random() + TV::Constant(1),
48 TV::Random() + TV::Constant(1),
49 CV::Random() - CV::Constant(1),
50 CV::Random() + CV::Constant(1)
62 BOOST_AUTO_TEST_SUITE ( BOOST_TEST_MODULE )
71 #ifdef _INTENSE_TESTING_ 72 const size_t NBT = 1000*1000;
74 const size_t NBT = 10;
84 timer.
toc(std::cout,NBT);
88 using namespace Eigen;
91 Eigen::MatrixXd
M(model.
nv,model.
nv);
96 data.
M.fill(0);
crba(model,data,q);
97 data.
M.triangularView<Eigen::StrictlyLower>() = data.
M.transpose().triangularView<Eigen::StrictlyLower>();
101 for(
int i=0;
i<model.
nv;++
i)
103 M.col(
i) =
rnea(model,data,q,v,Eigen::VectorXd::Unit(model.
nv,
i)) -
bias;
108 BOOST_CHECK(M.isApprox(data.
M,1e-12));
110 std::cout <<
"(the time score in debug mode is not relevant) " ;
112 q = Eigen::VectorXd::Zero(model.
nq);
119 timer.
toc(std::cout,NBT);
121 #endif // ifndef NDEBUG 137 crba(model,data_ref,q);
138 data_ref.
M.triangularView<Eigen::StrictlyLower>() = data_ref.
M.transpose().triangularView<Eigen::StrictlyLower>();
141 data.M.triangularView<Eigen::StrictlyLower>() =
data.M.transpose().triangularView<Eigen::StrictlyLower>();
143 BOOST_CHECK(
data.M.isApprox(data_ref.
M));
145 ccrba(model,data_ref,q,v);
147 BOOST_CHECK(
data.Ag.isApprox(data_ref.
Ag));
148 BOOST_CHECK(
data.J.isApprox(data_ref.
J));
152 BOOST_AUTO_TEST_SUITE_END ()
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & crba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the upper triangular part of the joint space inertia matrix M by using the Composite Rigid B...
FrameIndex addJointFrame(const JointIndex &joint_index, int previous_frame_index=-1)
Add a joint to the frame tree.
Matrix6x J
Jacobian of joint placements.
void rnea(const int num_threads, ModelPoolTpl< Scalar, Options, JointCollectionTpl > &pool, const Eigen::MatrixBase< ConfigVectorPool > &q, const Eigen::MatrixBase< TangentVectorPool1 > &v, const Eigen::MatrixBase< TangentVectorPool2 > &a, const Eigen::MatrixBase< TangentVectorPool3 > &tau)
The Recursive Newton-Euler algorithm. It computes the inverse dynamics, aka the joint torques accordi...
static InertiaTpl Random()
ConfigVectorType lowerPositionLimit
Lower joint configuration limit.
void randomConfiguration(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorIn1 > &lowerLimits, const Eigen::MatrixBase< ConfigVectorIn2 > &upperLimits, const Eigen::MatrixBase< ReturnType > &qout)
Generate a configuration vector uniformly sampled among provided limits.
BOOST_AUTO_TEST_CASE(test_crba)
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & ccrba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes the Centroidal Momentum Matrix, the Composite Ridig Body Inertia as well as the centroidal m...
JointIndex addJoint(const JointIndex parent, const JointModel &joint_model, const SE3 &joint_placement, const std::string &joint_name)
Add a joint to the kinematic tree with infinite bounds.
MatrixXs M
The joint space inertia matrix (a square matrix of dim model.nv).
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & crbaMinimal(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the upper triangular part of the joint space inertia matrix M by using the Composite Rigid B...
pinocchio::JointIndex JointIndex
Main pinocchio namespace.
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & computeJointJacobians(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the full model Jacobian, i.e. the stack of all motion subspace expressed in the world frame...
Matrix6x Ag
Centroidal Momentum Matrix.
MotionTpl< Scalar, Options > bias(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointBiasVisitor to get the joint bias as a dense motion.
int nv
Dimension of the velocity vector space.
JointIndex getJointId(const std::string &name) const
Return the index of a joint given by its name.
static void addJointAndBody(pinocchio::Model &model, const pinocchio::JointModelBase< JointModel > &joint, const std::string &parent_name, const std::string &name, const pinocchio::SE3 placement=pinocchio::SE3::Random(), bool setRandomLimits=true)
void normalize(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &qout)
Normalize a configuration vector.
ConfigVectorType upperPositionLimit
Upper joint configuration limit.
void appendBodyToJoint(const JointIndex joint_index, const Inertia &Y, const SE3 &body_placement=SE3::Identity())
Append a body to a given joint of the kinematic tree.
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorXd
JointCollectionTpl & model
int nq
Dimension of the configuration vector representation.
FrameIndex addBodyFrame(const std::string &body_name, const JointIndex &parentJoint, const SE3 &body_placement=SE3::Identity(), int previousFrame=-1)
Add a body to the frame tree.
void fill(Eigen::Ref< MatType > mat, const typename MatType::Scalar &value)