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(*)(
105  const context::Model &))&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(*)(
111  const context::Model &,
112  context::Data &))&computeTotalMass<Scalar, Options, JointCollectionDefaultTpl>,
113  bp::args("model", "data"),
114  "Compute the total mass of the model, put it in data.mass[0] and return it.");
115 
116  bp::def(
117  "computeSubtreeMasses",
118  (void (*)(
119  const context::Model &,
120  context::Data &))&computeSubtreeMasses<Scalar, Options, JointCollectionDefaultTpl>,
121  bp::args("model", "data"),
122  "Compute the mass of each kinematic subtree and store it in the vector data.mass.");
123 
124  bp::def(
125  "centerOfMass", com_0_proxy,
126  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("compute_subtree_coms") = true),
127  "Compute the center of mass, putting the result in context::Data and return it."
128  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
129  "subtrees.",
130  bp::return_value_policy<bp::return_by_value>());
131 
132  bp::def(
133  "centerOfMass", com_1_proxy,
134  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("v"),
135  bp::arg("compute_subtree_coms") = true),
136  "Computes the center of mass position and velocity by storing the result in context::Data. "
137  "It returns the center of mass position expressed in the WORLD frame.\n"
138  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
139  "subtrees.",
140  bp::return_value_policy<bp::return_by_value>());
141 
142  bp::def(
143  "centerOfMass", com_2_proxy,
144  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("v"), bp::arg("a"),
145  bp::arg("compute_subtree_coms") = true),
146  "Computes the center of mass position, velocity and acceleration by storing the result in "
147  "context::Data. It returns the center of mass position expressed in the WORLD frame.\n"
148  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
149  "subtrees.",
150  bp::return_value_policy<bp::return_by_value>());
151 
152  bp::def(
153  "centerOfMass", com_level_proxy,
154  (bp::arg("model"), bp::arg("data"), bp::arg("kinematic_level"),
155  bp::arg("compute_subtree_coms") = true),
156  "Computes the center of mass position, velocity or acceleration of a given model according "
157  "to the current kinematic values contained in data and the requested kinematic_level.\n"
158  "If kinematic_level = POSITION, computes the CoM position, if kinematic_level = VELOCITY, "
159  "also computes the CoM velocity and if kinematic_level = ACCELERATION, it also computes "
160  "the CoM acceleration.\n"
161  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
162  "subtrees.",
163  bp::return_value_policy<bp::return_by_value>());
164 
165  bp::def(
166  "centerOfMass", com_default_proxy,
167  (bp::arg("model"), bp::arg("data"), bp::arg("compute_subtree_coms") = true),
168  "Computes the center of mass position, velocity and acceleration of a given model "
169  "according to the current kinematic values contained in data.\n"
170  "If compute_subtree_coms is True, the algorithm also computes the center of mass of "
171  "the subtrees.",
172  bp::return_value_policy<bp::return_by_value>());
173 
174  bp::def(
175  "jacobianCenterOfMass",
176  (const context::Data::Matrix3x & (*)(const context::Model &, context::Data &,
177  const Eigen::MatrixBase<VectorXs> &, bool))
178  & jacobianCenterOfMass<Scalar, Options, JointCollectionDefaultTpl, VectorXs>,
179  (bp::arg("model"), bp::arg("data"), bp::arg("q"), bp::arg("compute_subtree_coms") = true),
180  "Computes the Jacobian of the center of mass, puts the result in context::Data and return "
181  "it.\n"
182  "If compute_subtree_coms is True, the algorithm also computes the center of mass of the "
183  "subtrees.",
184  bp::return_value_policy<bp::return_by_value>());
185 
186  bp::def(
187  "jacobianCenterOfMass",
188  (const context::Data::Matrix3x & (*)(const context::Model &, context::Data &, bool))
189  & jacobianCenterOfMass<Scalar, Options, JointCollectionDefaultTpl>,
190  (bp::arg("model"), bp::arg("data"), bp::arg("compute_subtree_coms") = true),
191  "Computes the Jacobian of the center of mass, puts the result in context::Data and "
192  "return it.\n"
193  "If compute_subtree_coms is True, the algorithm also computes the center of mass of "
194  "the subtrees.",
195  bp::return_value_policy<bp::return_by_value>());
196 
197  bp::def(
198  "jacobianSubtreeCenterOfMass", jacobian_subtree_com_kinematics_proxy,
199  bp::args("model", "data", "q", "subtree_root_joint_id"),
200  "Computes the Jacobian of the CoM of the given subtree (subtree_root_joint_id) "
201  "expressed in the WORLD frame, according to the given joint configuration.");
202 
203  bp::def(
204  "jacobianSubtreeCenterOfMass", jacobian_subtree_com_proxy,
205  bp::args("model", "data", "subtree_root_joint_id"),
206  "Computes the Jacobian of the CoM of the given subtree (subtree_root_joint_id) "
207  "expressed in the WORLD frame, according to the given entries in data.");
208 
209  bp::def(
210  "getJacobianSubtreeCenterOfMass", get_jacobian_subtree_com_proxy,
211  bp::args("model", "data", "subtree_root_joint_id"),
212  "Get the Jacobian of the CoM of the given subtree expressed in the world frame, "
213  "according to the given entries in data. It assumes that jacobianCenterOfMass has "
214  "been called first.");
215  }
216 
217  } // namespace python
218 } // 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
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
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: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:67
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: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:83
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
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:1082
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 Thu Dec 19 2024 03:41:29