diff --git a/drake_ros_viz/CMakeLists.txt b/drake_ros_viz/CMakeLists.txt index 61863f6c..89bf45f2 100644 --- a/drake_ros_viz/CMakeLists.txt +++ b/drake_ros_viz/CMakeLists.txt @@ -74,7 +74,7 @@ install( # Python bindings ### pybind11_add_module(py_drake_ros_viz SHARED - src/python_bindings/module_drake_ros_viz.cpp + src/python_bindings/drake_ros_viz.cc ) set_target_properties(py_drake_ros_viz PROPERTIES OUTPUT_NAME "drake_ros_viz") target_link_libraries(py_drake_ros_viz PRIVATE drake_ros_viz) @@ -84,11 +84,11 @@ target_include_directories(py_drake_ros_viz ) # Sets PYTHON_INSTALL_DIR -_ament_cmake_python_get_python_install_dir() +ament_get_python_install_dir(python_install_dir) install( TARGETS py_drake_ros_viz - DESTINATION "${PYTHON_INSTALL_DIR}" + DESTINATION "${python_install_dir}" ) ### End Python bindings diff --git a/drake_ros_viz/src/python_bindings/module_drake_ros_viz.cpp b/drake_ros_viz/src/python_bindings/drake_ros_viz.cc similarity index 65% rename from drake_ros_viz/src/python_bindings/module_drake_ros_viz.cpp rename to drake_ros_viz/src/python_bindings/drake_ros_viz.cc index f8253861..514c0fae 100644 --- a/drake_ros_viz/src/python_bindings/module_drake_ros_viz.cpp +++ b/drake_ros_viz/src/python_bindings/drake_ros_viz.cc @@ -13,17 +13,19 @@ // limitations under the License. #include -#include "drake_ros_viz/rviz_visualizer.hpp" -#include +#include "drake_ros_core/drake_ros.h" +#include #include #include +#include "drake_ros_viz/rviz_visualizer.h" + namespace py = pybind11; using drake::systems::Diagram; using drake::systems::TriggerType; -using drake_ros_core::DrakeRosInterface; +using drake_ros_core::DrakeRos; using drake_ros_viz::RvizVisualizer; using drake_ros_viz::RvizVisualizerParams; @@ -34,23 +36,26 @@ PYBIND11_MODULE(drake_ros_viz, m) { py::module::import("pydrake.systems.framework"); py::module::import("pydrake.multibody.plant"); + const RvizVisualizerParams default_params{}; py::class_(m, "RvizVisualizerParams") - .def(py::init([](py::kwargs kwargs) { - RvizVisualizerParams obj{}; - py::object pyobj = py::cast(&obj, py::return_value_policy::reference); - for (auto& item : kwargs) { - py::setattr(pyobj, item.first, item.second); - } - return obj; - })) + .def(py::init([](const std::unordered_set& + publish_triggers, + double publish_period, bool publish_tf) { + return RvizVisualizerParams{publish_triggers, publish_period, + publish_tf}; + }), + py::kw_only(), + py::arg("publish_triggers") = default_params.publish_triggers, + py::arg("publish_period") = default_params.publish_period, + py::arg("publish_tf") = default_params.publish_tf) .def_readwrite("publish_triggers", &RvizVisualizerParams::publish_triggers) .def_readwrite("publish_period", &RvizVisualizerParams::publish_period) .def_readwrite("publish_tf", &RvizVisualizerParams::publish_tf); py::class_>(m, "RvizVisualizer") - .def(py::init, RvizVisualizerParams>(), - py::arg("ros_interface"), py::arg("params") = RvizVisualizerParams{}) + .def(py::init(), py::arg("ros"), + py::arg("params") = RvizVisualizerParams{}) .def("RegisterMultibodyPlant", &RvizVisualizer::RegisterMultibodyPlant) .def("get_graph_query_port", &RvizVisualizer::get_graph_query_port, py::return_value_policy::reference_internal);