Directory: | ./ |
---|---|
File: | bindings/python/parsers/urdf/model.cpp |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 27 | 48 | 56.2% |
Branches: | 14 | 32 | 43.8% |
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 | |||
11 | #include <boost/python.hpp> | ||
12 | |||
13 | namespace pinocchio | ||
14 | { | ||
15 | namespace python | ||
16 | { | ||
17 | |||
18 | namespace bp = boost::python; | ||
19 | |||
20 | #ifdef PINOCCHIO_WITH_URDFDOM | ||
21 | |||
22 | 6 | Model buildModelFromUrdf(const std::string & filename) | |
23 | { | ||
24 | 6 | Model model; | |
25 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | pinocchio::urdf::buildModel(filename, model); |
26 | 6 | return model; | |
27 | } | ||
28 | |||
29 | ✗ | Model & buildModelFromUrdf(const std::string & filename, Model & model) | |
30 | { | ||
31 | ✗ | return pinocchio::urdf::buildModel(filename, model); | |
32 | } | ||
33 | |||
34 | 7 | Model buildModelFromUrdf(const std::string & filename, const JointModel & root_joint) | |
35 | { | ||
36 | 7 | Model model; | |
37 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | pinocchio::urdf::buildModel(filename, root_joint, model); |
38 | 7 | return model; | |
39 | } | ||
40 | |||
41 | Model & | ||
42 | ✗ | buildModelFromUrdf(const std::string & filename, const JointModel & root_joint, Model & model) | |
43 | { | ||
44 | ✗ | return pinocchio::urdf::buildModel(filename, root_joint, model); | |
45 | } | ||
46 | |||
47 | ✗ | Model buildModelFromXML(const std::string & XMLstream, const JointModel & root_joint) | |
48 | { | ||
49 | ✗ | Model model; | |
50 | ✗ | pinocchio::urdf::buildModelFromXML(XMLstream, root_joint, model); | |
51 | ✗ | return model; | |
52 | } | ||
53 | |||
54 | Model & | ||
55 | ✗ | buildModelFromXML(const std::string & XMLstream, const JointModel & root_joint, Model & model) | |
56 | { | ||
57 | ✗ | pinocchio::urdf::buildModelFromXML(XMLstream, root_joint, model); | |
58 | ✗ | return model; | |
59 | } | ||
60 | |||
61 | ✗ | Model buildModelFromXML(const std::string & XMLstream) | |
62 | { | ||
63 | ✗ | Model model; | |
64 | ✗ | pinocchio::urdf::buildModelFromXML(XMLstream, model); | |
65 | ✗ | return model; | |
66 | } | ||
67 | |||
68 | ✗ | Model & buildModelFromXML(const std::string & XMLstream, Model & model) | |
69 | { | ||
70 | ✗ | pinocchio::urdf::buildModelFromXML(XMLstream, model); | |
71 | ✗ | return model; | |
72 | } | ||
73 | |||
74 | #endif | ||
75 | |||
76 | 20 | void exposeURDFModel() | |
77 | { | ||
78 | |||
79 | #ifdef PINOCCHIO_WITH_URDFDOM | ||
80 | |||
81 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
82 | "buildModelFromUrdf", | ||
83 | static_cast<Model (*)(const std::string &, const JointModel &)>( | ||
84 | pinocchio::python::buildModelFromUrdf), | ||
85 | 40 | bp::args("urdf_filename", "root_joint"), | |
86 | "Parse the URDF file given in input and return a pinocchio Model starting with the " | ||
87 | "given root joint."); | ||
88 | |||
89 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
90 | "buildModelFromUrdf", | ||
91 | static_cast<Model (*)(const std::string &)>(pinocchio::python::buildModelFromUrdf), | ||
92 | 40 | bp::args("urdf_filename"), | |
93 | "Parse the URDF file given in input and return a pinocchio Model."); | ||
94 | |||
95 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
96 | "buildModelFromUrdf", | ||
97 | static_cast<Model & (*)(const std::string &, Model &)>( | ||
98 | pinocchio::python::buildModelFromUrdf), | ||
99 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | bp::args("urdf_filename", "model"), |
100 | "Append to a given model a URDF structure given by its filename.", | ||
101 | ✗ | bp::return_internal_reference<2>()); | |
102 | |||
103 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
104 | "buildModelFromUrdf", | ||
105 | static_cast<Model & (*)(const std::string &, const JointModel &, Model &)>( | ||
106 | pinocchio::python::buildModelFromUrdf), | ||
107 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | bp::args("urdf_filename", "root_joint", "model"), |
108 | "Append to a given model a URDF structure given by its filename and the root joint.\n" | ||
109 | "Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons," | ||
110 | "it is treated as operational frame and not as a joint of the model.", | ||
111 | ✗ | bp::return_internal_reference<3>()); | |
112 | |||
113 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
114 | "buildModelFromXML", | ||
115 | static_cast<Model (*)(const std::string &, const JointModel &)>( | ||
116 | pinocchio::python::buildModelFromXML), | ||
117 | 40 | bp::args("urdf_xml_stream", "root_joint"), | |
118 | "Parse the URDF XML stream given in input and return a pinocchio Model starting with " | ||
119 | "the given root joint."); | ||
120 | |||
121 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
122 | "buildModelFromXML", | ||
123 | static_cast<Model & (*)(const std::string &, const JointModel &, Model &)>( | ||
124 | pinocchio::python::buildModelFromXML), | ||
125 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | bp::args("urdf_xml_stream", "root_joint", "model"), |
126 | "Parse the URDF XML stream given in input and append it to the input model with the " | ||
127 | "given interfacing joint.", | ||
128 | ✗ | bp::return_internal_reference<3>()); | |
129 | |||
130 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
131 | "buildModelFromXML", | ||
132 | static_cast<Model (*)(const std::string &)>(pinocchio::python::buildModelFromXML), | ||
133 | 40 | bp::args("urdf_xml_stream"), | |
134 | "Parse the URDF XML stream given in input and return a pinocchio Model."); | ||
135 | |||
136 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
137 | "buildModelFromXML", | ||
138 | static_cast<Model & (*)(const std::string &, Model &)>( | ||
139 | pinocchio::python::buildModelFromXML), | ||
140 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | bp::args("urdf_xml_stream", "model"), |
141 | "Parse the URDF XML stream given in input and append it to the input model.", | ||
142 | 20 | bp::return_internal_reference<2>()); | |
143 | #endif | ||
144 | 20 | } | |
145 | } // namespace python | ||
146 | } // namespace pinocchio | ||
147 |