Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2021 CNRS INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifdef PINOCCHIO_WITH_SDFORMAT |
6 |
|
|
#include "pinocchio/parsers/sdf.hpp" |
7 |
|
|
#endif |
8 |
|
|
#include "pinocchio/bindings/python/parsers/sdf.hpp" |
9 |
|
|
#include "pinocchio/bindings/python/utils/path.hpp" |
10 |
|
|
|
11 |
|
|
#include <boost/python.hpp> |
12 |
|
|
#include <boost/python/tuple.hpp> |
13 |
|
|
|
14 |
|
|
namespace pinocchio |
15 |
|
|
{ |
16 |
|
|
namespace python |
17 |
|
|
{ |
18 |
|
|
|
19 |
|
|
namespace bp = boost::python; |
20 |
|
|
|
21 |
|
|
#ifdef PINOCCHIO_WITH_SDFORMAT |
22 |
|
|
bp::tuple buildModelFromSdf( |
23 |
|
|
const bp::object & filename, |
24 |
|
|
const std::string & root_link_name, |
25 |
|
|
const std::vector<std::string> & parent_guidance) |
26 |
|
|
{ |
27 |
|
|
Model model; |
28 |
|
|
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) contact_models; |
29 |
|
|
::pinocchio::sdf::buildModel( |
30 |
|
|
path(filename), model, contact_models, root_link_name, parent_guidance); |
31 |
|
|
return bp::make_tuple(model, contact_models); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
bp::tuple buildModelFromSdf( |
35 |
|
|
const bp::object & filename, |
36 |
|
|
const JointModel & root_joint, |
37 |
|
|
const std::string & root_link_name, |
38 |
|
|
const std::vector<std::string> & parent_guidance) |
39 |
|
|
{ |
40 |
|
|
Model model; |
41 |
|
|
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) contact_models; |
42 |
|
|
pinocchio::sdf::buildModel( |
43 |
|
|
path(filename), root_joint, model, contact_models, root_link_name, parent_guidance); |
44 |
|
|
return bp::make_tuple(model, contact_models); |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
bp::tuple buildModelFromSdf( |
48 |
|
|
const bp::object & filename, |
49 |
|
|
const JointModel & root_joint, |
50 |
|
|
const std::string & root_link_name, |
51 |
|
|
const std::string & root_joint_name, |
52 |
|
|
const std::vector<std::string> & parent_guidance) |
53 |
|
|
{ |
54 |
|
|
Model model; |
55 |
|
|
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) contact_models; |
56 |
|
|
pinocchio::sdf::buildModel( |
57 |
|
|
path(filename), root_joint, root_joint_name, model, contact_models, root_link_name, |
58 |
|
|
parent_guidance); |
59 |
|
|
return bp::make_tuple(model, contact_models); |
60 |
|
|
} |
61 |
|
|
#endif |
62 |
|
|
|
63 |
|
65 |
void exposeSDFModel() |
64 |
|
|
{ |
65 |
|
|
#ifdef PINOCCHIO_WITH_SDFORMAT |
66 |
|
|
bp::def( |
67 |
|
|
"buildModelFromSdf", |
68 |
|
|
static_cast<bp::tuple (*)( |
69 |
|
|
const bp::object &, const std::string &, const std::vector<std::string> &)>( |
70 |
|
|
pinocchio::python::buildModelFromSdf), |
71 |
|
|
(bp::arg("sdf_filename"), bp::arg("root_link_name"), |
72 |
|
|
bp::arg("parent_guidance") = bp::list()), |
73 |
|
|
"Parse the SDF file given in input and return a pinocchio Model and constraint models."); |
74 |
|
|
|
75 |
|
|
bp::def( |
76 |
|
|
"buildModelFromSdf", |
77 |
|
|
static_cast<bp::tuple (*)( |
78 |
|
|
const bp::object &, const JointModel &, const std::string &, |
79 |
|
|
const std::vector<std::string> &)>(pinocchio::python::buildModelFromSdf), |
80 |
|
|
(bp::arg("sdf_filename"), bp::arg("root_joint"), bp::arg("root_link_name"), |
81 |
|
|
bp::arg("parent_guidance") = bp::list()), |
82 |
|
|
"Parse the SDF file given in input and return a pinocchio Model and constraint " |
83 |
|
|
"models starting with the given root joint."); |
84 |
|
|
|
85 |
|
|
bp::def( |
86 |
|
|
"buildModelFromSdf", |
87 |
|
|
static_cast<bp::tuple (*)( |
88 |
|
|
const bp::object &, const JointModel &, const std::string &, const std::string &, |
89 |
|
|
const std::vector<std::string> &)>(pinocchio::python::buildModelFromSdf), |
90 |
|
|
(bp::arg("sdf_filename"), bp::arg("root_joint"), bp::arg("root_link_name"), |
91 |
|
|
bp::arg("root_joint_name"), bp::arg("parent_guidance") = bp::list()), |
92 |
|
|
"Parse the SDF file given in input and return a pinocchio Model and constraint " |
93 |
|
|
"models starting with the given root joint and its specified name."); |
94 |
|
|
#endif |
95 |
|
65 |
} |
96 |
|
|
} // namespace python |
97 |
|
|
} // namespace pinocchio |
98 |
|
|
|