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  bp::tuple dDifference_proxy(const Model & model,
54  const Eigen::VectorXd & q1,
55  const Eigen::VectorXd & q2)
56  {
57  Eigen::MatrixXd J0(Eigen::MatrixXd::Zero(model.nv,model.nv));
58  Eigen::MatrixXd J1(Eigen::MatrixXd::Zero(model.nv,model.nv));
59 
60  dDifference(model,q1,q2,J0,ARG0);
61  dDifference(model,q1,q2,J1,ARG1);
62 
63  return bp::make_tuple(J0,J1);
64  }
65 
66  Eigen::MatrixXd dDifference_arg_proxy(const Model & model,
67  const Eigen::VectorXd & q1,
68  const Eigen::VectorXd & q2,
69  const ArgumentPosition arg)
70  {
71  Eigen::MatrixXd J(Eigen::MatrixXd::Zero(model.nv,model.nv));
72 
73  dDifference(model,q1,q2,J,arg);
74 
75  return J;
76  }
77 
79  {
80  using namespace Eigen;
81 
82  bp::def("integrate",
83  &integrate<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
84  bp::args("model","q","v"),
85  "Integrate the joint configuration vector q with a tangent vector v during one unit time.\n"
86  "This is the canonical integrator of a Configuration Space composed of Lie groups, such as most robots.\n\n"
87  "Parameters:\n"
88  "\tmodel: model of the kinematic tree\n"
89  "\tq: the joint configuration vector (size model.nq)\n"
90  "\tv: the joint velocity vector (size model.nv)\n");
91 
92  bp::def("dIntegrate",
94  bp::args("model","q","v"),
95  "Computes the partial derivatives of the integrate function with respect to the first "
96  "and the second argument, and returns the two Jacobians as a tuple.\n\n"
97  "Parameters:\n"
98  "\tmodel: model of the kinematic tree\n"
99  "\tq: the joint configuration vector (size model.nq)\n"
100  "\tv: the joint velocity vector (size model.nv)\n");
101 
102  bp::def("dIntegrate",
104  bp::args("model","q","v","argument_position"),
105  "Computes the partial derivatives of the integrate function with respect to the first (arg == ARG0) "
106  "or the second argument (arg == ARG1).\n\n"
107  "Parameters:\n"
108  "\tmodel: model of the kinematic tree\n"
109  "\tq: the joint configuration vector (size model.nq)\n"
110  "\tv: the joint velocity vector (size model.nv)\n"
111  "\targument_position: either pinocchio.ArgumentPosition.ARG0 or pinocchio.ArgumentPosition.ARG1, depending on the desired Jacobian value.\n");
112 
113  bp::def("interpolate",
114  &interpolate<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
115  bp::args("model","q1","q2","alpha"),
116  "Interpolate between two given joint configuration vectors q1 and q2.\n\n"
117  "Parameters:\n"
118  "\tmodel: model of the kinematic tree\n"
119  "\tq1: the initial joint configuration vector (size model.nq)\n"
120  "\tq2: the terminal joint configuration vector (size model.nq)\n"
121  "\talpha: the interpolation coefficient in [0,1]\n");
122 
123  bp::def("difference",
124  &difference<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
125  bp::args("model","q1","q2"),
126  "Difference between two joint configuration vectors, i.e. the tangent vector that must be integrated during one unit time"
127  "to go from q1 to q2.\n\n"
128  "Parameters:\n"
129  "\tmodel: model of the kinematic tree\n"
130  "\tq1: the initial joint configuration vector (size model.nq)\n"
131  "\tq2: the terminal joint configuration vector (size model.nq)\n");
132 
133  bp::def("squaredDistance",
134  &squaredDistance<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
135  bp::args("model","q1","q2"),
136  "Squared distance vector between two joint configuration vectors.\n\n"
137  "Parameters:\n"
138  "\tmodel: model of the kinematic tree\n"
139  "\tq1: the initial joint configuration vector (size model.nq)\n"
140  "\tq2: the terminal joint configuration vector (size model.nq)\n");
141 
142  bp::def("distance",
143  &distance<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
144  bp::args("model","q1","q2"),
145  "Distance between two joint configuration vectors.\n\n"
146  "Parameters:\n"
147  "\tmodel: model of the kinematic tree\n"
148  "\tq1: the initial joint configuration vector (size model.nq)\n"
149  "\tq2: the terminal joint configuration vector (size model.nq)\n");
150 
151  bp::def("dDifference",
153  bp::args("model","q1","q2"),
154  "Computes the partial derivatives of the difference function with respect to the first "
155  "and the second argument, and returns the two Jacobians as a tuple.\n\n"
156  "Parameters:\n"
157  "\tmodel: model of the kinematic tree\n"
158  "\tq1: the initial joint configuration vector (size model.nq)\n"
159  "\tq2: the terminal joint configuration vector (size model.nq)\n");
160 
161  bp::def("dDifference",
163  bp::args("model","q1","q2","argument_position"),
164  "Computes the partial derivatives of the difference function with respect to the first (arg == ARG0) "
165  "or the second argument (arg == ARG1).\n\n"
166  "Parameters:\n"
167  "\tmodel: model of the kinematic tree\n"
168  "\tq1: the initial joint configuration vector (size model.nq)\n"
169  "\tq2: the terminal joint configuration vector (size model.nq)\n"
170  "\targument_position: either pinocchio.ArgumentPosition.ARG0 or pinocchio.ArgumentPosition.ARG1, depending on the desired Jacobian value.\n");
171 
172  bp::def("randomConfiguration",
174  bp::arg("model"),
175  "Generate a random configuration in the bounds given by the lower and upper limits contained in model.\n\n"
176  "Parameters:\n"
177  "\tmodel: model of the kinematic tree\n");
178 
179  bp::def("randomConfiguration",
180  &randomConfiguration<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
181  bp::args("model","lower_bound","upper_bound"),
182  "Generate a random configuration in the bounds given by the Joint lower and upper limits arguments.\n\n"
183  "Parameters:\n"
184  "\tmodel: model of the kinematic tree\n"
185  "\tlower_bound: the lower bound on the joint configuration vectors (size model.nq)\n"
186  "\tupper_bound: the upper bound on the joint configuration vectors (size model.nq)\n");
187 
188  bp::def("neutral",
189  &neutral<double,0,JointCollectionDefaultTpl>,
190  bp::arg("model"),
191  "Returns the neutral configuration vector associated to the model.\n\n"
192  "Parameters:\n"
193  "\tmodel: model of the kinematic tree\n");
194 
195  bp::def("normalize",normalize_proxy,
196  bp::args("model","q"),
197  "Returns the configuration normalized.\n"
198  "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"
199  "Parameters:\n"
200  "\tmodel: model of the kinematic tree\n"
201  "\tq: a joint configuration vector to normalize (size model.nq)\n");
202 
203  bp::def("isSameConfiguration",
204  &isSameConfiguration<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
205  bp::args("model","q1","q2","prec"),
206  "Return true if two configurations are equivalent within the given precision provided by prec.\n\n"
207  "Parameters:\n"
208  "\tmodel: model of the kinematic tree\n"
209  "\tq1: a joint configuration vector (size model.nq)\n"
210  "\tq2: a joint configuration vector (size model.nq)\n"
211  "\tprec: requested accuracy for the comparison\n");
212 
213  bp::def("isNormalized",
214  &isNormalized<double,0,JointCollectionDefaultTpl,VectorXd>,
215  isNormalized_overload(
216  bp::args("model","q","prec"),
217  "Check whether a configuration vector is normalized within the given precision provided by prec.\n\n"
218  "Parameters:\n"
219  "\tmodel: model of the kinematic tree\n"
220  "\tq: a joint configuration vector (size model.nq)\n"
221  "\tprec: requested accuracy for the check\n"
222  )
223  );
224  }
225 
226  } // namespace python
227 } // 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 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 dDifference_arg_proxy(const Model &model, const Eigen::VectorXd &q1, const Eigen::VectorXd &q2, const ArgumentPosition arg)
Main pinocchio namespace.
Definition: timings.cpp:30
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 Tue Jun 1 2021 02:45:02