expose-com.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 //
4 
7 #include "pinocchio/algorithm/center-of-mass.hpp"
8 
9 #include <boost/python/overloads.hpp>
10 
11 namespace pinocchio
12 {
13  namespace python
14  {
15 
16  BOOST_PYTHON_FUNCTION_OVERLOADS(jacobianCenterOfMassUpdate_overload,jacobianCenterOfMass,3,4)
17 
18  BOOST_PYTHON_FUNCTION_OVERLOADS(jacobianCenterOfMassNoUpdate_overload,jacobianCenterOfMass,2,3)
19 
20  static SE3::Vector3
22  Data & data,
23  const Eigen::VectorXd & q,
24  bool computeSubtreeComs = true)
25  {
26  return centerOfMass(model,data,q,computeSubtreeComs);
27  }
28 
29  static SE3::Vector3
31  Data & data,
32  const Eigen::VectorXd & q,
33  const Eigen::VectorXd & v,
34  bool computeSubtreeComs = true)
35  {
36  return centerOfMass(model,data,q,v,computeSubtreeComs);
37  }
38 
39  static SE3::Vector3
41  Data & data,
42  const Eigen::VectorXd & q,
43  const Eigen::VectorXd & v,
44  const Eigen::VectorXd & a,
45  bool computeSubtreeComs = true)
46  {
47  return centerOfMass(model,data,q,v,a,computeSubtreeComs);
48  }
49 
50  static const Data::Vector3 &
52  Data & data,
53  KinematicLevel kinematic_level,
54  bool computeSubtreeComs = true)
55  {
56  return centerOfMass(model,data,kinematic_level,computeSubtreeComs);
57  }
58 
59  static void
61  Data & data,
62  int kinematic_level,
63  bool computeSubtreeComs = true)
64  {
65  centerOfMass(model,data,static_cast<KinematicLevel>(kinematic_level),computeSubtreeComs);
66  }
67 
68  static const Data::Vector3 &
70  Data & data,
71  bool computeSubtreeComs = true)
72  {
73  return centerOfMass(model,data,computeSubtreeComs);
74  }
75 
76  static Data::Matrix3x
78  Data & data,
79  const Eigen::VectorXd & q,
80  Model::JointIndex jointId)
81  {
82  Data::Matrix3x J(3,model.nv); J.setZero();
83  jacobianSubtreeCenterOfMass(model, data, q, jointId, J);
84 
85  return J;
86  }
87 
88  static Data::Matrix3x
90  Data & data,
91  Model::JointIndex jointId)
92  {
93  Data::Matrix3x J(3,model.nv); J.setZero();
94  jacobianSubtreeCenterOfMass(model, data, jointId, J);
95 
96  return J;
97  }
98 
99  static Data::Matrix3x
101  Data & data,
102  Model::JointIndex jointId)
103  {
104  Data::Matrix3x J(3,model.nv); J.setZero();
105  getJacobianSubtreeCenterOfMass(model, data, jointId, J);
106 
107  return J;
108  }
109 
110  BOOST_PYTHON_FUNCTION_OVERLOADS(com_0_overload, com_0_proxy, 3, 4)
111 
112  BOOST_PYTHON_FUNCTION_OVERLOADS(com_1_overload, com_1_proxy, 4, 5)
113 
114  BOOST_PYTHON_FUNCTION_OVERLOADS(com_2_overload, com_2_proxy, 5, 6)
115 
116  BOOST_PYTHON_FUNCTION_OVERLOADS(com_level_overload, com_level_proxy, 3, 4)
117  BOOST_PYTHON_FUNCTION_OVERLOADS(com_level_overload_deprecated_signature, com_level_proxy_deprecated_signature, 3, 4)
118 
119  BOOST_PYTHON_FUNCTION_OVERLOADS(com_default_overload, com_default_proxy, 2, 3)
120 
121  void exposeCOM()
122  {
123  using namespace Eigen;
124 
125  bp::def("computeTotalMass",
126  (double (*)(const Model &))&computeTotalMass<double,0,JointCollectionDefaultTpl>,
127  bp::args("model"),
128  "Compute the total mass of the model and return it.");
129 
130  bp::def("computeTotalMass",
131  (double (*)(const Model &, Data &))&computeTotalMass<double,0,JointCollectionDefaultTpl>,
132  bp::args("model","data"),
133  "Compute the total mass of the model, put it in data.mass[0] and return it.");
134 
135  bp::def("computeSubtreeMasses",
136  (void (*)(const Model &, Data &))&computeSubtreeMasses<double,0,JointCollectionDefaultTpl>,
137  bp::args("model","data"),
138  "Compute the mass of each kinematic subtree and store it in the vector data.mass.");
139 
140  bp::def("centerOfMass",
141  com_0_proxy,
142  com_0_overload(bp::args("model","data",
143  "q",
144  "compute_subtree_coms"),
145  "Compute the center of mass, putting the result in Data and return it."
146  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees."
147  )[bp::return_value_policy<bp::return_by_value>()]
148  );
149 
150  bp::def("centerOfMass",
151  com_1_proxy,
152  com_1_overload(
153  bp::args("model","data",
154  "q","v",
155  "compute_subtree_coms"),
156  "Computes the center of mass position and velocity by storing the result in Data. It returns the center of mass position expressed in the WORLD frame.\n"
157  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees."
158  )[bp::return_value_policy<bp::return_by_value>()]
159  );
160 
161  bp::def("centerOfMass",
162  com_2_proxy,
163  com_2_overload(
164  bp::args("model","data",
165  "q","v","a",
166  "compute_subtree_coms"),
167  "Computes the center of mass position, velocity and acceleration by storing the result in Data. It returns the center of mass position expressed in the WORLD frame.\n"
168  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees."
169  )[bp::return_value_policy<bp::return_by_value>()]
170  );
171 
172  bp::def("centerOfMass",
174  com_level_overload_deprecated_signature(
175  bp::args("Model","Data",
176  "kinematic_level",
177  "computeSubtreeComs If true, the algorithm computes also the center of mass of the subtrees"
178  ),
179  "Computes the center of mass position, velocity and acceleration of a given model according to the current kinematic values contained in data and the requested kinematic_level.\n"
180  "If kinematic_level = 0, computes the CoM position, if kinematic_level = 1, also computes the CoM velocity and if kinematic_level = 2, it also computes the CoM acceleration."
182  );
183 
184  bp::def("centerOfMass",
186  com_level_overload(bp::args("model","data",
187  "kinematic_level",
188  "compute_subtree_coms"),
189  "Computes the center of mass position, velocity or acceleration of a given model according to the current kinematic values contained in data and the requested kinematic_level.\n"
190  "If kinematic_level = POSITION, computes the CoM position, if kinematic_level = VELOCITY, also computes the CoM velocity and if kinematic_level = ACCELERATION, it also computes the CoM acceleration.\n"
191  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees."
192  )[bp::return_value_policy<bp::return_by_value>()]
193  );
194 
195  bp::def("centerOfMass",
197  com_default_overload(
198  bp::args("model",
199  "data",
200  "compute_subtree_coms"),
201  "Computes the center of mass position, velocity and acceleration of a given model according to the current kinematic values contained in data.\n"
202  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees."
203  )[bp::return_value_policy<bp::return_by_value>()]
204  );
205 
206  bp::def("jacobianCenterOfMass",
207  (const Data::Matrix3x & (*)(const Model &, Data &, const Eigen::MatrixBase<Eigen::VectorXd> &, bool))&jacobianCenterOfMass<double,0,JointCollectionDefaultTpl,VectorXd>,
208  jacobianCenterOfMassUpdate_overload(bp::args("model",
209  "data",
210  "q",
211  "compute_subtree_coms"),
212  "Computes the Jacobian of the center of mass, puts the result in Data and return it.\n"
213  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees.")[
214  bp::return_value_policy<bp::return_by_value>()]);
215 
216  bp::def("jacobianCenterOfMass",
217  (const Data::Matrix3x & (*)(const Model &, Data &, bool))&jacobianCenterOfMass<double,0,JointCollectionDefaultTpl>,
218  jacobianCenterOfMassNoUpdate_overload(bp::args("model",
219  "data",
220  "compute_subtree_coms"),
221  "Computes the Jacobian of the center of mass, puts the result in Data and return it.\n"
222  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the subtrees.")[
223  bp::return_value_policy<bp::return_by_value>()]);
224 
225  bp::def("jacobianSubtreeCenterOfMass",jacobian_subtree_com_kinematics_proxy,
226  bp::args("model",
227  "data",
228  "q",
229  "subtree_root_joint_id"),
230  "Computes the Jacobian of the CoM of the given subtree (subtree_root_joint_id) expressed in the WORLD frame, according to the given joint configuration.");
231  bp::def("jacobianSubtreeCoMJacobian",jacobian_subtree_com_kinematics_proxy,
232  bp::args("Model, the model of the kinematic tree",
233  "Data, the data associated to the model where the results are stored",
234  "Joint configuration q (size Model::nq)",
235  "Subtree root ID, the index of the subtree root joint."),
236  "Computes the Jacobian of the CoM of the given subtree expressed in the world frame, according to the given joint configuration.",
237  deprecated_function<>("This function is now deprecated. It has been renamed jacobianSubtreeCenterOfMass."));
238 
239  bp::def("jacobianSubtreeCenterOfMass",jacobian_subtree_com_proxy,
240  bp::args("model",
241  "data",
242  "subtree_root_joint_id"),
243  "Computes the Jacobian of the CoM of the given subtree (subtree_root_joint_id) expressed in the WORLD frame, according to the given entries in data.");
244 
245  bp::def("jacobianSubtreeCoMJacobian",jacobian_subtree_com_proxy,
246  bp::args("Model, the model of the kinematic tree",
247  "Data, the data associated to the model where the results are stored",
248  "Subtree root ID, the index of the subtree root joint."),
249  "Computes the Jacobian of the CoM of the given subtree expressed in the world frame, according to the given entries in data.",
250  deprecated_function<>("This function is now deprecated. It has been renamed jacobianSubtreeCenterOfMass."));
251 
252  bp::def("getJacobianSubtreeCenterOfMass",get_jacobian_subtree_com_proxy,
253  bp::args("model",
254  "data",
255  "subtree_root_joint_id"),
256  "Get the Jacobian of the CoM of the given subtree expressed in the world frame, according to the given entries in data. It assumes that jacobianCenterOfMass has been called first.");
257 
258  }
259 
260  } // namespace python
261 } // namespace pinocchio
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix3x & jacobianCenterOfMass(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const bool computeSubtreeComs=true)
Computes both the jacobian and the the center of mass position of a given model according to a partic...
static SE3::Vector3 com_0_proxy(const Model &model, Data &data, const Eigen::VectorXd &q, bool computeSubtreeComs=true)
Definition: expose-com.cpp:21
BOOST_PYTHON_FUNCTION_OVERLOADS(computeKKTContactDynamicMatrixInverse_overload, computeKKTContactDynamicMatrixInverse_proxy, 4, 5) static const Eigen
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
static void com_level_proxy_deprecated_signature(const Model &model, Data &data, int kinematic_level, bool computeSubtreeComs=true)
Definition: expose-com.cpp:60
static const Data::Vector3 & com_default_proxy(const Model &model, Data &data, bool computeSubtreeComs=true)
Definition: expose-com.cpp:69
static Data::Matrix3x jacobian_subtree_com_kinematics_proxy(const Model &model, Data &data, const Eigen::VectorXd &q, Model::JointIndex jointId)
Definition: expose-com.cpp:77
static const Data::Vector3 & com_level_proxy(const Model &model, Data &data, KinematicLevel kinematic_level, bool computeSubtreeComs=true)
Definition: expose-com.cpp:51
static SE3::Vector3 com_1_proxy(const Model &model, Data &data, const Eigen::VectorXd &q, const Eigen::VectorXd &v, bool computeSubtreeComs=true)
Definition: expose-com.cpp:30
pinocchio::JointIndex JointIndex
KinematicLevel
List of Kinematics Level supported by Pinocchio.
traits< SE3Tpl >::Vector3 Vector3
void getJacobianSubtreeCenterOfMass(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const JointIndex &rootSubtreeId, const Eigen::MatrixBase< Matrix3xLike > &res)
Retrieves the Jacobian of the center of mass of the given subtree according to the current value stor...
Main pinocchio namespace.
Definition: timings.cpp:30
int nv
Dimension of the velocity vector space.
Eigen::Matrix< Scalar, 3, Eigen::Dynamic, Options > Matrix3x
The 3d jacobian type (temporary)
static Data::Matrix3x jacobian_subtree_com_proxy(const Model &model, Data &data, Model::JointIndex jointId)
Definition: expose-com.cpp:89
const DataTpl< Scalar, Options, JointCollectionTpl >::Vector3 & centerOfMass(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const bool computeSubtreeComs=true)
Computes the center of mass position of a given model according to a particular joint configuration...
void jacobianSubtreeCenterOfMass(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const JointIndex &rootSubtreeId, const Eigen::MatrixBase< Matrix3xLike > &res)
Computes the Jacobian of the center of mass of the given subtree according to a particular joint conf...
SE3Tpl< double, 0 > SE3
static SE3::Vector3 com_2_proxy(const Model &model, Data &data, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const Eigen::VectorXd &a, bool computeSubtreeComs=true)
Definition: expose-com.cpp:40
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorXd
Definition: conversions.cpp:14
JointCollectionTpl & model
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
static Data::Matrix3x get_jacobian_subtree_com_proxy(const Model &model, Data &data, Model::JointIndex jointId)
Definition: expose-com.cpp:100


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:02