5 #include "pinocchio/multibody/model.hpp" 6 #include "pinocchio/multibody/data.hpp" 7 #include "pinocchio/parsers/sample-models.hpp" 8 #include "pinocchio/algorithm/joint-configuration.hpp" 9 #include "pinocchio/algorithm/kinematics.hpp" 10 #include "pinocchio/algorithm/jacobian.hpp" 12 #include <boost/test/unit_test.hpp> 13 #include <boost/utility/binary.hpp> 16 using namespace Eigen;
23 VectorXd v_integrate (model.
nv); v_integrate.setZero();
29 for(
int k=0; k<model.
nv; ++k)
33 q_integrate =
integrate(model,q,v_integrate);
39 res.col(k) =
log6(oMi_ref.
inverse()*oMi).toVector();
51 template<
typename Matrix>
54 for(
int k = 0; k < mat.size(); ++k)
55 mat.derived().data()[k] = math::fabs(mat.derived().data()[k]) <= value?0:mat.derived().data()[k];
58 template<
typename Jo
intModel_>
struct init;
60 template<
typename Jo
intModel_>
63 static JointModel_
run()
66 jmodel.setIndexes(0,0,0);
71 template<
typename Scalar,
int Options>
76 static JointModel
run()
79 JointModel jmodel(Vector3::Random().normalized());
86 template<
typename Scalar,
int Options>
91 static JointModel
run()
94 JointModel jmodel(Vector3::Random().normalized());
101 template<
typename Scalar,
int Options>
109 JointModel jmodel(Vector3::Random().normalized());
116 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollection>
131 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollection>
148 template<
typename Jo
intModel_>
157 JointModel jmodel(jmodel_ref,1.,0.);
169 template<
typename Jo
intModel>
172 typedef typename JointModel::ConfigVector_t CV;
173 typedef typename JointModel::TangentVector_t TV;
177 std::cout <<
"name: " << jmodel.
classname() << std::endl;
179 typename JointModel::JointDataDerived jdata_ = jmodel.
createData();
181 DataBaseType & jdata =
static_cast<DataBaseType &
>(jdata_);
183 CV
q = LieGroupType().random();
184 jmodel.
calc(jdata.derived(),
q);
185 SE3 M_ref(jdata.M());
188 const Eigen::DenseIndex
nv = jdata.S().nv();
189 TV
v(nv); v.setZero();
192 Eigen::Matrix<double,6,JointModel::NV> S(6,nv), S_ref(jdata.S().matrix());
194 for(
int k=0;k<
nv;++k)
197 q_int = LieGroupType().integrate(q,v);
198 jmodel.
calc(jdata.derived(),q_int);
199 SE3 M_int = jdata.M();
201 S.col(k) =
log6(M_ref.inverse()*M_int).toVector();
207 BOOST_CHECK(S.isApprox(S_ref,eps*1e1));
208 std::cout <<
"S_ref:\n" << S_ref << std::endl;
209 std::cout <<
"S:\n" << S << std::endl;
235 BOOST_CHECK(Jrh_finite_diff.isApprox(Jrh,1e-8*1e1));
238 Jrh_finite_diff = finiteDiffJacobian<true>(
model,
data,
q,idx);
239 BOOST_CHECK(Jrh_finite_diff.isApprox(Jrh,1e-8*1e1));
242 BOOST_AUTO_TEST_SUITE_END()
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
BOOST_AUTO_TEST_CASE(test_S_finit_diff)
int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space...
The WORLD frame convention corresponds to the frame concident with the Universe/Inertial frame but mo...
pinocchio::JointModelMimic< JointModel_ > JointModel
void setIndexes(JointIndex id, int q, int v)
Data::Matrix6x finiteDiffJacobian(const Model &model, Data &data, const Eigen::VectorXd &q, const Model::JointIndex joint_id)
JointModelDerived & addJoint(const JointModelBase< JointModel > &jmodel, const SE3 &placement=SE3::Identity())
Add a joint to the vector of joints.
void integrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< ReturnType > &qout)
Integrate a configuration vector for the specified model for a tangent vector during one unit time...
pinocchio::JointModelRevoluteUnboundedUnalignedTpl< Scalar, Options > JointModel
int njoints
Number of joints.
MotionTpl< Scalar, Options > log6(const SE3Tpl< Scalar, Options > &M)
Log: SE3 -> se3.
Eigen::Matrix< Scalar, 3, 1, _Options > Vector3
bool existJointName(const std::string &name) const
Check if a joint given by its name exists.
void getJointJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointIndex jointId, const ReferenceFrame rf, const Eigen::MatrixBase< Matrix6Like > &J)
Computes the Jacobian of a specific joint frame expressed either in the world (rf = WORLD) frame or i...
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
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.
JointModelRevoluteTpl< double, 0, 1 > JointModelRY
SE3Tpl inverse() const
aXb = bXa.inverse()
The LOCAL frame convention corresponds to the frame directly attached to the moving part (Joint...
void operator()(JointModelComposite &) const
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
pinocchio::JointIndex JointIndex
static std::string classname()
#define BOOST_TEST_MODULE
Eigen::Matrix< Scalar, 3, 1, _Options > Vector3
pinocchio::JointModelCompositeTpl< Scalar, Options, JointCollection > JointModel
pinocchio::JointModelRevoluteUnalignedTpl< Scalar, Options > JointModel
void setIndexes(JointIndex id, int nq, int nv)
Main pinocchio namespace.
JointIndex getJointId(const std::string &name) const
Return the index of a joint given by its name.
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...
int nv
Dimension of the velocity vector space.
void filterValue(MatrixBase< Matrix > &mat, typename Matrix::Scalar value)
void operator()(JointModelBase< JointModel > &) const
pinocchio::JointModelPrismaticUnalignedTpl< Scalar, Options > JointModel
SE3GroupAction< D >::ReturnType act(const D &d) const
ay = aXb.act(by)
void normalize(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &qout)
Normalize a configuration vector.
pinocchio::JointModelTpl< Scalar, Options, JointCollection > JointModel
JointDataDerived createData() const
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
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
The 6d jacobian type (temporary)
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVector > &q) const
JointModelRevoluteTpl< double, 0, 0 > JointModelRX
JointCollectionTpl & model
int nq
Dimension of the configuration vector representation.