66 const std::unique_ptr<pluginlib::ClassLoader<TPluginClass>>& plugin_loader,
67 std::vector<std::shared_ptr<const TPluginClass>>& plugin_vector,
68 const std::vector<std::string>& plugin_names,
const std::string& parameter_namespace)
71 for (
const std::string& plugin_name : plugin_names)
73 RCLCPP_INFO(node->get_logger(),
"Try loading adapter '%s'", plugin_name.c_str());
74 std::shared_ptr<TPluginClass> adapter;
77 adapter = plugin_loader->createUniqueInstance(plugin_name);
79 catch (pluginlib::PluginlibException& ex)
81 RCLCPP_FATAL(node->get_logger(),
"Exception while loading planning adapter plugin '%s': %s", plugin_name.c_str(),
88 adapter->initialize(node, parameter_namespace);
89 plugin_vector.push_back(std::move(adapter));
90 RCLCPP_INFO(node->get_logger(),
"Loaded adapter '%s'", plugin_name.c_str());
94 RCLCPP_WARN(node->get_logger(),
"Failed to initialize adapter '%s'. Not adding it to the chain.",
113 PlanningPipeline(
const moveit::core::RobotModelConstPtr& model,
const std::shared_ptr<rclcpp::Node>& node,
114 const std::string& parameter_namespace);
126 PlanningPipeline(
const moveit::core::RobotModelConstPtr& model,
const std::shared_ptr<rclcpp::Node>& node,
127 const std::string& parameter_namespace,
const std::vector<std::string>& planner_plugin_names,
128 const std::vector<std::string>& request_adapter_plugin_names = std::vector<std::string>(),
129 const std::vector<std::string>& response_adapter_plugin_names = std::vector<std::string>());
150 "Please use getResponseAdapterPluginNames() or getRequestAdapterPluginNames().")]]
const std::vector<std::string>&
153 return pipeline_parameters_.request_adapters;
155 [[deprecated(
"`check_solution_paths` and `display_computed_motion_plans` are deprecated. To validate the solution "
156 "please add the ValidatePath response adapter and to publish the path use the DisplayMotionPath "
157 "response adapter to your pipeline.")]]
bool
160 const bool ,
const bool ,
167 return pipeline_parameters_.planning_plugins.at(0);
170 "Please use 'getPlannerManager(const std::string& planner_name)'.")]]
const planning_interface::PlannerManagerPtr&
173 return planner_map_.at(pipeline_parameters_.planning_plugins.at(0));
184 [[nodiscard]]
bool generatePlan(
const planning_scene::PlanningSceneConstPtr&
planning_scene,
187 const bool publish_received_requests =
false)
const;
190 void terminate()
const;
195 return pipeline_parameters_.planning_plugins;
201 return pipeline_parameters_.request_adapters;
207 return pipeline_parameters_.response_adapters;
225 return parameter_namespace_;
231 if (planner_map_.find(planner_name) == planner_map_.end())
233 RCLCPP_ERROR(node_->get_logger(),
"Cannot retrieve planner because '%s' does not exist.", planner_name.c_str());
236 return planner_map_.at(planner_name);
251 const std::string& pipeline_stage)
const;
254 mutable std::atomic<bool> active_;
257 std::shared_ptr<rclcpp::Node> node_;
258 const std::string parameter_namespace_;
259 planning_pipeline_parameters::Params pipeline_parameters_;
262 std::unique_ptr<pluginlib::ClassLoader<planning_interface::PlannerManager>> planner_plugin_loader_;
263 std::unordered_map<std::string, planning_interface::PlannerManagerPtr> planner_map_;
266 std::unique_ptr<pluginlib::ClassLoader<planning_interface::PlanningRequestAdapter>> request_adapter_plugin_loader_;
267 std::vector<planning_interface::PlanningRequestAdapterConstPtr> planning_request_adapter_vector_;
270 std::unique_ptr<pluginlib::ClassLoader<planning_interface::PlanningResponseAdapter>> response_adapter_plugin_loader_;
271 std::vector<planning_interface::PlanningResponseAdapterConstPtr> planning_response_adapter_vector_;
274 moveit::core::RobotModelConstPtr robot_model_;
277 rclcpp::Publisher<moveit_msgs::msg::PipelineState>::SharedPtr progress_publisher_;
279 rclcpp::Logger logger_;
bool generatePlan(const planning_scene::PlanningSceneConstPtr &, const planning_interface::MotionPlanRequest &, planning_interface::MotionPlanResponse &, const bool, const bool, const bool) const
void loadPluginVector(const std::shared_ptr< rclcpp::Node > &node, const std::unique_ptr< pluginlib::ClassLoader< TPluginClass > > &plugin_loader, std::vector< std::shared_ptr< const TPluginClass > > &plugin_vector, const std::vector< std::string > &plugin_names, const std::string ¶meter_namespace)
Helper function template to load a vector of plugins.