From 648da88f575a3266d8c7de12e957ac6fbaf63f7b Mon Sep 17 00:00:00 2001 From: JafarAbdi Date: Fri, 2 Jun 2023 20:46:37 +0000 Subject: [PATCH] Use sys.argv for rclcpp::init when no args are passed --- python/src/rviz_visual_tools.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/src/rviz_visual_tools.cpp b/python/src/rviz_visual_tools.cpp index 9af4a51..1821034 100644 --- a/python/src/rviz_visual_tools.cpp +++ b/python/src/rviz_visual_tools.cpp @@ -22,7 +22,11 @@ PYBIND11_MODULE(pyrviz_visual_tools, m) */ m.def( "init", - [](const std::vector& args) { + [](std::vector args) { + if (args.empty()) + { + args = py::module::import("sys").attr("argv").cast>(); + } std::vector raw_args; raw_args.reserve(args.size()); for (const auto& arg : args)