46 constexpr
char LOGNAME[] =
"ompl_interface";
52 , robot_model_(robot_model)
54 , context_manager_(robot_model, constraint_sampler_manager_)
55 , use_constraints_approximations_(true)
56 , simplify_solutions_(true)
67 , robot_model_(robot_model)
69 , context_manager_(robot_model, constraint_sampler_manager_)
70 , use_constraints_approximations_(true)
71 , simplify_solutions_(true)
87 if (pconfig.find(group->getName()) == pconfig.end())
90 empty.
name = empty.
group = group->getName();
91 pconfig2[empty.
name] = empty;
95 context_manager_.setPlannerConfigurations(pconfig2);
98 ompl_interface::ModelBasedPlanningContextPtr
102 moveit_msgs::MoveItErrorCodes dummy;
106 ompl_interface::ModelBasedPlanningContextPtr
109 moveit_msgs::MoveItErrorCodes& error_code)
const
111 ModelBasedPlanningContextPtr ctx =
112 context_manager_.getPlanningContext(
planning_scene, req, error_code, nh_, use_constraints_approximations_);
114 configureContext(ctx);
120 context->simplifySolutions(simplify_solutions_);
125 constraint_sampler_manager_loader_ =
126 std::make_shared<constraint_sampler_manager_loader::ConstraintSamplerManagerLoader>(constraint_sampler_manager_);
130 const std::string& group_name,
const std::string& planner_id,
131 const std::map<std::string, std::string>& group_params,
135 if (!nh_.getParam(
"planner_configs/" + planner_id, xml_config))
137 ROS_ERROR_NAMED(
LOGNAME,
"Could not find the planner configuration '%s' on the param server", planner_id.c_str());
143 ROS_ERROR_NAMED(
LOGNAME,
"A planning configuration should be of type XmlRpc Struct type (for configuration '%s')",
148 planner_config.
name = group_name +
"[" + planner_id +
"]";
149 planner_config.
group = group_name;
152 planner_config.
config = group_params;
155 for (std::pair<const std::string, XmlRpc::XmlRpcValue>& element : xml_config)
158 planner_config.
config[element.first] =
static_cast<std::string
>(element.second);
162 planner_config.
config[element.first] = std::to_string(
static_cast<int>(element.second));
164 planner_config.
config[element.first] = std::to_string(
static_cast<bool>(element.second));
176 for (
const std::string& group_name : robot_model_->getJointModelGroupNames())
179 static const std::string KNOWN_GROUP_PARAMS[] = {
"projection_evaluator",
"longest_valid_segment_fraction",
180 "enforce_joint_model_state_space" };
183 std::map<std::string, std::string> specific_group_params;
184 for (
const std::string& k : KNOWN_GROUP_PARAMS)
186 std::string param_name{ group_name };
190 if (nh_.hasParam(param_name))
193 if (nh_.getParam(param_name, value))
196 specific_group_params[k] = value;
201 if (nh_.getParam(param_name, value_d))
209 if (nh_.getParam(param_name, value_i))
211 specific_group_params[k] = std::to_string(value_i);
216 if (nh_.getParam(param_name, value_b))
218 specific_group_params[k] = std::to_string(value_b);
226 std::string default_planner_id;
227 if (nh_.getParam(group_name +
"/default_planner_config", default_planner_id))
229 if (!loadPlannerConfiguration(group_name, default_planner_id, specific_group_params, default_pc))
230 default_planner_id =
"";
233 if (default_planner_id.empty())
235 default_pc.
group = group_name;
236 default_pc.
config = specific_group_params;
237 default_pc.
config[
"type"] =
"geometric::RRTConnect";
240 default_pc.
name = group_name;
241 pconfig[default_pc.
name] = default_pc;
245 if (nh_.getParam(group_name +
"/planner_configs", config_names))
250 "The planner_configs argument of a group configuration "
251 "should be an array of strings (for group '%s')",
256 for (
int j = 0; j < config_names.
size(); ++j)
265 const std::string planner_id =
static_cast<std::string
>(config_names[j]);
268 if (loadPlannerConfiguration(group_name, planner_id, specific_group_params, pc))
269 pconfig[pc.
name] = pc;
274 for (
const std::pair<const std::string, planning_interface::PlannerConfigurationSettings>& config : pconfig)
278 for (
const std::pair<const std::string, std::string>& parameters : config.second.config)
282 setPlannerConfigurations(pconfig);