Directory: | ./ |
---|---|
File: | include/pinocchio/bindings/python/multibody/model.hpp |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 90 | 96 | 93.8% |
Branches: | 124 | 248 | 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 | 20 | void visit(PyClass & cl) const | |
67 | { | ||
68 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
20 | cl.def(bp::init<>(bp::arg("self"), "Default constructor. Constructs an empty model.")) |
69 |
5/10✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 20 times.
✗ Branch 14 not taken.
|
40 | .def(bp::init<const Model &>((bp::arg("self"), bp::arg("clone")), "Copy constructor")) |
70 | |||
71 | // Class Members | ||
72 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("nq", &Model::nq, "Dimension of the configuration vector representation.") |
73 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("nv", &Model::nv, "Dimension of the velocity vector space.") |
74 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("njoints", &Model::njoints, "Number of joints.") |
75 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("nbodies", &Model::nbodies, "Number of bodies.") |
76 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("nframes", &Model::nframes, "Number of frames.") |
77 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .add_property( |
78 | "inertias", &Model::inertias, "Vector of spatial inertias supported by each joint.") | ||
79 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("joints", &Model::joints, "Vector of joint models.") |
83 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .add_property( |
87 | "nqs", &Model::nqs, "Vector of dimension of the joint configuration subspace.") | ||
88 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("nvs", &Model::nvs, "Dimension of the *i*th joint tangent subspace.") |
92 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .add_property("names", &Model::names, "Name of the joints.") |
101 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("name", &Model::name, "Name of the model.") |
102 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite( |
103 | "referenceConfigurations", &Model::referenceConfigurations, | ||
104 | "Map of reference configurations, indexed by user given names.") | ||
105 | |||
106 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("armature", &Model::armature, "Armature vector.") |
107 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite( |
108 | "rotorInertia", &Model::rotorInertia, "Vector of rotor inertia parameters.") | ||
109 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite( |
110 | "rotorGearRatio", &Model::rotorGearRatio, "Vector of rotor gear ratio parameters.") | ||
111 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("friction", &Model::friction, "Vector of joint friction parameters.") |
112 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("damping", &Model::damping, "Vector of joint damping parameters.") |
113 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("effortLimit", &Model::effortLimit, "Joint max effort.") |
114 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("velocityLimit", &Model::velocityLimit, "Joint max velocity.") |
115 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite( |
116 | "lowerPositionLimit", &Model::lowerPositionLimit, "Limit for joint lower position.") | ||
117 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite( |
118 | "upperPositionLimit", &Model::upperPositionLimit, "Limit for joint upper position.") | ||
119 | |||
120 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_readwrite("frames", &Model::frames, "Vector of frames contained in the model.") |
121 | |||
122 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
|
20 | .def( |
162 | "addJointFrame", &Model::addJointFrame, | ||
163 |
5/10✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 20 times.
✗ Branch 14 not taken.
|
60 | (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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .def( |
190 | "getFrameId", &Model::getFrameId, | ||
191 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | (bp::arg("self"), bp::arg("name"), |
192 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
40 | 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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .def( |
198 | "existFrame", &Model::existFrame, | ||
199 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | (bp::arg("self"), bp::arg("name"), |
200 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
40 | 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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .def( |
205 | "addFrame", &Model::addFrame, | ||
206 |
5/10✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 20 times.
✗ Branch 14 not taken.
|
60 | (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 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .def( |
212 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | "createData", &ModelPythonVisitor::createData, bp::arg("self"), |
213 | "Create a Data object for the given model.") | ||
214 | |||
215 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
|
40 | .def( |
220 | "hasConfigurationLimit", &Model::hasConfigurationLimit, bp::args("self"), | ||
221 | "Returns list of boolean if joints have configuration limit.") | ||
222 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .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 20 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
20 | .def(bp::self == bp::self) |
230 |
1/2✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | .def(bp::self != bp::self) |
231 | #endif | ||
232 | |||
233 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
20 | .PINOCCHIO_ADD_STATIC_PROPERTY_READONLY_BYVALUE( |
234 | Model, gravity981, "Default gravity field value on the Earth."); | ||
235 | 20 | } | |
236 | |||
237 | 2 | static JointIndex addJoint0( | |
238 | Model & model, | ||
239 | JointIndex parent_id, | ||
240 | const JointModel & jmodel, | ||
241 | const SE3 & joint_placement, | ||
242 | const std::string & joint_name) | ||
243 | { | ||
244 | 2 | return model.addJoint(parent_id, jmodel, joint_placement, joint_name); | |
245 | } | ||
246 | |||
247 | ✗ | static JointIndex addJoint1( | |
248 | Model & model, | ||
249 | JointIndex parent_id, | ||
250 | const JointModel & jmodel, | ||
251 | const SE3 & joint_placement, | ||
252 | const std::string & joint_name, | ||
253 | const VectorXs & max_effort, | ||
254 | const VectorXs & max_velocity, | ||
255 | const VectorXs & min_config, | ||
256 | const VectorXs & max_config) | ||
257 | { | ||
258 | ✗ | return model.addJoint( | |
259 | parent_id, jmodel, joint_placement, joint_name, max_effort, max_velocity, min_config, | ||
260 | ✗ | max_config); | |
261 | } | ||
262 | |||
263 | ✗ | static JointIndex addJoint2( | |
264 | Model & model, | ||
265 | JointIndex parent_id, | ||
266 | const JointModel & jmodel, | ||
267 | const SE3 & joint_placement, | ||
268 | const std::string & joint_name, | ||
269 | const VectorXs & max_effort, | ||
270 | const VectorXs & max_velocity, | ||
271 | const VectorXs & min_config, | ||
272 | const VectorXs & max_config, | ||
273 | const VectorXs & friction, | ||
274 | const VectorXs & damping) | ||
275 | { | ||
276 | ✗ | return model.addJoint( | |
277 | parent_id, jmodel, joint_placement, joint_name, max_effort, max_velocity, min_config, | ||
278 | ✗ | max_config, friction, damping); | |
279 | } | ||
280 | |||
281 | 16 | static Data createData(const Model & model) | |
282 | { | ||
283 | 16 | return Data(model); | |
284 | } | ||
285 | |||
286 | /// | ||
287 | /// \brief Provide equivalent to python list index function for | ||
288 | /// vectors. | ||
289 | /// | ||
290 | /// \param[in] x The input vector. | ||
291 | /// \param[in] v The value of to look for in the vector. | ||
292 | /// | ||
293 | /// \return The index of the matching element of the vector. If | ||
294 | /// no element is found, return the size of the vector. | ||
295 | /// | ||
296 | template<typename T> | ||
297 | static Index index(std::vector<T> const & x, typename std::vector<T>::value_type const & v) | ||
298 | { | ||
299 | Index i = 0; | ||
300 | for (typename std::vector<T>::const_iterator it = x.begin(); it != x.end(); ++it, ++i) | ||
301 | { | ||
302 | if (*it == v) | ||
303 | { | ||
304 | return i; | ||
305 | } | ||
306 | } | ||
307 | return x.size(); | ||
308 | } | ||
309 | |||
310 | /* --- Expose --------------------------------------------------------- */ | ||
311 | 20 | static void expose() | |
312 | { | ||
313 | typedef typename Model::ConfigVectorMap ConfigVectorMap; | ||
314 | typedef bp::map_indexing_suite<ConfigVectorMap, false> map_indexing_suite; | ||
315 |
3/6✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<Index>, true>::expose("StdVec_Index"); |
316 | 20 | serialize<std::vector<Index>>(); | |
317 |
3/6✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<IndexVector>>::expose("StdVec_IndexVector"); |
318 | 20 | serialize<std::vector<IndexVector>>(); | |
319 |
3/6✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<std::string>, true>::expose("StdVec_StdString"); |
320 |
3/6✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<bool>, true>::expose("StdVec_Bool"); |
321 |
3/6✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<Scalar>, true>::expose("StdVec_Scalar"); |
322 | |||
323 | #if defined(PINOCCHIO_PYTHON_INTERFACE_MAIN_MODULE) | ||
324 |
4/8✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 20 times.
✗ Branch 12 not taken.
|
20 | bp::scope().attr("StdVec_Double") = bp::scope().attr("StdVec_Scalar"); // alias |
325 | #endif | ||
326 | |||
327 | 20 | serialize<std::vector<std::string>>(); | |
328 | 20 | serialize<std::vector<bool>>(); | |
329 | #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION | ||
330 | 20 | serialize<std::vector<Scalar>>(); | |
331 | #endif | ||
332 | 20 | bp::class_<typename Model::ConfigVectorMap>("StdMap_String_VectorXd") | |
333 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(map_indexing_suite()) |
334 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_pickle(PickleMap<typename Model::ConfigVectorMap>()) |
335 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(details::overload_base_get_item_for_std_map<typename Model::ConfigVectorMap>()); |
336 | |||
337 | 20 | bp::class_<Model>("Model", "Articulated Rigid Body model", bp::no_init) | |
338 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(ModelPythonVisitor()) |
339 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(CastVisitor<Model>()) |
340 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(ExposeConstructorByCastVisitor<Model, ::pinocchio::Model>()) |
341 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(SerializableVisitor<Model>()) |
342 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(PrintableVisitor<Model>()) |
343 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def(CopyableVisitor<Model>()) |
344 | #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION | ||
345 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | .def_pickle(PickleFromStringSerialization<Model>()) |
346 | #endif | ||
347 | ; | ||
348 | 20 | } | |
349 | }; | ||
350 | |||
351 | } // namespace python | ||
352 | } // namespace pinocchio | ||
353 | |||
354 | #endif // ifndef __pinocchio_python_multibody_model_hpp__ | ||
355 |