copy.cpp
Go to the documentation of this file.
1 //
2 // Copyright(c) 2018-2020 CNRS INRIA
3 //
4 
10 
11 #include <boost/test/unit_test.hpp>
12 #include <boost/utility/binary.hpp>
13 
14 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
15 
16 BOOST_AUTO_TEST_CASE(test_data_copy)
17 {
18  using namespace Eigen;
19  using namespace pinocchio;
20 
21  Model model;
23 
24  model.upperPositionLimit.head<3>().fill(100);
25  model.upperPositionLimit.segment<4>(3).setOnes();
26  model.lowerPositionLimit.head<7>() = -model.upperPositionLimit.head<7>();
27 
28  VectorXd q(model.nq);
30  VectorXd v(VectorXd::Random(model.nv));
31  VectorXd a(VectorXd::Random(model.nv));
32 
33  Data data_ref(model), data(model);
34  forwardKinematics(model, data_ref, q, v, a);
35  rnea(model, data_ref, q, v, a); // for a_gf to be initialized
36 
37  // Check zero order kinematic quantities
38  copy(model, data_ref, data, POSITION);
39  for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i)
40  {
41  BOOST_CHECK(data.oMi[i] == data_ref.oMi[i]);
42  }
43 
44  // Check first order kinematic quantities
45  copy(model, data_ref, data, VELOCITY);
46  for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i)
47  {
48  BOOST_CHECK(data.oMi[i] == data_ref.oMi[i]);
49  BOOST_CHECK(data.v[i] == data_ref.v[i]);
50  }
51 
52  // Check second order kinematic quantities
53  copy(model, data_ref, data, ACCELERATION);
54  for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i)
55  {
56  BOOST_CHECK(data.oMi[i] == data_ref.oMi[i]);
57  BOOST_CHECK(data.v[i] == data_ref.v[i]);
58  BOOST_CHECK(data.a[i] == data_ref.a[i]);
59  BOOST_CHECK(data.a_gf[i] == data_ref.a_gf[i]);
60  }
61 }
62 
63 BOOST_AUTO_TEST_SUITE_END()
copy.hpp
Eigen
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::forwardKinematics
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.
pinocchio::ACCELERATION
@ ACCELERATION
Definition: multibody/fwd.hpp:65
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
kinematics.hpp
setup.data
data
Definition: cmake/cython/setup.in.py:48
pinocchio::buildModels::humanoidRandom
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
pinocchio::randomConfiguration
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.
Definition: joint-configuration.hpp:315
rnea.hpp
anymal-simulation.model
model
Definition: anymal-simulation.py:8
pinocchio::ModelTpl::JointIndex
pinocchio::JointIndex JointIndex
Definition: multibody/model.hpp:67
joint-configuration.hpp
cartpole.v
v
Definition: cartpole.py:153
q
q
a
Vec3f a
fill
fill
pinocchio::rnea
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & rnea(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 > &a)
The Recursive Newton-Euler algorithm. It computes the inverse dynamics, aka the joint torques accordi...
pinocchio::copy
void copy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &origin, DataTpl< Scalar, Options, JointCollectionTpl > &dest, KinematicLevel kinematic_level)
Copy part of the data from origin to dest. Template parameter can be used to select at which differen...
Definition: copy.hpp:42
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
pinocchio::POSITION
@ POSITION
Definition: multibody/fwd.hpp:61
pinocchio::VELOCITY
@ VELOCITY
Definition: multibody/fwd.hpp:63
sample-models.hpp
setOnes
void setOnes(Eigen::Ref< MatType > mat)
pinocchio::ModelTpl
Definition: context/generic.hpp:20
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_data_copy)
Definition: copy.cpp:16
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:28