5 #include "pinocchio/algorithm/rnea.hpp" 6 #include "pinocchio/algorithm/aba.hpp" 7 #include "pinocchio/algorithm/jacobian.hpp" 8 #include "pinocchio/algorithm/center-of-mass.hpp" 9 #include "pinocchio/algorithm/joint-configuration.hpp" 10 #include "pinocchio/algorithm/crba.hpp" 11 #include "pinocchio/algorithm/centroidal.hpp" 12 #include "pinocchio/parsers/sample-models.hpp" 14 #include "pinocchio/math/multiprecision.hpp" 16 #include <boost/multiprecision/cpp_dec_float.hpp> 17 #include <boost/math/special_functions/gamma.hpp> 21 #include <boost/test/unit_test.hpp> 22 #include <boost/utility/binary.hpp> 24 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
28 using namespace boost::multiprecision;
31 cpp_dec_float_100
b = 2;
32 std::cout << std::numeric_limits<cpp_dec_float_100>::digits << std::endl;
33 std::cout << std::numeric_limits<cpp_dec_float_100>::digits10 << std::endl;
35 std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_100>::max_digits10)
36 <<
log(b) << std::endl;
38 std::cout << boost::math::tgamma(b) << std::endl;
40 std::cout << boost::math::tgamma(b * b) << std::endl;
43 std::cout << boost::math::tgamma(cpp_dec_float_100(1000)) << std::endl;
48 typedef boost::multiprecision::cpp_dec_float_100 float_100;
51 double initial_value = boost::math::constants::pi<double>();
52 float_100 value_100(initial_value);
53 double value_cast = value_100.convert_to<
double>();
54 BOOST_CHECK(initial_value == value_cast);
56 typedef Eigen::Matrix<float_100,Eigen::Dynamic,1> VectorFloat100;
57 static const Eigen::DenseIndex
dim = 100;
59 VectorFloat100 vec_float_100 = initial_vec.cast<float_100>();
62 BOOST_CHECK(vec == initial_vec);
65 #define BOOST_CHECK_IS_APPROX(double_field,multires_field,Scalar) \ 66 BOOST_CHECK(double_field.isApprox(multires_field.cast<Scalar>())) 79 typedef boost::multiprecision::cpp_dec_float_100 float_100;
83 ModelMulti model_multi = model.
cast<float_100>();
84 DataMulti data_multi(model_multi);
87 ModelMulti::TangentVectorType v_multi = ModelMulti::TangentVectorType::Random(model_multi.nv);
88 ModelMulti::TangentVectorType a_multi = ModelMulti::TangentVectorType::Random(model_multi.nv);
89 ModelMulti::TangentVectorType tau_multi = ModelMulti::TangentVectorType::Random(model_multi.nv);
118 rnea(model_multi,data_multi,q_multi,v_multi,a_multi);
119 rnea(model,data,q,v,a);
124 aba(model_multi,data_multi,q_multi,v_multi,tau_multi);
125 aba(model,data,q,v,tau);
130 crba(model_multi,data_multi,q_multi);
131 data_multi.M.triangularView<Eigen::StrictlyLower>()
132 = data_multi.M.transpose().triangularView<Eigen::StrictlyLower>();
135 data.
M.triangularView<Eigen::StrictlyLower>()
136 = data.
M.transpose().triangularView<Eigen::StrictlyLower>();
141 BOOST_AUTO_TEST_SUITE_END()
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & aba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &tau)
The Articulated-Body algorithm. It computes the forward dynamics, aka the joint accelerations given t...
TangentVectorType tau
Vector of joint torques (dim model.nv).
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...
#define BOOST_CHECK_IS_APPROX(double_field, multires_field, Scalar)
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...
ModelTpl< NewScalar, Options, JointCollectionTpl > cast() const
int njoints
Number of joints.
ConfigVectorType lowerPositionLimit
Lower joint configuration limit.
BOOST_AUTO_TEST_CASE(test_basic)
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.
VectorXs TangentVectorType
Dense vectorized version of a joint tangent vector (e.g. velocity, acceleration, etc). It also handles the notion of co-tangent vector (e.g. torque, etc).
void forwardKinematics(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Update the joint placements according to the current joint configuration.
MatrixXs M
The joint space inertia matrix (a square matrix of dim model.nv).
TangentVectorType ddq
The joint accelerations computed from ABA.
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...
VectorXs ConfigVectorType
Dense vectorized version of a joint configuration vector.
ConfigVectorType upperPositionLimit
Upper joint configuration limit.
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