43 std::string packageName, std::string launchFileName, std::function<
bool()> cancelCondition)
50 rclcpp::get_logger(
"smacc2"),
"[ClRosLaunch static] starting ros launch thread ");
52 std::stringstream cmd;
53 cmd <<
"ros2 launch " << packageName <<
" " << launchFileName;
55 std::array<char, 128> buffer;
57 std::unique_ptr<FILE,
decltype(&pclose)> pipe(popen(cmd.str().c_str(),
"r"), pclose);
60 throw std::runtime_error(
"popen() failed!");
64 bool cancelled =
false;
67 while (fgets(buffer.data(), buffer.size(), pipe.get()) !=
nullptr &&
68 !(cancelled = cancelCondition()))
74 rclcpp::get_logger(
"smacc2"),
"[ClRosLaunch static] cancelling ros launch thread ");
77 pclose(pipe.release());
83 catch (
const std::exception & e)
85 std::cerr << e.what() <<
'\n';
90 rclcpp::get_logger(
"smacc2"),
"[ClRosLaunch static]] RESULT = \n " << ss.str());