23
23
#include " sdf/Model.hh"
24
24
#include " sdf/Root.hh"
25
25
#include " sdf/World.hh"
26
+ #include " pybind11_helpers.hh"
26
27
27
28
using namespace pybind11 ::literals;
28
29
@@ -38,23 +39,32 @@ void defineRoot(pybind11::object module)
38
39
pybind11::class_<sdf::Root>(module, " Root" )
39
40
.def (pybind11::init<>())
40
41
.def (" load" ,
41
- pybind11::overload_cast<const std::string &>(&sdf::Root::Load),
42
+ [](Root &self, const std::string &_filename)
43
+ {
44
+ ThrowIfErrors (self.Load (_filename));
45
+ },
42
46
" Parse the given SDF file, and generate objects based on types "
43
47
" specified in the SDF file." )
44
48
.def (" load" ,
45
- pybind11::overload_cast<
46
- const std::string &, const ParserConfig &>(&sdf::Root::Load),
49
+ [](Root &self, const std::string &_filename,
50
+ const ParserConfig &_config)
51
+ {
52
+ ThrowIfErrors (self.Load (_filename, _config));
53
+ },
47
54
" Parse the given SDF file, and generate objects based on types "
48
55
" specified in the SDF file." )
49
56
.def (" load_sdf_string" ,
50
- pybind11::overload_cast<const std::string &>(
51
- &sdf::Root::LoadSdfString),
57
+ [](Root &self, const std::string &_sdf)
58
+ {
59
+ ThrowIfErrors (self.LoadSdfString (_sdf));
60
+ },
52
61
" Parse the given SDF string, and generate objects based on types "
53
62
" specified in the SDF file." )
54
63
.def (" load_sdf_string" ,
55
- pybind11::overload_cast<
56
- const std::string &, const ParserConfig &>(
57
- &sdf::Root::LoadSdfString),
64
+ [](Root &self, const std::string &_sdf, const ParserConfig &_config)
65
+ {
66
+ ThrowIfErrors (self.LoadSdfString (_sdf, _config));
67
+ },
58
68
" Parse the given SDF string, and generate objects based on types "
59
69
" specified in the SDF file." )
60
70
.def (" version" , &sdf::Root::Version,
@@ -84,11 +94,17 @@ void defineRoot(pybind11::object module)
84
94
.def (" set_light" , &sdf::Root::SetLight,
85
95
" Set the light object. This will override any existing model, "
86
96
" actor, and light object." )
87
- .def (" add_world" , &sdf::Root::AddWorld,
97
+ .def (" add_world" , [](Root &self, const World &_world)
98
+ {
99
+ ThrowIfErrors (self.AddWorld (_world));
100
+ },
88
101
" Add a world to the root." )
89
102
.def (" clear_worlds" , &sdf::Root::ClearWorlds,
90
103
" Remove all worlds." )
91
- .def (" update_graphs" , &sdf::Root::UpdateGraphs,
104
+ .def (" update_graphs" , [](Root &self)
105
+ {
106
+ ThrowIfErrors (self.UpdateGraphs ());
107
+ },
92
108
" Recreate the frame and pose graphs for the worlds and model "
93
109
" that are children of this Root object. You can call this function "
94
110
" to build new graphs when the DOM was created programmatically, or "
0 commit comments