algorithm/expose-joints.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 //
4 
6 #include "pinocchio/algorithm/joint-configuration.hpp"
7 
8 namespace pinocchio
9 {
10  namespace python
11  {
12 
13  BOOST_PYTHON_FUNCTION_OVERLOADS(isNormalized_overload,isNormalized,2,3)
14 
16  const Eigen::VectorXd & config)
17  {
18  Eigen::VectorXd q(config);
19  normalize(model,q);
20  return q;
21  }
22 
24  {
25  return randomConfiguration(model);
26  }
27 
28  bp::tuple dIntegrate_proxy(const Model & model,
29  const Eigen::VectorXd & q,
30  const Eigen::VectorXd & v)
31  {
32  Eigen::MatrixXd J0(Eigen::MatrixXd::Zero(model.nv,model.nv));
33  Eigen::MatrixXd J1(Eigen::MatrixXd::Zero(model.nv,model.nv));
34 
35  dIntegrate(model,q,v,J0,ARG0);
36  dIntegrate(model,q,v,J1,ARG1);
37 
38  return bp::make_tuple(J0,J1);
39  }
40 
41  Eigen::MatrixXd dIntegrate_arg_proxy(const Model & model,
42  const Eigen::VectorXd & q,
43  const Eigen::VectorXd & v,
44  const ArgumentPosition arg)
45  {
46  Eigen::MatrixXd J(Eigen::MatrixXd::Zero(model.nv,model.nv));
47 
48  dIntegrate(model,q,v,J,arg, SETTO);
49 
50  return J;
51  }
52 
53  Eigen::MatrixXd dIntegrateTransport_proxy(const Model & model,
54  const Eigen::VectorXd & q,
55  const Eigen::VectorXd & v,
56  const Eigen::MatrixXd & Jin,
57  const ArgumentPosition arg)
58  {
59  int ncols = Jin.cols();
60  Eigen::MatrixXd Jout(Eigen::MatrixXd::Zero(model.nv,ncols));
61  dIntegrateTransport(model, q, v, Jin, Jout, arg);
62  return Jout;
63  }
64 
65  bp::tuple dDifference_proxy(const Model & model,
66  const Eigen::VectorXd & q1,
67  const Eigen::VectorXd & q2)
68  {
69  Eigen::MatrixXd J0(Eigen::MatrixXd::Zero(model.nv,model.nv));
70  Eigen::MatrixXd J1(Eigen::MatrixXd::Zero(model.nv,model.nv));
71 
72  dDifference(model,q1,q2,J0,ARG0);
73  dDifference(model,q1,q2,J1,ARG1);
74 
75  return bp::make_tuple(J0,J1);
76  }
77 
78  Eigen::MatrixXd dDifference_arg_proxy(const Model & model,
79  const Eigen::VectorXd & q1,
80  const Eigen::VectorXd & q2,
81  const ArgumentPosition arg)
82  {
83  Eigen::MatrixXd J(Eigen::MatrixXd::Zero(model.nv,model.nv));
84 
85  dDifference(model,q1,q2,J,arg);
86 
87  return J;
88  }
89 
91  {
92  using namespace Eigen;
93 
94  bp::def("integrate",
95  &integrate<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
96  bp::args("model","q","v"),
97  "Integrate the joint configuration vector q with a tangent vector v during one unit time.\n"
98  "This is the canonical integrator of a Configuration Space composed of Lie groups, such as most robots.\n\n"
99  "Parameters:\n"
100  "\tmodel: model of the kinematic tree\n"
101  "\tq: the joint configuration vector (size model.nq)\n"
102  "\tv: the joint velocity vector (size model.nv)\n");
103 
104  bp::def("dIntegrate",
106  bp::args("model","q","v"),
107  "Computes the partial derivatives of the integrate function with respect to the first "
108  "and the second argument, and returns the two Jacobians as a tuple.\n\n"
109  "Parameters:\n"
110  "\tmodel: model of the kinematic tree\n"
111  "\tq: the joint configuration vector (size model.nq)\n"
112  "\tv: the joint velocity vector (size model.nv)\n");
113 
114  bp::def("dIntegrate",
116  bp::args("model","q","v","argument_position"),
117  "Computes the partial derivatives of the integrate function with respect to the first (arg == ARG0) "
118  "or the second argument (arg == ARG1).\n\n"
119  "Parameters:\n"
120  "\tmodel: model of the kinematic tree\n"
121  "\tq: the joint configuration vector (size model.nq)\n"
122  "\tv: the joint velocity vector (size model.nv)\n"
123  "\targument_position: either pinocchio.ArgumentPosition.ARG0 or pinocchio.ArgumentPosition.ARG1, depending on the desired Jacobian value.\n");
124 
125  bp::def("dIntegrateTransport",
127  bp::args("model","q","v","Jin","argument_position"),
128  "Takes a matrix expressed at q (+) v and uses parallel transport to express it in the tangent space at q."
129  "\tThis operation does the product of the matrix by the Jacobian of the integration operation, but more efficiently."
130  "Parameters:\n"
131  "\tmodel: model of the kinematic tree\n"
132  "\tq: the joint configuration vector (size model.nq)\n"
133  "\tv: the joint velocity vector (size model.nv)\n"
134  "\tJin: the input matrix (row size model.nv)"
135  "\targument_position: either pinocchio.ArgumentPosition.ARG0 (q) or pinocchio.ArgumentPosition.ARG1 (v), depending on the desired Jacobian value.\n");
136 
137  bp::def("interpolate",
138  &interpolate<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
139  bp::args("model","q1","q2","alpha"),
140  "Interpolate between two given joint configuration vectors q1 and q2.\n\n"
141  "Parameters:\n"
142  "\tmodel: model of the kinematic tree\n"
143  "\tq1: the initial joint configuration vector (size model.nq)\n"
144  "\tq2: the terminal joint configuration vector (size model.nq)\n"
145  "\talpha: the interpolation coefficient in [0,1]\n");
146 
147  bp::def("difference",
148  &difference<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
149  bp::args("model","q1","q2"),
150  "Difference between two joint configuration vectors, i.e. the tangent vector that must be integrated during one unit time"
151  "to go from q1 to q2.\n\n"
152  "Parameters:\n"
153  "\tmodel: model of the kinematic tree\n"
154  "\tq1: the initial joint configuration vector (size model.nq)\n"
155  "\tq2: the terminal joint configuration vector (size model.nq)\n");
156 
157  bp::def("squaredDistance",
158  &squaredDistance<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
159  bp::args("model","q1","q2"),
160  "Squared distance vector between two joint configuration vectors.\n\n"
161  "Parameters:\n"
162  "\tmodel: model of the kinematic tree\n"
163  "\tq1: the initial joint configuration vector (size model.nq)\n"
164  "\tq2: the terminal joint configuration vector (size model.nq)\n");
165 
166  bp::def("distance",
167  &distance<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
168  bp::args("model","q1","q2"),
169  "Distance between two joint configuration vectors.\n\n"
170  "Parameters:\n"
171  "\tmodel: model of the kinematic tree\n"
172  "\tq1: the initial joint configuration vector (size model.nq)\n"
173  "\tq2: the terminal joint configuration vector (size model.nq)\n");
174 
175  bp::def("dDifference",
177  bp::args("model","q1","q2"),
178  "Computes the partial derivatives of the difference function with respect to the first "
179  "and the second argument, and returns the two Jacobians as a tuple.\n\n"
180  "Parameters:\n"
181  "\tmodel: model of the kinematic tree\n"
182  "\tq1: the initial joint configuration vector (size model.nq)\n"
183  "\tq2: the terminal joint configuration vector (size model.nq)\n");
184 
185  bp::def("dDifference",
187  bp::args("model","q1","q2","argument_position"),
188  "Computes the partial derivatives of the difference function with respect to the first (arg == ARG0) "
189  "or the second argument (arg == ARG1).\n\n"
190  "Parameters:\n"
191  "\tmodel: model of the kinematic tree\n"
192  "\tq1: the initial joint configuration vector (size model.nq)\n"
193  "\tq2: the terminal joint configuration vector (size model.nq)\n"
194  "\targument_position: either pinocchio.ArgumentPosition.ARG0 or pinocchio.ArgumentPosition.ARG1, depending on the desired Jacobian value.\n");
195 
196  bp::def("randomConfiguration",
198  bp::arg("model"),
199  "Generate a random configuration in the bounds given by the lower and upper limits contained in model.\n\n"
200  "Parameters:\n"
201  "\tmodel: model of the kinematic tree\n");
202 
203  bp::def("randomConfiguration",
204  &randomConfiguration<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
205  bp::args("model","lower_bound","upper_bound"),
206  "Generate a random configuration in the bounds given by the Joint lower and upper limits arguments.\n\n"
207  "Parameters:\n"
208  "\tmodel: model of the kinematic tree\n"
209  "\tlower_bound: the lower bound on the joint configuration vectors (size model.nq)\n"
210  "\tupper_bound: the upper bound on the joint configuration vectors (size model.nq)\n");
211 
212  bp::def("neutral",
213  &neutral<double,0,JointCollectionDefaultTpl>,
214  bp::arg("model"),
215  "Returns the neutral configuration vector associated to the model.\n\n"
216  "Parameters:\n"
217  "\tmodel: model of the kinematic tree\n");
218 
219  bp::def("normalize",normalize_proxy,
220  bp::args("model","q"),
221  "Returns the configuration normalized.\n"
222  "For instance, when the configuration vectors contains some quaternion values, it must be required to renormalize these components to keep orthonormal rotation values.\n\n"
223  "Parameters:\n"
224  "\tmodel: model of the kinematic tree\n"
225  "\tq: a joint configuration vector to normalize (size model.nq)\n");
226 
227  bp::def("isSameConfiguration",
228  &isSameConfiguration<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
229  bp::args("model","q1","q2","prec"),
230  "Return true if two configurations are equivalent within the given precision provided by prec.\n\n"
231  "Parameters:\n"
232  "\tmodel: model of the kinematic tree\n"
233  "\tq1: a joint configuration vector (size model.nq)\n"
234  "\tq2: a joint configuration vector (size model.nq)\n"
235  "\tprec: requested accuracy for the comparison\n");
236 
237  bp::def("isNormalized",
238  &isNormalized<double,0,JointCollectionDefaultTpl,VectorXd>,
239  isNormalized_overload(
240  bp::args("model","q","prec"),
241  "Check whether a configuration vector is normalized within the given precision provided by prec.\n\n"
242  "Parameters:\n"
243  "\tmodel: model of the kinematic tree\n"
244  "\tq: a joint configuration vector (size model.nq)\n"
245  "\tprec: requested accuracy for the check\n"
246  )
247  );
248  }
249 
250  } // namespace python
251 } // namespace pinocchio
ArgumentPosition
Argument position. Used as template parameter to refer to an argument.
Definition: src/fwd.hpp:59
bp::tuple dDifference_proxy(const Model &model, const Eigen::VectorXd &q1, const Eigen::VectorXd &q2)
void dDifference(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVector1 > &q0, const Eigen::MatrixBase< ConfigVector2 > &q1, const Eigen::MatrixBase< JacobianMatrix > &J, const ArgumentPosition arg)
Computes the Jacobian of a small variation of the configuration vector into the tangent space at iden...
bool isNormalized(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision())
Check whether a configuration vector is normalized within the given precision provided by prec...
BOOST_PYTHON_FUNCTION_OVERLOADS(computeKKTContactDynamicMatrixInverse_overload, computeKKTContactDynamicMatrixInverse_proxy, 4, 5) static const Eigen
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.
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
void dIntegrateTransport(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< JacobianMatrixType1 > &Jin, const Eigen::MatrixBase< JacobianMatrixType2 > &Jout, const ArgumentPosition arg)
Transport a matrix from the terminal to the originate tangent space of the integrate operation...
void dIntegrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< JacobianMatrixType > &J, const ArgumentPosition arg, const AssignmentOperatorType op=SETTO)
Computes the Jacobian of a small variation of the configuration vector or the tangent vector into the...
static Eigen::VectorXd randomConfiguration_proxy(const Model &model)
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > & q1
static Eigen::VectorXd normalize_proxy(const Model &model, const Eigen::VectorXd &config)
Eigen::MatrixXd dIntegrateTransport_proxy(const Model &model, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const Eigen::MatrixXd &Jin, const ArgumentPosition arg)
Eigen::MatrixXd dDifference_arg_proxy(const Model &model, const Eigen::VectorXd &q1, const Eigen::VectorXd &q2, const ArgumentPosition arg)
Main pinocchio namespace.
Definition: timings.cpp:28
int nv
Dimension of the velocity vector space.
bp::tuple dIntegrate_proxy(const Model &model, const Eigen::VectorXd &q, const Eigen::VectorXd &v)
void normalize(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &qout)
Normalize a configuration vector.
Eigen::MatrixXd dIntegrate_arg_proxy(const Model &model, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const ArgumentPosition arg)
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorXd
Definition: conversions.cpp:14
JointCollectionTpl & model


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:30