54 double map_resolution,
55 const std::string& map_frame)
57 , parameters_{ map_resolution, map_frame, {} }
62 updater_plugin_loader_ = std::make_unique<pluginlib::ClassLoader<OccupancyMapUpdater>>(
63 "moveit_ros_occupancy_map_monitor",
"occupancy_map_monitor::OccupancyMapUpdater");
65 catch (pluginlib::PluginlibException& ex)
67 RCLCPP_FATAL_STREAM(logger_,
"Exception while creating octomap updater plugin loader " << ex.what());
71 if (parameters_.map_resolution <= std::numeric_limits<double>::epsilon())
73 if (!node_->get_parameter(
"octomap_resolution", parameters_.map_resolution))
75 parameters_.map_resolution = 0.1;
76 RCLCPP_WARN(logger_,
"Resolution not specified for Octomap. Assuming resolution = %g instead",
77 parameters_.map_resolution);
81 if (parameters_.map_frame.empty())
83 node_->get_parameter(
"octomap_frame", parameters_.map_frame);
84 if (parameters_.map_frame.empty())
86 RCLCPP_ERROR(logger_,
"No 'octomap_frame' parameter defined for octomap updates");
90 std::vector<std::string> sensor_names;
91 if (!node_->get_parameter(
"sensors", sensor_names))
93 RCLCPP_ERROR(logger_,
"No 3D sensor plugin(s) defined for octomap updates");
95 else if (sensor_names.empty())
97 RCLCPP_ERROR(logger_,
"List of sensors is empty!");
100 for (
const auto& sensor_name : sensor_names)
102 std::string sensor_plugin =
"";
103 if (!node_->get_parameter(sensor_name +
".sensor_plugin", sensor_plugin))
105 RCLCPP_ERROR(logger_,
"No sensor plugin specified for octomap updater %s; ignoring.", sensor_name.c_str());
108 if (sensor_plugin.empty() || sensor_plugin[0] ==
'~')
110 RCLCPP_INFO_STREAM(logger_,
"Skipping octomap updater plugin '" << sensor_plugin <<
'\'');
115 parameters_.sensor_plugins.emplace_back(sensor_name, sensor_plugin);
125OccupancyMapUpdaterPtr OccupancyMapMonitorMiddlewareHandle::loadOccupancyMapUpdater(
const std::string& sensor_plugin)
129 return updater_plugin_loader_->createUniqueInstance(sensor_plugin);
131 catch (pluginlib::PluginlibException& exception)
133 RCLCPP_ERROR_STREAM(logger_,
"Exception while loading octomap updater '" << sensor_plugin
134 <<
"': " << exception.what() <<
'\n');