GCC Code Coverage Report


Directory: ./
File: bindings/python/parsers/urdf/model.cpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 54 78 69.2%
Branches: 98 204 48.0%

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