expose-com.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 //
4 
7 
9 
10 #include <boost/python/overloads.hpp>
11 
12 namespace pinocchio
13 {
14  namespace python
15  {
16 
18  const context::Model & model,
20  const context::VectorXs & q,
21  bool computeSubtreeComs = true)
22  {
23  return centerOfMass(model, data, q, computeSubtreeComs);
24  }
25 
27  const context::Model & model,
29  const context::VectorXs & q,
30  const context::VectorXs & v,
31  bool computeSubtreeComs = true)
32  {
33  return centerOfMass(model, data, q, v, computeSubtreeComs);
34  }
35 
37  const context::Model & model,
39  const context::VectorXs & q,
40  const context::VectorXs & v,
41  const context::VectorXs & a,
42  bool computeSubtreeComs = true)
43  {
44  return centerOfMass(model, data, q, v, a, computeSubtreeComs);
45  }
46 
48  const context::Model & model,
50  KinematicLevel kinematic_level,
51  bool computeSubtreeComs = true)
52  {
53  return centerOfMass(model, data, kinematic_level, computeSubtreeComs);
54  }
55 
57  const context::Model & model, context::Data & data, bool computeSubtreeComs = true)
58  {
59  return centerOfMass(model, data, computeSubtreeComs);
60  }
61 
63  const context::Model & model,
65  const context::VectorXs & q,
67  {
69  J.setZero();
71 
72  return J;
73  }
74 
77  {
79  J.setZero();
81 
82  return J;
83  }
84 
87  {
89  J.setZero();
91 
92  return J;
93  }
94 
95  void exposeCOM()
96  {
97  typedef context::Scalar Scalar;
99  enum
100  {
102  };
103 
104  bp::def(
105  "computeTotalMass",
106  (Scalar(*)(
107  const context::Model &))&computeTotalMass<Scalar, Options, JointCollectionDefaultTpl>,
108  bp::args("model"), "Compute the total mass of the model and return it.");
109 
110  bp::def(
111  "computeTotalMass",
112  (Scalar(*)(
113  const context::Model &,
114  context::Data &))&computeTotalMass<Scalar, Options, JointCollectionDefaultTpl>,
115  bp::args("model", "data"),
116  "Compute the total mass of the model, put it in data.mass[0] and return it.");
117 
118  bp::def(
119  "computeSubtreeMasses",
120  (void (*)(
121  const context::Model &,
122  context::Data &))&computeSubtreeMasses<Scalar, Options, JointCollectionDefaultTpl>,
123  bp::args("model", "data"),
124  "Compute the mass of each kinematic subtree and store it in the vector data.mass.");
125 
126  bp::def(
127  "centerOfMass", com_0_proxy,
128  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("compute_subtree_coms") = true),
129  "Compute the center of mass, putting the result in context::Data and return it."
130  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
131  "subtrees.",
132  bp::return_value_policy<bp::return_by_value>());
133 
134  bp::def(
135  "centerOfMass", com_1_proxy,
136  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("v"),
137  bp::arg("compute_subtree_coms") = true),
138  "Computes the center of mass position and velocity by storing the result in context::Data. "
139  "It returns the center of mass position expressed in the WORLD frame.\n"
140  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
141  "subtrees.",
142  bp::return_value_policy<bp::return_by_value>());
143 
144  bp::def(
145  "centerOfMass", com_2_proxy,
146  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("v"), bp::arg("a"),
147  bp::arg("compute_subtree_coms") = true),
148  "Computes the center of mass position, velocity and acceleration by storing the result in "
149  "context::Data. It returns the center of mass position expressed in the WORLD frame.\n"
150  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
151  "subtrees.",
152  bp::return_value_policy<bp::return_by_value>());
153 
154  bp::def(
155  "centerOfMass", com_level_proxy,
156  (bp::arg("model"), bp::arg("data"), bp::arg("kinematic_level"),
157  bp::arg("compute_subtree_coms") = true),
158  "Computes the center of mass position, velocity or acceleration of a given model according "
159  "to the current kinematic values contained in data and the requested kinematic_level.\n"
160  "If kinematic_level = POSITION, computes the CoM position, if kinematic_level = VELOCITY, "
161  "also computes the CoM velocity and if kinematic_level = ACCELERATION, it also computes "
162  "the CoM acceleration.\n"
163  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
164  "subtrees.",
165  bp::return_value_policy<bp::return_by_value>());
166 
167  bp::def(
168  "centerOfMass", com_default_proxy,
169  (bp::arg("model"), bp::arg("data"), bp::arg("compute_subtree_coms") = true),
170  "Computes the center of mass position, velocity and acceleration of a given model "
171  "according to the current kinematic values contained in data.\n"
172  "If compute_subtree_coms is True, the algorithm also computes the center of mass of "
173  "the subtrees.",
174  bp::return_value_policy<bp::return_by_value>());
175 
176  bp::def(
177  "jacobianCenterOfMass",
178  (const context::Data::Matrix3x & (*)(const context::Model &, context::Data &,
179  const Eigen::MatrixBase<VectorXs> &, bool))
180  & jacobianCenterOfMass<Scalar, Options, JointCollectionDefaultTpl, VectorXs>,
181  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("compute_subtree_coms") = true),
182  "Computes the Jacobian of the center of mass, puts the result in context::Data and return "
183  "it.\n"
184  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
185  "subtrees.",
186  bp::return_value_policy<bp::return_by_value>());
187 
188  bp::def(
189  "jacobianCenterOfMass",
190  (const context::Data::Matrix3x & (*)(const context::Model &, context::Data &, bool))
191  & jacobianCenterOfMass<Scalar, Options, JointCollectionDefaultTpl>,
192  (bp::arg("model"), bp::arg("data"), bp::arg("compute_subtree_coms") = true),
193  "Computes the Jacobian of the center of mass, puts the result in context::Data and "
194  "return it.\n"
195  "If compute_subtree_coms is True, the algorithm also computes the center of mass of "
196  "the subtrees.",
197  bp::return_value_policy<bp::return_by_value>());
198 
199  bp::def(
200  "jacobianSubtreeCenterOfMass", jacobian_subtree_com_kinematics_proxy,
201  bp::args("model", "data", "q", "subtree_root_joint_id"),
202  "Computes the Jacobian of the CoM of the given subtree (subtree_root_joint_id) "
203  "expressed in the WORLD frame, according to the given joint configuration.",
205 
206  bp::def(
207  "jacobianSubtreeCenterOfMass", jacobian_subtree_com_proxy,
208  bp::args("model", "data", "subtree_root_joint_id"),
209  "Computes the Jacobian of the CoM of the given subtree (subtree_root_joint_id) "
210  "expressed in the WORLD frame, according to the given entries in data.",
212 
213  bp::def(
214  "getJacobianSubtreeCenterOfMass", get_jacobian_subtree_com_proxy,
215  bp::args("model", "data", "subtree_root_joint_id"),
216  "Get the Jacobian of the CoM of the given subtree expressed in the world frame, "
217  "according to the given entries in data. It assumes that jacobianCenterOfMass has "
218  "been called first.",
220  }
221 
222  } // namespace python
223 } // namespace pinocchio
pinocchio::SE3Tpl::Vector3
traits< SE3Tpl >::Vector3 Vector3
Definition: spatial/se3-tpl.hpp:55
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::python::com_0_proxy
static context::SE3::Vector3 com_0_proxy(const context::Model &model, context::Data &data, const context::VectorXs &q, bool computeSubtreeComs=true)
Definition: expose-com.cpp:17
pinocchio::KinematicLevel
KinematicLevel
List of Kinematics Level supported by Pinocchio.
Definition: multibody/fwd.hpp:59
pinocchio::python::Options
@ Options
Definition: expose-contact-inverse-dynamics.cpp:24
setup.data
data
Definition: cmake/cython/setup.in.py:48
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
inverse-kinematics-3d.J
J
Definition: inverse-kinematics-3d.py:28
pinocchio::python::com_1_proxy
static context::SE3::Vector3 com_1_proxy(const context::Model &model, context::Data &data, const context::VectorXs &q, const context::VectorXs &v, bool computeSubtreeComs=true)
Definition: expose-com.cpp:26
pinocchio::python::com_default_proxy
static const context::Data::Vector3 & com_default_proxy(const context::Model &model, context::Data &data, bool computeSubtreeComs=true)
Definition: expose-com.cpp:56
pinocchio::python::VectorXs
context::VectorXs VectorXs
Definition: admm-solver.cpp:30
pinocchio::python::jacobian_subtree_com_proxy
static context::Data::Matrix3x jacobian_subtree_com_proxy(const context::Model &model, context::Data &data, context::Model::JointIndex jointId)
Definition: expose-com.cpp:75
pinocchio::ModelTpl::JointIndex
pinocchio::JointIndex JointIndex
Definition: multibody/model.hpp:67
pinocchio::python::context::Options
@ Options
Definition: bindings/python/context/generic.hpp:40
center-of-mass.hpp
pinocchio::DataTpl::Matrix3x
Eigen::Matrix< Scalar, 3, Eigen::Dynamic, Options > Matrix3x
The 3d jacobian type (temporary)
Definition: multibody/data.hpp:94
algorithms.hpp
pinocchio::python::get_jacobian_subtree_com_proxy
static context::Data::Matrix3x get_jacobian_subtree_com_proxy(const context::Model &model, context::Data &data, context::Model::JointIndex jointId)
Definition: expose-com.cpp:85
pinocchio::DataTpl::Vector3
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
Definition: multibody/data.hpp:77
python
pinocchio::python::v
const Vector3Like & v
Definition: bindings/python/spatial/explog.hpp:66
pinocchio::getJacobianSubtreeCenterOfMass
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...
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
a
Vec3f a
pinocchio::python::mimic_not_supported_function
Definition: model-checker.hpp:22
pinocchio::python::com_level_proxy
static const context::Data::Vector3 & com_level_proxy(const context::Model &model, context::Data &data, KinematicLevel kinematic_level, bool computeSubtreeComs=true)
Definition: expose-com.cpp:47
pinocchio::python::jacobian_subtree_com_kinematics_proxy
static context::Data::Matrix3x jacobian_subtree_com_kinematics_proxy(const context::Model &model, context::Data &data, const context::VectorXs &q, context::Model::JointIndex jointId)
Definition: expose-com.cpp:62
pinocchio::python::exposeCOM
void exposeCOM()
Definition: expose-com.cpp:95
pinocchio::python::com_2_proxy
static context::SE3::Vector3 com_2_proxy(const context::Model &model, context::Data &data, const context::VectorXs &q, const context::VectorXs &v, const context::VectorXs &a, bool computeSubtreeComs=true)
Definition: expose-com.cpp:36
pinocchio::jacobianSubtreeCenterOfMass
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...
model-checker.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::python::context::Scalar
PINOCCHIO_PYTHON_SCALAR_TYPE Scalar
Definition: bindings/python/context/generic.hpp:37
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:33
pinocchio::centerOfMass
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....


pinocchio
Author(s):
autogenerated on Thu Apr 10 2025 02:42:18