Directory: | ./ |
---|---|
File: | include/pinocchio/bindings/python/multibody/model.hpp |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 94 | 97 | 96.9% |
Branches: | 125 | 250 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2015-2023 CNRS INRIA | ||
3 | // Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France. | ||
4 | // | ||
5 | |||
6 | #ifndef __pinocchio_python_multibody_model_hpp__ | ||
7 | #define __pinocchio_python_multibody_model_hpp__ | ||
8 | |||
9 | #include <eigenpy/eigen-to-python.hpp> | ||
10 | |||
11 | #include "pinocchio/multibody/model.hpp" | ||
12 | #include "pinocchio/serialization/model.hpp" | ||
13 | |||
14 | #include <boost/python/overloads.hpp> | ||
15 | #include <eigenpy/memory.hpp> | ||
16 | #include <eigenpy/exception.hpp> | ||
17 | |||
18 | #include "pinocchio/algorithm/check.hpp" | ||
19 | |||
20 | #include "pinocchio/bindings/python/utils/cast.hpp" | ||
21 | #include "pinocchio/bindings/python/utils/macros.hpp" | ||
22 | #include "pinocchio/bindings/python/utils/printable.hpp" | ||
23 | #include "pinocchio/bindings/python/utils/copyable.hpp" | ||
24 | #include "pinocchio/bindings/python/utils/std-map.hpp" | ||
25 | #include "pinocchio/bindings/python/utils/pickle.hpp" | ||
26 | #include "pinocchio/bindings/python/utils/pickle-map.hpp" | ||
27 | #include "pinocchio/bindings/python/utils/std-vector.hpp" | ||
28 | #include "pinocchio/bindings/python/serialization/serializable.hpp" | ||
29 | |||
30 | #if EIGENPY_VERSION_AT_MOST(2, 8, 1) | ||
31 | EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(pinocchio::Model) | ||
32 | #endif | ||
33 | |||
34 | namespace pinocchio | ||
35 | { | ||
36 | namespace python | ||
37 | { | ||
38 | namespace bp = boost::python; | ||
39 | |||
40 | template<typename Model> | ||
41 | struct ModelPythonVisitor : public bp::def_visitor<ModelPythonVisitor<Model>> | ||
42 | { | ||
43 | public: | ||
44 | typedef typename Model::Scalar Scalar; | ||
45 | |||
46 | typedef typename Model::Index Index; | ||
47 | typedef typename Model::JointIndex JointIndex; | ||
48 | typedef typename Model::JointModel JointModel; | ||
49 | typedef typename JointModel::JointModelVariant JointModelVariant; | ||
50 | typedef typename Model::FrameIndex FrameIndex; | ||
51 | typedef typename Model::IndexVector IndexVector; | ||
52 | |||
53 | typedef typename Model::SE3 SE3; | ||
54 | typedef typename Model::Motion Motion; | ||
55 | typedef typename Model::Force Force; | ||
56 | typedef typename Model::Frame Frame; | ||
57 | typedef typename Model::Inertia Inertia; | ||
58 | |||
59 | typedef typename Model::Data Data; | ||
60 | |||
61 | typedef typename Model::VectorXs VectorXs; | ||
62 | |||
63 | public: | ||
64 | /* --- Exposing C++ API to python through the handler ----------------- */ | ||
65 | template<class PyClass> | ||
66 | 69 | void visit(PyClass & cl) const | |
67 | { | ||
68 |
2/4✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 69 times.
✗ Branch 6 not taken.
|
69 | cl.def(bp::init<>(bp::arg("self"), "Default constructor. Constructs an empty model.")) |
69 |
5/10✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 69 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 69 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 69 times.
✗ Branch 14 not taken.
|
138 | .def(bp::init<const Model &>((bp::arg("self"), bp::arg("clone")), "Copy constructor")) |
70 | |||
71 | // Class Members | ||
72 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("nq", &Model::nq, "Dimension of the configuration vector representation.") |
73 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("nv", &Model::nv, "Dimension of the velocity vector space.") |
74 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("njoints", &Model::njoints, "Number of joints.") |
75 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("nbodies", &Model::nbodies, "Number of bodies.") |
76 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("nframes", &Model::nframes, "Number of frames.") |
77 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property( |
78 | "inertias", &Model::inertias, "Vector of spatial inertias supported by each joint.") | ||
79 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
80 | "jointPlacements", &Model::jointPlacements, | ||
81 | "Vector of joint placements: placement of a joint *i* wrt its parent joint frame.") | ||
82 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("joints", &Model::joints, "Vector of joint models.") |
83 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property( |
84 | "idx_qs", &Model::idx_qs, | ||
85 | "Vector of starting index of the *i*th joint in the configuration space.") | ||
86 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property( |
87 | "nqs", &Model::nqs, "Vector of dimension of the joint configuration subspace.") | ||
88 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property( |
89 | "idx_vs", &Model::idx_vs, | ||
90 | "Starting index of the *i*th joint in the tangent configuration space.") | ||
91 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("nvs", &Model::nvs, "Dimension of the *i*th joint tangent subspace.") |
92 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property( |
93 | "parents", &Model::parents, | ||
94 | "Vector of parent joint indexes. The parent of joint *i*, denoted *li*, " | ||
95 | "corresponds to li==parents[i].") | ||
96 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property( |
97 | "children", &Model::children, | ||
98 | "Vector of children index. Chidren of the *i*th joint, denoted *mu(i)* " | ||
99 | "corresponds to the set (i==parents[k] for k in mu(i)).") | ||
100 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .add_property("names", &Model::names, "Name of the joints.") |
101 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("name", &Model::name, "Name of the model.") |
102 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
103 | "referenceConfigurations", &Model::referenceConfigurations, | ||
104 | "Map of reference configurations, indexed by user given names.") | ||
105 | |||
106 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("armature", &Model::armature, "Armature vector.") |
107 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
108 | "rotorInertia", &Model::rotorInertia, "Vector of rotor inertia parameters.") | ||
109 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
110 | "rotorGearRatio", &Model::rotorGearRatio, "Vector of rotor gear ratio parameters.") | ||
111 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("friction", &Model::friction, "Vector of joint friction parameters.") |
112 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("damping", &Model::damping, "Vector of joint damping parameters.") |
113 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("effortLimit", &Model::effortLimit, "Joint max effort.") |
114 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("velocityLimit", &Model::velocityLimit, "Joint max velocity.") |
115 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
116 | "lowerPositionLimit", &Model::lowerPositionLimit, "Limit for joint lower position.") | ||
117 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
118 | "upperPositionLimit", &Model::upperPositionLimit, "Limit for joint upper position.") | ||
119 | |||
120 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite("frames", &Model::frames, "Vector of frames contained in the model.") |
121 | |||
122 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
123 | "supports", &Model::supports, | ||
124 | "Vector of supports. supports[j] corresponds to the list of joints on the " | ||
125 | "path between\n" | ||
126 | "the current *j* to the root of the kinematic tree.") | ||
127 | |||
128 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
129 | "subtrees", &Model::subtrees, | ||
130 | "Vector of subtrees. subtree[j] corresponds to the subtree supported by the joint j.") | ||
131 | |||
132 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_readwrite( |
133 | "gravity", &Model::gravity, | ||
134 | "Motion vector corresponding to the gravity field expressed in the world Frame.") | ||
135 | |||
136 | // Class Methods | ||
137 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
138 | "addJoint", &ModelPythonVisitor::addJoint0, | ||
139 | bp::args("self", "parent_id", "joint_model", "joint_placement", "joint_name"), | ||
140 | "Adds a joint to the kinematic tree. The joint is defined by its placement relative " | ||
141 | "to its parent joint and its name.") | ||
142 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
143 | "addJoint", &ModelPythonVisitor::addJoint1, | ||
144 | bp::args( | ||
145 | "self", "parent_id", "joint_model", "joint_placement", "joint_name", "max_effort", | ||
146 | "max_velocity", "min_config", "max_config"), | ||
147 | "Adds a joint to the kinematic tree with given bounds. The joint is defined by its " | ||
148 | "placement relative to its parent joint and its name." | ||
149 | "This signature also takes as input effort, velocity limits as well as the bounds " | ||
150 | "on the joint configuration.") | ||
151 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
152 | "addJoint", &ModelPythonVisitor::addJoint2, | ||
153 | bp::args( | ||
154 | "self", "parent_id", "joint_model", "joint_placement", "joint_name", "max_effort", | ||
155 | "max_velocity", "min_config", "max_config", "friction", "damping"), | ||
156 | "Adds a joint to the kinematic tree with given bounds. The joint is defined by its " | ||
157 | "placement relative to its parent joint and its name.\n" | ||
158 | "This signature also takes as input effort, velocity limits as well as the bounds " | ||
159 | "on the joint configuration.\n" | ||
160 | "The user should also provide the friction and damping related to the joint.") | ||
161 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def( |
162 | "addJointFrame", &Model::addJointFrame, | ||
163 |
5/10✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 69 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 69 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 69 times.
✗ Branch 14 not taken.
|
207 | (bp::arg("self"), bp::arg("joint_id"), bp::arg("frame_id") = 0), |
164 | "Add the joint provided by its joint_id as a frame to the frame tree.\n" | ||
165 | "The frame_id may be optionally provided.") | ||
166 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
167 | "appendBodyToJoint", &Model::appendBodyToJoint, | ||
168 | bp::args("self", "joint_id", "body_inertia", "body_placement"), | ||
169 | "Appends a body to the joint given by its index. The body is defined by its " | ||
170 | "inertia, its relative placement regarding to the joint and its name.") | ||
171 | |||
172 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
173 | "addBodyFrame", &Model::addBodyFrame, | ||
174 | bp::args("self", "body_name", "parentJoint", "body_placement", "previous_frame"), | ||
175 | "add a body to the frame tree") | ||
176 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
177 | "getBodyId", &Model::getBodyId, bp::args("self", "name"), | ||
178 | "Return the index of a frame of type BODY given by its name") | ||
179 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
180 | "existBodyName", &Model::existBodyName, bp::args("self", "name"), | ||
181 | "Check if a frame of type BODY exists, given its name") | ||
182 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
183 | "getJointId", &Model::getJointId, bp::args("self", "name"), | ||
184 | "Return the index of a joint given by its name") | ||
185 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
186 | "existJointName", &Model::existJointName, bp::args("self", "name"), | ||
187 | "Check if a joint given by its name exists") | ||
188 | |||
189 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
190 | "getFrameId", &Model::getFrameId, | ||
191 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | (bp::arg("self"), bp::arg("name"), |
192 |
3/6✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 69 times.
✗ Branch 8 not taken.
|
138 | bp::arg("type") = (FrameType)(JOINT | FIXED_JOINT | BODY | OP_FRAME | SENSOR)), |
193 | "Returns the index of the frame given by its name and its type." | ||
194 | "If the frame is not in the frames vector, it returns the current size of the " | ||
195 | "frames vector.") | ||
196 | |||
197 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
198 | "existFrame", &Model::existFrame, | ||
199 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | (bp::arg("self"), bp::arg("name"), |
200 |
3/6✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 69 times.
✗ Branch 8 not taken.
|
138 | bp::arg("type") = (FrameType)(JOINT | FIXED_JOINT | BODY | OP_FRAME | SENSOR)), |
201 | "Returns true if the frame given by its name exists inside the Model with the given " | ||
202 | "type.") | ||
203 | |||
204 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
205 | "addFrame", &Model::addFrame, | ||
206 |
5/10✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 69 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 69 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 69 times.
✗ Branch 14 not taken.
|
207 | (bp::arg("self"), bp::arg("frame"), bp::arg("append_inertia") = true), |
207 | "Add a frame to the vector of frames. If append_inertia set to True, " | ||
208 | "the inertia value contained in frame will be added to the inertia supported by the " | ||
209 | "parent joint.") | ||
210 | |||
211 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
212 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | "createData", &ModelPythonVisitor::createData, bp::arg("self"), |
213 | "Create a Data object for the given model.") | ||
214 | |||
215 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
216 | "check", (bool(Model::*)(const Data &) const) & Model::check, bp::args("self", "data"), | ||
217 | "Check consistency of data wrt model.") | ||
218 | |||
219 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | .def( |
220 | "hasConfigurationLimit", &Model::hasConfigurationLimit, bp::args("self"), | ||
221 | "Returns list of boolean if joints have configuration limit.") | ||
222 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | .def( |
223 | "hasConfigurationLimitInTangent", &Model::hasConfigurationLimitInTangent, | ||
224 | bp::args("self"), | ||
225 | "Returns list of boolean if joints have configuration limit in tangent space .") | ||
226 | |||
227 | #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS | ||
228 | |||
229 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 65 times.
✗ Branch 6 not taken.
|
65 | .def(bp::self == bp::self) |
230 |
1/2✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
|
65 | .def(bp::self != bp::self) |
231 | #endif | ||
232 | |||
233 |
3/6✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
69 | .PINOCCHIO_ADD_STATIC_PROPERTY_READONLY_BYVALUE( |
234 | Model, gravity981, "Default gravity field value on the Earth."); | ||
235 | |||
236 | 69 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); | |
237 | 69 | } | |
238 | |||
239 | 5 | static JointIndex addJoint0( | |
240 | Model & model, | ||
241 | JointIndex parent_id, | ||
242 | const JointModel & jmodel, | ||
243 | const SE3 & joint_placement, | ||
244 | const std::string & joint_name) | ||
245 | { | ||
246 | 5 | return model.addJoint(parent_id, jmodel, joint_placement, joint_name); | |
247 | } | ||
248 | |||
249 | 1 | static JointIndex addJoint1( | |
250 | Model & model, | ||
251 | JointIndex parent_id, | ||
252 | const JointModel & jmodel, | ||
253 | const SE3 & joint_placement, | ||
254 | const std::string & joint_name, | ||
255 | const VectorXs & max_effort, | ||
256 | const VectorXs & max_velocity, | ||
257 | const VectorXs & min_config, | ||
258 | const VectorXs & max_config) | ||
259 | { | ||
260 | 1 | return model.addJoint( | |
261 | parent_id, jmodel, joint_placement, joint_name, max_effort, max_velocity, min_config, | ||
262 | 1 | max_config); | |
263 | } | ||
264 | |||
265 | ✗ | static JointIndex addJoint2( | |
266 | Model & model, | ||
267 | JointIndex parent_id, | ||
268 | const JointModel & jmodel, | ||
269 | const SE3 & joint_placement, | ||
270 | const std::string & joint_name, | ||
271 | const VectorXs & max_effort, | ||
272 | const VectorXs & max_velocity, | ||
273 | const VectorXs & min_config, | ||
274 | const VectorXs & max_config, | ||
275 | const VectorXs & friction, | ||
276 | const VectorXs & damping) | ||
277 | { | ||
278 | ✗ | return model.addJoint( | |
279 | parent_id, jmodel, joint_placement, joint_name, max_effort, max_velocity, min_config, | ||
280 | ✗ | max_config, friction, damping); | |
281 | } | ||
282 | |||
283 | 158 | static Data createData(const Model & model) | |
284 | { | ||
285 | 158 | return Data(model); | |
286 | } | ||
287 | |||
288 | /// | ||
289 | /// \brief Provide equivalent to python list index function for | ||
290 | /// vectors. | ||
291 | /// | ||
292 | /// \param[in] x The input vector. | ||
293 | /// \param[in] v The value of to look for in the vector. | ||
294 | /// | ||
295 | /// \return The index of the matching element of the vector. If | ||
296 | /// no element is found, return the size of the vector. | ||
297 | /// | ||
298 | template<typename T> | ||
299 | static Index index(std::vector<T> const & x, typename std::vector<T>::value_type const & v) | ||
300 | { | ||
301 | Index i = 0; | ||
302 | for (typename std::vector<T>::const_iterator it = x.begin(); it != x.end(); ++it, ++i) | ||
303 | { | ||
304 | if (*it == v) | ||
305 | { | ||
306 | return i; | ||
307 | } | ||
308 | } | ||
309 | return x.size(); | ||
310 | } | ||
311 | |||
312 | /* --- Expose --------------------------------------------------------- */ | ||
313 | 69 | static void expose() | |
314 | { | ||
315 | typedef typename Model::ConfigVectorMap ConfigVectorMap; | ||
316 | typedef bp::map_indexing_suite<ConfigVectorMap, false> map_indexing_suite; | ||
317 |
3/6✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 69 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 69 times.
✗ Branch 10 not taken.
|
69 | StdVectorPythonVisitor<std::vector<Index>, true>::expose("StdVec_Index"); |
318 | 69 | serialize<std::vector<Index>>(); | |
319 |
3/6✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 69 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 69 times.
✗ Branch 10 not taken.
|
69 | StdVectorPythonVisitor<std::vector<IndexVector>>::expose("StdVec_IndexVector"); |
320 | 69 | serialize<std::vector<IndexVector>>(); | |
321 |
3/6✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 69 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 69 times.
✗ Branch 10 not taken.
|
69 | StdVectorPythonVisitor<std::vector<std::string>, true>::expose("StdVec_StdString"); |
322 |
3/6✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 69 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 69 times.
✗ Branch 10 not taken.
|
69 | StdVectorPythonVisitor<std::vector<bool>, true>::expose("StdVec_Bool"); |
323 |
3/6✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 69 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 69 times.
✗ Branch 10 not taken.
|
69 | StdVectorPythonVisitor<std::vector<Scalar>, true>::expose("StdVec_Scalar"); |
324 | |||
325 | #if defined(PINOCCHIO_PYTHON_INTERFACE_MAIN_MODULE) | ||
326 |
4/8✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 65 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 65 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 65 times.
✗ Branch 12 not taken.
|
65 | bp::scope().attr("StdVec_Double") = bp::scope().attr("StdVec_Scalar"); // alias |
327 | #endif | ||
328 | |||
329 | 69 | serialize<std::vector<std::string>>(); | |
330 | 69 | serialize<std::vector<bool>>(); | |
331 | #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION | ||
332 | 65 | serialize<std::vector<Scalar>>(); | |
333 | #endif | ||
334 | 69 | bp::class_<typename Model::ConfigVectorMap>("StdMap_String_VectorXd") | |
335 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(map_indexing_suite()) |
336 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def_pickle(PickleMap<typename Model::ConfigVectorMap>()) |
337 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(details::overload_base_get_item_for_std_map<typename Model::ConfigVectorMap>()); |
338 | |||
339 | 69 | bp::class_<Model>("Model", "Articulated Rigid Body model", bp::no_init) | |
340 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(ModelPythonVisitor()) |
341 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(CastVisitor<Model>()) |
342 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(ExposeConstructorByCastVisitor<Model, ::pinocchio::Model>()) |
343 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(SerializableVisitor<Model>()) |
344 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(PrintableVisitor<Model>()) |
345 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(CopyableVisitor<Model>()) |
346 | #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION | ||
347 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def_pickle(PickleFromStringSerialization<Model>()) |
348 | #endif | ||
349 | ; | ||
350 | 69 | } | |
351 | }; | ||
352 | |||
353 | } // namespace python | ||
354 | } // namespace pinocchio | ||
355 | |||
356 | #endif // ifndef __pinocchio_python_multibody_model_hpp__ | ||
357 |