moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
planning_context_manager.h
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2012, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Ioan Sucan */
36
37#pragma once
38
43
44#include <ompl/base/PlannerDataStorage.h>
45
46#include <string>
47#include <map>
48
49namespace ompl_interface
50{
52{
53public:
56
57 template <typename T>
58 ob::PlannerPtr allocatePlanner(const ob::SpaceInformationPtr& si, const std::string& new_name,
60
61private:
62 template <typename T>
63 ob::PlannerPtr allocatePlannerImpl(const ob::SpaceInformationPtr& si, const std::string& new_name,
64 const ModelBasedPlanningContextSpecification& spec, bool load_planner_data = false,
65 bool store_planner_data = false, const std::string& file_path = "");
66
67 template <typename T>
68 inline ob::Planner* allocatePersistentPlanner(const ob::PlannerData& data);
69
70 // Storing multi-query planners
71 std::map<std::string, ob::PlannerPtr> planners_;
72
73 std::map<std::string, std::string> planner_data_storage_paths_;
74
75 // Store and load planner data
76 ob::PlannerDataStorage storage_;
77};
78
80{
81public:
82 PlanningContextManager(moveit::core::RobotModelConstPtr robot_model,
83 constraint_samplers::ConstraintSamplerManagerPtr csm);
85
89
95
96 /* \brief Get the maximum number of sampling attempts allowed when sampling states is needed */
98 {
100 }
101
102 /* \brief Set the maximum number of sampling attempts allowed when sampling states is needed */
103 void setMaximumStateSamplingAttempts(unsigned int max_state_sampling_attempts)
104 {
105 max_state_sampling_attempts_ = max_state_sampling_attempts;
106 }
107
108 /* \brief Get the maximum number of sampling attempts allowed when sampling goals is needed */
110 {
112 }
113
114 /* \brief Set the maximum number of sampling attempts allowed when sampling goals is needed */
115 void setMaximumGoalSamplingAttempts(unsigned int max_goal_sampling_attempts)
116 {
117 max_goal_sampling_attempts_ = max_goal_sampling_attempts;
118 }
119
120 /* \brief Get the maximum number of goal samples */
121 unsigned int getMaximumGoalSamples() const
122 {
123 return max_goal_samples_;
124 }
125
126 /* \brief Set the maximum number of goal samples */
127 void setMaximumGoalSamples(unsigned int max_goal_samples)
128 {
129 max_goal_samples_ = max_goal_samples;
130 }
131
132 /* \brief Get the maximum number of planning threads allowed */
133 unsigned int getMaximumPlanningThreads() const
134 {
136 }
137
138 /* \brief Set the maximum number of planning threads */
139 void setMaximumPlanningThreads(unsigned int max_planning_threads)
140 {
141 max_planning_threads_ = max_planning_threads;
142 }
143
144 /* \brief Get the maximum solution segment length */
146 {
148 }
149
150 /* \brief Set the maximum solution segment length */
152 {
154 }
155
156 unsigned int getMinimumWaypointCount() const
157 {
159 }
160
162 void setMinimumWaypointCount(unsigned int mwc)
163 {
165 }
166
167 const moveit::core::RobotModelConstPtr& getRobotModel() const
168 {
169 return robot_model_;
170 }
171
181 ModelBasedPlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene,
183 moveit_msgs::msg::MoveItErrorCodes& error_code,
184 const rclcpp::Node::SharedPtr& node,
185 bool use_constraints_approximations) const;
186
187 void registerPlannerAllocator(const std::string& planner_id, const ConfiguredPlannerAllocator& pa)
188 {
189 known_planners_[planner_id] = pa;
190 }
191
192 void registerStateSpaceFactory(const ModelBasedStateSpaceFactoryPtr& factory)
193 {
194 state_space_factories_[factory->getType()] = factory;
195 }
196
197 const std::map<std::string, ConfiguredPlannerAllocator>& getRegisteredPlannerAllocators() const
198 {
199 return known_planners_;
200 }
201
202 const std::map<std::string, ModelBasedStateSpaceFactoryPtr>& getRegisteredStateSpaceFactories() const
203 {
205 }
206
208
209protected:
210 ConfiguredPlannerAllocator plannerSelector(const std::string& planner) const;
211
214
215 template <typename T>
216 void registerPlannerAllocatorHelper(const std::string& planner_id);
217
219 ModelBasedPlanningContextPtr getPlanningContext(const planning_interface::PlannerConfigurationSettings& config,
220 const ModelBasedStateSpaceFactoryPtr& factory,
221 const moveit_msgs::msg::MotionPlanRequest& req) const;
222
223 const ModelBasedStateSpaceFactoryPtr& getStateSpaceFactory(const std::string& factory_type) const;
224 const ModelBasedStateSpaceFactoryPtr& getStateSpaceFactory(const std::string& group_name,
225 const moveit_msgs::msg::MotionPlanRequest& req) const;
226
228 moveit::core::RobotModelConstPtr robot_model_;
229
230 constraint_samplers::ConstraintSamplerManagerPtr constraint_sampler_manager_;
231
232 std::map<std::string, ConfiguredPlannerAllocator> known_planners_;
233 std::map<std::string, ModelBasedStateSpaceFactoryPtr> state_space_factories_;
234
241
243 unsigned int max_goal_samples_;
244
248
251
254
258
262
265
266private:
268 CachedContextsPtr cached_contexts_;
269};
270} // namespace ompl_interface
#define MOVEIT_STRUCT_FORWARD(C)
ob::PlannerPtr allocatePlanner(const ob::SpaceInformationPtr &si, const std::string &new_name, const ModelBasedPlanningContextSpecification &spec)
planning_interface::PlannerConfigurationMap planner_configs_
All the existing planning configurations. The name of the configuration is the key of the map....
const std::map< std::string, ConfiguredPlannerAllocator > & getRegisteredPlannerAllocators() const
const ModelBasedStateSpaceFactoryPtr & getStateSpaceFactory(const std::string &factory_type) const
unsigned int max_goal_sampling_attempts_
maximum number of attempts to be made at sampling goals
void setMaximumStateSamplingAttempts(unsigned int max_state_sampling_attempts)
std::map< std::string, ConfiguredPlannerAllocator > known_planners_
const std::map< std::string, ModelBasedStateSpaceFactoryPtr > & getRegisteredStateSpaceFactories() const
void registerPlannerAllocator(const std::string &planner_id, const ConfiguredPlannerAllocator &pa)
ModelBasedPlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr &planning_scene, const planning_interface::MotionPlanRequest &req, moveit_msgs::msg::MoveItErrorCodes &error_code, const rclcpp::Node::SharedPtr &node, bool use_constraints_approximations) const
Returns a planning context to OMPLInterface, which in turn passes it to OMPLPlannerManager.
constraint_samplers::ConstraintSamplerManagerPtr constraint_sampler_manager_
unsigned int max_planning_threads_
when planning in parallel, this is the maximum number of threads to use at one time
unsigned int max_goal_samples_
maximum number of states to sample in the goal region for any planning request (when such sampling is...
moveit::core::RobotModelConstPtr robot_model_
The kinematic model for which motion plans are computed.
ConfiguredPlannerSelector getPlannerSelector() const
void setMaximumGoalSamples(unsigned int max_goal_samples)
std::map< std::string, ModelBasedStateSpaceFactoryPtr > state_space_factories_
const moveit::core::RobotModelConstPtr & getRobotModel() const
void setPlannerConfigurations(const planning_interface::PlannerConfigurationMap &pconfig)
Specify configurations for the planners.
void setMinimumWaypointCount(unsigned int mwc)
Get the minimum number of waypoints along the solution path.
void setMaximumGoalSamplingAttempts(unsigned int max_goal_sampling_attempts)
ConfiguredPlannerAllocator plannerSelector(const std::string &planner) const
const planning_interface::PlannerConfigurationMap & getPlannerConfigurations() const
Return the previously set planner configurations.
void registerPlannerAllocatorHelper(const std::string &planner_id)
void setMaximumPlanningThreads(unsigned int max_planning_threads)
MultiQueryPlannerAllocator planner_allocator_
Multi-query planner allocator.
void registerStateSpaceFactory(const ModelBasedStateSpaceFactoryPtr &factory)
The MoveIt interface to OMPL.
std::function< ob::PlannerPtr(const ompl::base::SpaceInformationPtr &si, const std::string &name, const ModelBasedPlanningContextSpecification &spec)> ConfiguredPlannerAllocator
std::function< ConfiguredPlannerAllocator(const std::string &planner_type)> ConfiguredPlannerSelector
std::map< std::string, PlannerConfigurationSettings > PlannerConfigurationMap
Map from PlannerConfigurationSettings.name to PlannerConfigurationSettings.
moveit_msgs::msg::MotionPlanRequest MotionPlanRequest
This namespace includes the central class for representing planning contexts.
Specify the settings for a particular planning algorithm, for a particular group. The Planner plugin ...