37 #include <sys/types.h>
40 #include <rclcpp/logger.hpp>
41 #include <rclcpp/logging.hpp>
42 #include <rclcpp/utilities.hpp>
44 static const rclcpp::Logger
LOGGER = rclcpp::get_logger(
"moveit.ros.warehouse.warehouse_connector");
49 RCLCPP_ERROR(LOGGER,
"Warehouse connector not supported on Windows");
53 RCLCPP_ERROR(LOGGER,
"Warehouse connector not supported on Windows");
69 kill(child_pid_, SIGTERM);
75 kill(child_pid_, SIGTERM);
80 RCLCPP_ERROR(LOGGER,
"Error forking process.");
87 std::size_t exec_file_pos = dbexec_.find_last_of(
"/\\");
88 if (exec_file_pos != std::string::npos)
90 char** argv =
new char*[4];
91 std::size_t exec_length = 1 + dbexec_.length() - exec_file_pos;
92 argv[0] =
new char[1 + exec_length];
93 snprintf(argv[0], exec_length,
"%s", dbexec_.substr(exec_file_pos + 1).c_str());
95 argv[1] =
new char[16];
96 snprintf(argv[1], 15,
"--dbpath");
98 argv[2] =
new char[1024];
99 snprintf(argv[2], 1023,
"%s", dirname.c_str());
103 int code = execv(dbexec_.c_str(), argv);
108 RCLCPP_ERROR_STREAM(LOGGER,
109 "execv() returned " << code <<
", errno=" << errno <<
" string errno = " << strerror(errno));
116 using namespace std::chrono_literals;
117 rclcpp::sleep_for(1s);
WarehouseConnector(const std::string &dbexec)
bool connectToDatabase(const std::string &db_dirname)
const rclcpp::Logger LOGGER