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