Go to the documentation of this file.
23 template<
typename Matrix1,
typename Matrix2,
typename Matrix3>
27 const Eigen::VectorXd & q,
28 const Eigen::VectorXd &
v,
29 const Eigen::VectorXd &
a,
30 const Eigen::MatrixBase<Matrix1> & _drnea_dq,
31 const Eigen::MatrixBase<Matrix2> & _drnea_dv,
32 const Eigen::MatrixBase<Matrix3> & _drnea_da)
38 using namespace Eigen;
39 VectorXd v_eps(VectorXd::Zero(
model.nv));
40 VectorXd q_plus(
model.nq);
41 VectorXd tau_plus(
model.nv);
42 const double alpha = 1e-8;
47 for (
int k = 0; k <
model.nv; ++k)
53 drnea_dq.col(k) = (tau_plus - tau0) /
alpha;
59 for (
int k = 0; k <
model.nv; ++k)
64 drnea_dv.col(k) = (tau_plus - tau0) /
alpha;
70 drnea_da.template triangularView<Eigen::StrictlyLower>() =
71 drnea_da.transpose().template triangularView<Eigen::StrictlyLower>();
77 const Eigen::VectorXd & q,
78 const Eigen::VectorXd &
v,
79 const Eigen::VectorXd &
tau,
80 Eigen::MatrixXd & daba_dq,
81 Eigen::MatrixXd & daba_dv,
84 using namespace Eigen;
85 VectorXd v_eps(VectorXd::Zero(
model.nv));
86 VectorXd q_plus(
model.nq);
87 VectorXd a_plus(
model.nv);
88 const double alpha = 1e-8;
93 for (
int k = 0; k <
model.nv; ++k)
99 daba_dq.col(k) = (a_plus -
a0) /
alpha;
105 for (
int k = 0; k <
model.nv; ++k)
110 daba_dv.col(k) = (a_plus -
a0) /
alpha;
118 int main(
int argc,
const char ** argv)
120 using namespace Eigen;
125 const int NBT = 1000 * 100;
128 std::cout <<
"(the time score in debug mode is not relevant) " << std::endl;
140 const std::string ff_option = argv[2];
141 if (ff_option ==
"-no-ff")
152 std::cout <<
"nq = " <<
model.nq << std::endl;
153 std::cout <<
"nv = " <<
model.nv << std::endl;
154 std::cout <<
"--" << std::endl;
157 VectorXd qmax = Eigen::VectorXd::Ones(
model.nq);
164 for (
size_t i = 0;
i < NBT; ++
i)
167 qdots[
i] = Eigen::VectorXd::Random(
model.nv);
168 qddots[
i] = Eigen::VectorXd::Random(
model.nv);
169 taus[
i] = Eigen::VectorXd::Random(
model.nv);
174 MatrixXd drnea_da(MatrixXd::Zero(
model.nv,
model.nv));
176 MatrixXd daba_dq(MatrixXd::Zero(
model.nv,
model.nv));
177 MatrixXd daba_dv(MatrixXd::Zero(
model.nv,
model.nv));
196 std::cout <<
"FK= \t\t\t\t";
197 timer.
toc(std::cout, NBT);
204 std::cout <<
"FK derivatives= \t\t";
205 timer.
toc(std::cout, NBT);
212 std::cout <<
"RNEA= \t\t\t\t";
213 timer.
toc(std::cout, NBT);
219 model,
data,
qs[_smooth], qdots[_smooth], qddots[_smooth], drnea_dq, drnea_dv, drnea_da);
221 std::cout <<
"RNEA derivatives= \t\t";
222 timer.
toc(std::cout, NBT);
228 model,
data,
qs[_smooth], qdots[_smooth], qddots[_smooth], dtau2_dq, dtau2_dv, dtau2_dqv,
231 std::cout <<
"RNEA derivatives SO= \t\t";
232 timer.
toc(std::cout, NBT);
238 model,
data,
qs[_smooth], qdots[_smooth], qddots[_smooth], drnea_dq, drnea_dv, drnea_da);
240 std::cout <<
"RNEA finite differences= \t";
241 timer.
toc(std::cout, NBT / 100);
248 std::cout <<
"ABA= \t\t\t\t";
249 timer.
toc(std::cout, NBT);
255 model,
data,
qs[_smooth], qdots[_smooth], taus[_smooth], daba_dq, daba_dv, daba_dtau);
257 std::cout <<
"ABA derivatives(q,v,tau)= \t";
258 timer.
toc(std::cout, NBT);
269 std::cout <<
"ABA derivatives() = \t\t" << (total / NBT) <<
" "
276 aba_fd(
model,
data,
qs[_smooth], qdots[_smooth], taus[_smooth], daba_dq, daba_dv, daba_dtau);
278 std::cout <<
"ABA finite differences= \t";
279 timer.
toc(std::cout, NBT / 100);
286 std::cout <<
"M.inverse(q) = \t\t\t";
287 timer.
toc(std::cout, NBT);
298 std::cout <<
"M.inverse() from ABA = \t\t" << (total / NBT) <<
" "
311 std::cout <<
"Minv from Cholesky = \t\t";
312 timer.
toc(std::cout, NBT);
314 std::cout <<
"--" << std::endl;
#define PINOCCHIO_EIGEN_PLAIN_COLUMN_MAJOR_TYPE(D)
Similar to macro PINOCCHIO_EIGEN_PLAIN_TYPE but with guaranty to provite a column major type.
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.
void aba_fd(const pinocchio::Model &model, pinocchio::Data &data_fd, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const Eigen::VectorXd &tau, Eigen::MatrixXd &daba_dq, Eigen::MatrixXd &daba_dv, pinocchio::Data::RowMatrixXs &daba_dtau)
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Options > RowMatrixXs
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
void rnea_fd(const pinocchio::Model &model, pinocchio::Data &data_fd, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const Eigen::VectorXd &a, const Eigen::MatrixBase< Matrix1 > &_drnea_dq, const Eigen::MatrixBase< Matrix2 > &_drnea_dv, const Eigen::MatrixBase< Matrix3 > &_drnea_da)
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
bp::tuple computeRNEADerivatives(const context::Model &model, context::Data &data, const context::VectorXs &q, const context::VectorXs &v, const context::VectorXs &a)
JointModelFreeFlyerTpl< Scalar > JointModelFreeFlyer
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & crba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Convention convention=Convention::LOCAL)
Computes the upper triangular part of the joint space inertia matrix M by using the Composite Rigid B...
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, const Convention convention=Convention::LOCAL)
The Articulated-Body algorithm. It computes the forward dynamics, aka the joint accelerations given t...
static std::string unitName(Unit u)
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.
const DataTpl< Scalar, Options, JointCollectionTpl >::RowMatrixXs & computeMinverse(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the inverse of the joint space inertia matrix using Articulated Body formulation.
void computeForwardKinematicsDerivatives(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)
Computes all the terms required to compute the derivatives of the placement, spatial velocity and acc...
void ComputeRNEASecondOrderDerivatives(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, const Tensor1 &d2tau_dqdq, const Tensor2 &d2tau_dvdv, const Tensor3 &dtau_dqdv, const Tensor4 &dtau_dadq)
Computes the Second-Order partial derivatives of the Recursive Newton Euler Algorithm w....
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.
int main(int argc, const char **argv)
ModelTpl< Scalar, Options, JointCollectionTpl > & buildModel(const std::string &filename, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointModel &rootJoint, const std::string &rootJointName, ModelTpl< Scalar, Options, JointCollectionTpl > &model, const bool verbose=false)
Build the model from a URDF file with a particular joint as root of the model tree inside the model g...
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & decompose(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Compute the Cholesky decomposition of the joint space inertia matrix M contained in data.
Mat & computeMinv(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< Mat > &Minv)
Computes the inverse of the joint space inertia matrix M from its Cholesky factorization.
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...
#define PINOCCHIO_ALIGNED_STD_VECTOR(Type)
bp::tuple computeABADerivatives(const context::Model &model, context::Data &data, const context::VectorXs &q, const context::VectorXs &v, const context::VectorXs &tau)
Main pinocchio namespace.
#define PINOCCHIO_MODEL_DIR
pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:33