38 #include <rclcpp/logger.hpp>
44 static const rclcpp::Logger LOGGER = rclcpp::get_logger(
"moveit.planning_request_adapter");
55 return context->solve(res);
63 std::vector<std::size_t>& added_path_index)
67 return adapter.adaptAndPlan(planner,
planning_scene, req, res, added_path_index);
69 catch (std::exception& ex)
71 RCLCPP_ERROR(LOGGER,
"Exception caught executing adapter '%s': %s\nSkipping adapter instead.",
72 adapter.getDescription().c_str(), ex.what());
73 added_path_index.clear();
84 std::vector<std::size_t>& added_path_index)
const
89 return callPlannerInterfaceSolve(*planner,
scene, req, res);
99 std::vector<std::size_t> dummy;
108 std::vector<std::size_t> dummy;
116 std::vector<std::size_t>& added_path_index)
const
119 if (adapters_.empty())
121 added_path_index.clear();
122 return callPlannerInterfaceSolve(*planner,
planning_scene, req, res);
127 std::vector<std::vector<std::size_t> > added_path_index_each(adapters_.size());
135 return callPlannerInterfaceSolve(planner,
scene, req, res);
138 for (
int i = adapters_.size() - 1; i >= 0; --i)
140 fn = [&adapter = *adapters_[i], fn, &added_path_index = added_path_index_each[i]](
143 return callAdapter(adapter, fn,
scene, req, res, added_path_index);
148 added_path_index.clear();
151 for (std::vector<std::size_t>& added_states_by_each_adapter : added_path_index_each)
152 for (std::size_t& added_index : added_states_by_each_adapter)
154 for (std::size_t& index_in_path : added_path_index)
155 if (added_index <= index_in_path)
157 added_path_index.push_back(added_index);
159 std::sort(added_path_index.begin(), added_path_index.end());
Base class for a MoveIt planner.
virtual PlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr &planning_scene, const MotionPlanRequest &req, moveit_msgs::msg::MoveItErrorCodes &error_code) const =0
Construct a planning context given the current scene and a planning request. If a problem is encounte...
bool adaptAndPlan(const planning_interface::PlannerManagerPtr &planner, const planning_scene::PlanningSceneConstPtr &planning_scene, const planning_interface::MotionPlanRequest &req, planning_interface::MotionPlanResponse &res) const
bool adaptAndPlan(const planning_interface::PlannerManagerPtr &planner, const planning_scene::PlanningSceneConstPtr &planning_scene, const planning_interface::MotionPlanRequest &req, planning_interface::MotionPlanResponse &res) const
std::function< bool(const planning_scene::PlanningSceneConstPtr &, const planning_interface::MotionPlanRequest &, planning_interface::MotionPlanResponse &)> PlannerFn
moveit_msgs::msg::MotionPlanRequest MotionPlanRequest
Generic interface to adapting motion planning requests.
This namespace includes the central class for representing planning contexts.
moveit_msgs::msg::MoveItErrorCodes error_code_