Directory: | ./ |
---|---|
File: | bindings/python/parsers/urdf/model.cpp |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 48 | 71 | 67.6% |
Branches: | 26 | 60 | 43.3% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2015-2020 CNRS INRIA | ||
3 | // | ||
4 | |||
5 | #ifdef PINOCCHIO_WITH_URDFDOM | ||
6 | #include "pinocchio/parsers/urdf.hpp" | ||
7 | #endif | ||
8 | |||
9 | #include "pinocchio/bindings/python/parsers/urdf.hpp" | ||
10 | #include "pinocchio/bindings/python/utils/path.hpp" | ||
11 | |||
12 | #include <boost/python.hpp> | ||
13 | |||
14 | namespace pinocchio | ||
15 | { | ||
16 | namespace python | ||
17 | { | ||
18 | |||
19 | namespace bp = boost::python; | ||
20 | |||
21 | #ifdef PINOCCHIO_WITH_URDFDOM | ||
22 | |||
23 | 8 | Model buildModelFromUrdf(const bp::object & filename) | |
24 | { | ||
25 | 8 | Model model; | |
26 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | pinocchio::urdf::buildModel(path(filename), model); |
27 | 8 | return model; | |
28 | } | ||
29 | |||
30 | ✗ | Model & buildModelFromUrdf(const bp::object & filename, Model & model) | |
31 | { | ||
32 | ✗ | return pinocchio::urdf::buildModel(path(filename), model); | |
33 | } | ||
34 | |||
35 | 24 | Model buildModelFromUrdf(const bp::object & filename, const JointModel & root_joint) | |
36 | { | ||
37 | 24 | Model model; | |
38 |
2/4✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
|
24 | pinocchio::urdf::buildModel(path(filename), root_joint, model); |
39 | 24 | return model; | |
40 | } | ||
41 | |||
42 | 1 | Model buildModelFromUrdf( | |
43 | const bp::object & filename, | ||
44 | const JointModel & root_joint, | ||
45 | const std::string & root_joint_name) | ||
46 | { | ||
47 | 1 | Model model; | |
48 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | pinocchio::urdf::buildModel(path(filename), root_joint, root_joint_name, model); |
49 | 1 | return model; | |
50 | } | ||
51 | |||
52 | Model & | ||
53 | 1 | buildModelFromUrdf(const bp::object & filename, const JointModel & root_joint, Model & model) | |
54 | { | ||
55 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | return pinocchio::urdf::buildModel(path(filename), root_joint, model); |
56 | } | ||
57 | |||
58 | ✗ | Model & buildModelFromUrdf( | |
59 | const bp::object & filename, | ||
60 | const JointModel & root_joint, | ||
61 | const std::string & root_joint_name, | ||
62 | Model & model) | ||
63 | { | ||
64 | ✗ | return pinocchio::urdf::buildModel(path(filename), root_joint, root_joint_name, model); | |
65 | } | ||
66 | |||
67 | 1 | Model buildModelFromXML(const std::string & xml_stream, const JointModel & root_joint) | |
68 | { | ||
69 | 1 | Model model; | |
70 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, model); |
71 | 1 | return model; | |
72 | } | ||
73 | |||
74 | ✗ | Model buildModelFromXML( | |
75 | const std::string & xml_stream, | ||
76 | const JointModel & root_joint, | ||
77 | const std::string & root_joint_name) | ||
78 | { | ||
79 | ✗ | Model model; | |
80 | ✗ | pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, root_joint_name, model); | |
81 | ✗ | return model; | |
82 | } | ||
83 | |||
84 | Model & | ||
85 | 1 | buildModelFromXML(const std::string & xml_stream, const JointModel & root_joint, Model & model) | |
86 | { | ||
87 | 1 | pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, model); | |
88 | 1 | return model; | |
89 | } | ||
90 | |||
91 | ✗ | Model & buildModelFromXML( | |
92 | const std::string & xml_stream, | ||
93 | const JointModel & root_joint, | ||
94 | const std::string & root_joint_name, | ||
95 | Model & model) | ||
96 | { | ||
97 | ✗ | pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, root_joint_name, model); | |
98 | ✗ | return model; | |
99 | } | ||
100 | |||
101 | ✗ | Model buildModelFromXML(const std::string & xml_stream) | |
102 | { | ||
103 | ✗ | Model model; | |
104 | ✗ | pinocchio::urdf::buildModelFromXML(xml_stream, model); | |
105 | ✗ | return model; | |
106 | } | ||
107 | |||
108 | ✗ | Model & buildModelFromXML(const std::string & xml_stream, Model & model) | |
109 | { | ||
110 | ✗ | pinocchio::urdf::buildModelFromXML(xml_stream, model); | |
111 | ✗ | return model; | |
112 | } | ||
113 | |||
114 | #endif | ||
115 | |||
116 | 65 | void exposeURDFModel() | |
117 | { | ||
118 | |||
119 | #ifdef PINOCCHIO_WITH_URDFDOM | ||
120 | |||
121 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
122 | "buildModelFromUrdf", | ||
123 | static_cast<Model (*)(const bp::object &, const JointModel &)>( | ||
124 | pinocchio::python::buildModelFromUrdf), | ||
125 | 130 | bp::args("urdf_filename", "root_joint"), | |
126 | "Parse the URDF file given in input and return a pinocchio Model starting with the " | ||
127 | "given root joint."); | ||
128 | |||
129 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
130 | "buildModelFromUrdf", | ||
131 | static_cast<Model (*)(const bp::object &, const JointModel &, const std::string &)>( | ||
132 | pinocchio::python::buildModelFromUrdf), | ||
133 | 130 | bp::args("urdf_filename", "root_joint", "root_joint_name"), | |
134 | "Parse the URDF file given in input and return a pinocchio Model starting with the " | ||
135 | "given root joint with its specified name."); | ||
136 | |||
137 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
138 | "buildModelFromUrdf", | ||
139 | static_cast<Model (*)(const bp::object &)>(pinocchio::python::buildModelFromUrdf), | ||
140 | 130 | bp::args("urdf_filename"), | |
141 | "Parse the URDF file given in input and return a pinocchio Model."); | ||
142 | |||
143 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
144 | "buildModelFromUrdf", | ||
145 | static_cast<Model & (*)(const bp::object &, Model &)>( | ||
146 | pinocchio::python::buildModelFromUrdf), | ||
147 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("urdf_filename", "model"), |
148 | "Append to a given model a URDF structure given by its filename.", | ||
149 | ✗ | bp::return_internal_reference<2>()); | |
150 | |||
151 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
152 | "buildModelFromUrdf", | ||
153 | static_cast<Model & (*)(const bp::object &, const JointModel &, Model &)>( | ||
154 | pinocchio::python::buildModelFromUrdf), | ||
155 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("urdf_filename", "root_joint", "model"), |
156 | "Append to a given model a URDF structure given by its filename and the root joint.\n" | ||
157 | "Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons," | ||
158 | "it is treated as operational frame and not as a joint of the model.", | ||
159 | ✗ | bp::return_internal_reference<3>()); | |
160 | |||
161 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
162 | "buildModelFromUrdf", | ||
163 | static_cast<Model & (*)(const bp::object &, const JointModel &, const std::string &, | ||
164 | Model &)>(pinocchio::python::buildModelFromUrdf), | ||
165 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("urdf_filename", "root_joint", "root_joint_name", "model"), |
166 | "Append to a given model a URDF structure given by its filename and the root joint with " | ||
167 | "its specified name.\n" | ||
168 | "Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons," | ||
169 | "it is treated as operational frame and not as a joint of the model.", | ||
170 | ✗ | bp::return_internal_reference<3>()); | |
171 | |||
172 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
173 | "buildModelFromXML", | ||
174 | static_cast<Model (*)(const std::string &, const JointModel &)>( | ||
175 | pinocchio::python::buildModelFromXML), | ||
176 | 130 | bp::args("urdf_xml_stream", "root_joint"), | |
177 | "Parse the URDF XML stream given in input and return a pinocchio Model starting with " | ||
178 | "the given root joint."); | ||
179 | |||
180 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
181 | "buildModelFromXML", | ||
182 | static_cast<Model (*)(const std::string &, const JointModel &, const std::string &)>( | ||
183 | pinocchio::python::buildModelFromXML), | ||
184 | 130 | bp::args("urdf_xml_stream", "root_joint", "root_joint_name"), | |
185 | "Parse the URDF XML stream given in input and return a pinocchio Model starting with " | ||
186 | "the given root joint with its specified name."); | ||
187 | |||
188 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
189 | "buildModelFromXML", | ||
190 | static_cast<Model & (*)(const std::string &, const JointModel &, Model &)>( | ||
191 | pinocchio::python::buildModelFromXML), | ||
192 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("urdf_xml_stream", "root_joint", "model"), |
193 | "Parse the URDF XML stream given in input and append it to the input model with the " | ||
194 | "given interfacing joint.", | ||
195 | ✗ | bp::return_internal_reference<3>()); | |
196 | |||
197 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
198 | "buildModelFromXML", | ||
199 | static_cast<Model & (*)(const std::string &, const JointModel &, const std::string &, | ||
200 | Model &)>(pinocchio::python::buildModelFromXML), | ||
201 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("urdf_xml_stream", "root_joint", "root_joint_name", "model"), |
202 | "Parse the URDF XML stream given in input and append it to the input model with the " | ||
203 | "given interfacing joint with its specified name.", | ||
204 | ✗ | bp::return_internal_reference<3>()); | |
205 | |||
206 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
207 | "buildModelFromXML", | ||
208 | static_cast<Model (*)(const std::string &)>(pinocchio::python::buildModelFromXML), | ||
209 | 130 | bp::args("urdf_xml_stream"), | |
210 | "Parse the URDF XML stream given in input and return a pinocchio Model."); | ||
211 | |||
212 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
213 | "buildModelFromXML", | ||
214 | static_cast<Model & (*)(const std::string &, Model &)>( | ||
215 | pinocchio::python::buildModelFromXML), | ||
216 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("urdf_xml_stream", "model"), |
217 | "Parse the URDF XML stream given in input and append it to the input model.", | ||
218 | 65 | bp::return_internal_reference<2>()); | |
219 | #endif | ||
220 | 65 | } | |
221 | } // namespace python | ||
222 | } // namespace pinocchio | ||
223 |