43 static std::vector<std::string>& ROScppArgs()
45 static std::vector<std::string>
args;
49 static std::string& ROScppNodeName()
51 static std::string node_name(
"moveit_python_wrappers");
57 ROScppNodeName() = node_name;
67 const std::vector<std::string>&
args = ROScppArgs();
68 int fake_argc =
args.size();
69 char** fake_argv =
new char*[
args.size()];
70 for (std::size_t i = 0; i <
args.size(); ++i)
71 fake_argv[i] = strdup(
args[i].c_str());
73 ros::init(fake_argc, fake_argv, ROScppNodeName(),
74 ros::init_options::AnonymousName | ros::init_options::NoSigintHandler);
75 for (
int i = 0; i < fake_argc; ++i)
76 delete[] fake_argv[i];
82 if (ros::isInitialized() && !ros::isShuttingDown())
88 static void roscpp_init_or_stop(
bool init)
91 static std::mutex lock;
92 std::mutex::scoped_lock slock(lock);
95 static bool once =
true;
96 static std::unique_ptr<InitProxy> proxy;
97 static std::unique_ptr<ros::AsyncSpinner> spinner;
105 if (!ros::isInitialized())
107 proxy = std::make_unique<InitProxy>();
108 spinner = std::make_unique<ros::AsyncSpinner>(1);
124 roscpp_init_or_stop(
true);
141 roscpp_init_or_stop(
false);