148 rclcpp::init(argc, argv);
149 rclcpp::NodeOptions node_options;
150 node_options.allow_undeclared_parameters(
true);
151 node_options.automatically_declare_parameters_from_overrides(
true);
152 rclcpp::Node::SharedPtr node = rclcpp::Node::make_shared(
"save_to_warehouse", node_options);
155 boost::program_options::options_description desc;
156 desc.add_options()(
"help",
"Show help message")(
"host", boost::program_options::value<std::string>(),
158 "DB.")(
"port", boost::program_options::value<std::size_t>(),
161 boost::program_options::variables_map vm;
162 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
163 boost::program_options::notify(vm);
165 if (vm.count(
"help"))
167 std::cout << desc <<
'\n';
172 if (vm.count(
"host") && vm.count(
"port"))
173 conn->setParams(vm[
"host"].as<std::string>(), vm[
"port"].as<std::size_t>());
174 if (!conn->connect())
180 RCLCPP_ERROR(node->get_logger(),
"Unable to initialize PlanningSceneMonitor");
189 std::vector<std::string> names;
193 RCLCPP_INFO(node->get_logger(),
"There are no previously stored scenes");
197 RCLCPP_INFO(node->get_logger(),
"Previously stored scenes:");
198 for (
const std::string& name : names)
199 RCLCPP_INFO(node->get_logger(),
" * %s", name.c_str());
204 RCLCPP_INFO(node->get_logger(),
"There are no previously stored constraints");
208 RCLCPP_INFO(node->get_logger(),
"Previously stored constraints:");
209 for (
const std::string& name : names)
210 RCLCPP_INFO(node->get_logger(),
" * %s", name.c_str());
215 RCLCPP_INFO(node->get_logger(),
"There are no previously stored robot states");
219 RCLCPP_INFO(node->get_logger(),
"Previously stored robot states:");
220 for (
const std::string& name : names)
221 RCLCPP_INFO(node->get_logger(),
" * %s", name.c_str());
226 auto mplan_req_sub = node->create_subscription<moveit_msgs::msg::MotionPlanRequest>(
227 "motion_plan_request", rclcpp::SystemDefaultsQoS(),
228 [&](
const moveit_msgs::msg::MotionPlanRequest& msg) {
onMotionPlanRequest(msg, psm, pss); });
229 auto constr_sub = node->create_subscription<moveit_msgs::msg::Constraints>(
230 "constraints", rclcpp::SystemDefaultsQoS(),
231 [&](
const moveit_msgs::msg::Constraints& msg) {
onConstraints(msg, cs); });
232 auto state_sub = node->create_subscription<moveit_msgs::msg::RobotState>(
233 "robot_state", rclcpp::SystemDefaultsQoS(),
234 [&](
const moveit_msgs::msg::RobotState& msg) {
onRobotState(msg, rs); });
236 std::vector<std::string> topics;
238 RCLCPP_INFO_STREAM(node->get_logger(),
239 "Listening for scene updates on topics " << fmt::format(
"{}", fmt::join(topics,
", ")));
240 RCLCPP_INFO_STREAM(node->get_logger(),
"Listening for planning requests on topic " << mplan_req_sub->get_topic_name());
241 RCLCPP_INFO_STREAM(node->get_logger(),
"Listening for named constraints on topic " << constr_sub->get_topic_name());
242 RCLCPP_INFO_STREAM(node->get_logger(),
"Listening for states on topic " << state_sub->get_topic_name());