algorithm/expose-model.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2024 INRIA
3 //
4 
8 
9 namespace pinocchio
10 {
11  namespace python
12  {
13 
14  namespace bp = boost::python;
15 
16  template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
17  bp::tuple appendModel_proxy(
20  const GeometryModel & geomModelA,
21  const GeometryModel & geomModelB,
22  const FrameIndex frameInModelA,
23  const SE3Tpl<Scalar, Options> & aMb)
24  {
26  Model model;
28 
29  appendModel(modelA, modelB, geomModelA, geomModelB, frameInModelA, aMb, model, geom_model);
30 
31  return bp::make_tuple(model, geom_model);
32  }
33 
34  template<
35  typename Scalar,
36  int Options,
37  template<typename, int> class JointCollectionTpl,
38  typename ConfigVectorType>
39  bp::tuple buildReducedModel(
41  const GeometryModel & geom_model,
42  const std::vector<JointIndex> & list_of_joints_to_lock,
43  const Eigen::MatrixBase<ConfigVectorType> & reference_configuration)
44  {
46  Model reduced_model;
47  GeometryModel reduced_geom_model;
48 
51  reduced_geom_model);
52 
53  return bp::make_tuple(reduced_model, reduced_geom_model);
54  }
55 
56  template<
57  typename Scalar,
58  int Options,
59  template<typename, int> class JointCollectionTpl,
60  typename ConfigVectorType>
61  bp::tuple buildReducedModel(
63  const std::vector<GeometryModel, Eigen::aligned_allocator<GeometryModel>> &
65  const std::vector<JointIndex> & list_of_joints_to_lock,
66  const Eigen::MatrixBase<ConfigVectorType> & reference_configuration)
67  {
69  std::vector<GeometryModel, Eigen::aligned_allocator<GeometryModel>> reduced_geom_models;
70  Model reduced_model;
73  reduced_geom_models);
74  return bp::make_tuple(reduced_model, reduced_geom_models);
75  }
76 
79  {
80  size_t index_ancestor_in_support1, index_ancestor_in_support2;
81  JointIndex ancestor_id = findCommonAncestor(
82  model, joint1_id, joint2_id, index_ancestor_in_support1, index_ancestor_in_support2);
83  return bp::make_tuple(ancestor_id, index_ancestor_in_support1, index_ancestor_in_support2);
84  }
85 
87  {
88  using namespace Eigen;
89 
90  typedef std::vector<GeometryModel, Eigen::aligned_allocator<GeometryModel>>
91  GeometryModelVector;
93 
94  bp::def(
95  "appendModel",
96  (Model(*)(
97  const Model &, const Model &, const FrameIndex,
98  const SE3 &))&appendModel<double, 0, JointCollectionDefaultTpl>,
99  bp::args("modelA", "modelB", "frame_in_modelA", "aMb"),
100  "Append a child model into a parent model, after a specific frame given by its index.\n\n"
101  "Parameters:\n"
102  "\tmodelA: the parent model\n"
103  "\tmodelB: the child model\n"
104  "\tframeInModelA: index of the frame of modelA where to append modelB\n"
105  "\taMb: pose of modelB universe joint (index 0) in frameInModelA\n");
106 
107  bp::def(
108  "appendModel", &appendModel_proxy<double, 0, JointCollectionDefaultTpl>,
109  bp::args("modelA", "modelB", "geomModelA", "geomModelB", "frame_in_modelA", "aMb"),
110  "Append a child (geometry) model into a parent (geometry) model, after a specific "
111  "frame given by its index.\n\n"
112  "Parameters:\n"
113  "\tmodelA: the parent model\n"
114  "\tmodelB: the child model\n"
115  "\tgeomModelA: the parent geometry model\n"
116  "\tgeomModelB: the child geometry model\n"
117  "\tframeInModelA: index of the frame of modelA where to append modelB\n"
118  "\taMb: pose of modelB universe joint (index 0) in frameInModelA\n");
119 
120  bp::def(
121  "buildReducedModel",
122  (Model(*)(
123  const Model &, const std::vector<JointIndex> &,
124  const Eigen::MatrixBase<VectorXd> &))&pinocchio::
125  buildReducedModel<double, 0, JointCollectionDefaultTpl, VectorXd>,
126  bp::args("model", "list_of_joints_to_lock", "reference_configuration"),
127  "Build a reduce model from a given input model and a list of joint to lock.\n\n"
128  "Parameters:\n"
129  "\tmodel: input kinematic modell to reduce\n"
130  "\tlist_of_joints_to_lock: list of joint indexes to lock\n"
131  "\treference_configuration: reference configuration to compute the placement of the "
132  "lock joints\n");
133 
134  bp::def(
135  "buildReducedModel",
136  (bp::tuple(*)(
137  const Model &, const GeometryModel &, const std::vector<JointIndex> &,
138  const Eigen::MatrixBase<
139  VectorXd> &))&buildReducedModel<double, 0, JointCollectionDefaultTpl, VectorXd>,
140  bp::args("model", "geom_model", "list_of_joints_to_lock", "reference_configuration"),
141  "Build a reduced model and a reduced geometry model from a given input model,"
142  "an input geometry model and a list of joints to lock.\n\n"
143  "Parameters:\n"
144  "\tmodel: input kinematic model to reduce\n"
145  "\tgeom_model: input geometry model to reduce\n"
146  "\tlist_of_joints_to_lock: list of joint indexes to lock\n"
147  "\treference_configuration: reference configuration to compute the placement of the "
148  "locked joints\n");
149 
150  bp::def(
151  "buildReducedModel",
152  (bp::tuple(*)(
153  const Model &,
154  const std::vector<GeometryModel, Eigen::aligned_allocator<GeometryModel>> &,
155  const std::vector<JointIndex> &, const Eigen::MatrixBase<VectorXd> &))
156  buildReducedModel<double, 0, JointCollectionDefaultTpl, VectorXd>,
157  bp::args(
158  "model", "list_of_geom_models", "list_of_joints_to_lock", "reference_configuration"),
159  "Build a reduced model and the related reduced geometry models from a given "
160  "input model,"
161  "a list of input geometry models and a list of joints to lock.\n\n"
162  "Parameters:\n"
163  "\tmodel: input kinematic model to reduce\n"
164  "\tlist_of_geom_models: input geometry models to reduce\n"
165  "\tlist_of_joints_to_lock: list of joint indexes to lock\n"
166  "\treference_configuration: reference configuration to compute the "
167  "placement of the locked joints\n");
168 
169  bp::def(
170  "findCommonAncestor", findCommonAncestor_proxy, bp::args("model", "joint1_id", "joint2_id"),
171  "Computes the common ancestor between two joints belonging to the same kinematic tree.\n\n"
172  "Parameters:\n"
173  "\tmodel: input model\n"
174  "\tjoint1_id: index of the first joint\n"
175  "\tjoint2_id: index of the second joint\n"
176  "Returns a tuple containing the index of the common joint ancestor, the position of this "
177  "ancestor in model.supports[joint1_id] and model.supports[joint2_id].\n");
178  }
179 
180  } // namespace python
181 } // namespace pinocchio
pinocchio::python::findCommonAncestor_proxy
bp::tuple findCommonAncestor_proxy(const context::Model &model, const JointIndex joint1_id, const JointIndex joint2_id)
Definition: algorithm/expose-model.cpp:77
pinocchio::FrameIndex
Index FrameIndex
Definition: multibody/fwd.hpp:28
boost::python
Eigen
model.hpp
pinocchio::python::exposeModelAlgo
void exposeModelAlgo()
Definition: algorithm/expose-model.cpp:86
pinocchio::SE3Tpl< Scalar, Options >
build-reduced-model.list_of_joints_to_lock
list_of_joints_to_lock
Definition: build-reduced-model.py:62
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::python::appendModel_proxy
bp::tuple appendModel_proxy(const ModelTpl< Scalar, Options, JointCollectionTpl > &modelA, const ModelTpl< Scalar, Options, JointCollectionTpl > &modelB, const GeometryModel &geomModelA, const GeometryModel &geomModelB, const FrameIndex frameInModelA, const SE3Tpl< Scalar, Options > &aMb)
Definition: algorithm/expose-model.cpp:17
pinocchio::appendModel
void appendModel(const ModelTpl< Scalar, Options, JointCollectionTpl > &modelA, const ModelTpl< Scalar, Options, JointCollectionTpl > &modelB, const FrameIndex frameInModelA, const SE3Tpl< Scalar, Options > &aMb, ModelTpl< Scalar, Options, JointCollectionTpl > &model)
Append a child model into a parent model, after a specific frame given by its index.
pinocchio::findCommonAncestor
JointIndex findCommonAncestor(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, JointIndex joint1_id, JointIndex joint2_id, size_t &index_ancestor_in_support1, size_t &index_ancestor_in_support2)
Computes the common ancestor between two joints belonging to the same kinematic tree.
pinocchio::python::Options
@ Options
Definition: expose-contact-inverse-dynamics.cpp:22
algorithms.hpp
python
append-urdf-model-with-another-model.geom_model
geom_model
Definition: append-urdf-model-with-another-model.py:25
eigenpy::StdVectorPythonVisitor::expose
static void expose(const std::string &class_name, const bp::def_visitor< DerivedVisitor > &visitor)
simulation-closed-kinematic-chains.joint1_id
joint1_id
Definition: simulation-closed-kinematic-chains.py:56
simulation-closed-kinematic-chains.joint2_id
joint2_id
Definition: simulation-closed-kinematic-chains.py:66
build-reduced-model.reference_configuration
reference_configuration
Definition: build-reduced-model.py:63
pinocchio::python::buildReducedModel
bp::tuple buildReducedModel(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const GeometryModel &geom_model, const std::vector< JointIndex > &list_of_joints_to_lock, const Eigen::MatrixBase< ConfigVectorType > &reference_configuration)
Definition: algorithm/expose-model.cpp:39
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
std-vector.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::Model
ModelTpl< context::Scalar, context::Options > Model
Definition: multibody/fwd.hpp:33
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
build-reduced-model.list_of_geom_models
list_of_geom_models
Definition: build-reduced-model.py:61


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:43