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 |
|
|
|
10 |
|
|
#include <boost/python.hpp> |
11 |
|
|
#include <boost/python/tuple.hpp> |
12 |
|
|
|
13 |
|
|
namespace pinocchio |
14 |
|
|
{ |
15 |
|
|
namespace python |
16 |
|
|
{ |
17 |
|
|
|
18 |
|
|
namespace bp = boost::python; |
19 |
|
|
|
20 |
|
|
#ifdef PINOCCHIO_WITH_SDFORMAT |
21 |
|
|
bp::tuple buildModelFromSdf( |
22 |
|
|
const std::string & filename, |
23 |
|
|
const std::string & root_link_name, |
24 |
|
|
const std::vector<std::string> & parent_guidance) |
25 |
|
|
{ |
26 |
|
|
Model model; |
27 |
|
|
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) contact_models; |
28 |
|
|
::pinocchio::sdf::buildModel( |
29 |
|
|
filename, model, contact_models, root_link_name, parent_guidance); |
30 |
|
|
return bp::make_tuple(model, contact_models); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
bp::tuple buildModelFromSdf( |
34 |
|
|
const std::string & filename, |
35 |
|
|
const JointModel & root_joint, |
36 |
|
|
const std::string & root_link_name, |
37 |
|
|
const std::vector<std::string> & parent_guidance) |
38 |
|
|
{ |
39 |
|
|
Model model; |
40 |
|
|
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) contact_models; |
41 |
|
|
pinocchio::sdf::buildModel( |
42 |
|
|
filename, root_joint, model, contact_models, root_link_name, parent_guidance); |
43 |
|
|
return bp::make_tuple(model, contact_models); |
44 |
|
|
} |
45 |
|
|
#endif |
46 |
|
|
|
47 |
|
20 |
void exposeSDFModel() |
48 |
|
|
{ |
49 |
|
|
#ifdef PINOCCHIO_WITH_SDFORMAT |
50 |
|
|
bp::def( |
51 |
|
|
"buildModelFromSdf", |
52 |
|
|
static_cast<bp::tuple (*)( |
53 |
|
|
const std::string &, const std::string &, const std::vector<std::string> &)>( |
54 |
|
|
pinocchio::python::buildModelFromSdf), |
55 |
|
|
(bp::arg("sdf_filename"), bp::arg("root_link_name"), |
56 |
|
|
bp::arg("parent_guidance") = bp::list()), |
57 |
|
|
"Parse the SDF file given in input and return a pinocchio Model and constraint models."); |
58 |
|
|
|
59 |
|
|
bp::def( |
60 |
|
|
"buildModelFromSdf", |
61 |
|
|
static_cast<bp::tuple (*)( |
62 |
|
|
const std::string &, const JointModel &, const std::string &, |
63 |
|
|
const std::vector<std::string> &)>(pinocchio::python::buildModelFromSdf), |
64 |
|
|
(bp::arg("sdf_filename"), bp::arg("root_joint"), bp::arg("root_link_name"), |
65 |
|
|
bp::arg("parent_guidance") = bp::list()), |
66 |
|
|
"Parse the SDF file given in input and return a pinocchio Model and constraint " |
67 |
|
|
"models starting with the given root joint."); |
68 |
|
|
#endif |
69 |
|
20 |
} |
70 |
|
|
} // namespace python |
71 |
|
|
} // namespace pinocchio |
72 |
|
|
|