50 , context_manager_(kmodel, constraint_sampler_manager_)
52 , use_constraints_approximations_(true)
53 , simplify_solutions_(true)
55 ROS_INFO(
"Initializing OMPL interface using ROS parameters");
72 ROS_INFO(
"Initializing OMPL interface using specified configuration");
87 const std::vector<const robot_model::JointModelGroup*>& groups =
kmodel_->getJointModelGroups();
88 for (std::size_t i = 0; i < groups.size(); ++i)
90 if (pconfig.find(groups[i]->getName()) == pconfig.end())
93 empty.
name = empty.
group = groups[i]->getName();
94 pconfig2[empty.
name] = empty;
104 moveit_msgs::MoveItErrorCodes dummy;
108 ompl_interface::ModelBasedPlanningContextPtr
111 moveit_msgs::MoveItErrorCodes& error_code)
const 119 ompl_interface::ModelBasedPlanningContextPtr
133 context->setConstraintsApproximations(ConstraintsLibraryPtr());
140 std::stringstream ss;
153 if (
nh_.
getParam(
"constraint_approximations_path", cpath))
158 ROS_WARN(
"ROS param 'constraint_approximations' not found. Unable to save constraint approximations");
165 if (
nh_.
getParam(
"constraint_approximations_path", cpath))
180 const std::string& group_name,
const std::string& planner_id,
181 const std::map<std::string, std::string>& group_params,
185 if (!
nh_.
getParam(
"planner_configs/" + planner_id, xml_config))
187 ROS_ERROR(
"Could not find the planner configuration '%s' on the param server", planner_id.c_str());
193 ROS_ERROR(
"A planning configuration should be of type XmlRpc Struct type (for configuration '%s')",
198 planner_config.
name = group_name +
"[" + planner_id +
"]";
199 planner_config.
group = group_name;
202 planner_config.
config = group_params;
208 planner_config.
config[it->first] = static_cast<std::string>(it->second);
212 planner_config.
config[it->first] = std::to_string(static_cast<int>(it->second));
214 planner_config.
config[it->first] = boost::lexical_cast<std::string>(static_cast<bool>(it->second));
222 const std::vector<std::string>& group_names =
kmodel_->getJointModelGroupNames();
227 for (std::size_t i = 0; i < group_names.size(); ++i)
230 static const std::string KNOWN_GROUP_PARAMS[] = {
"projection_evaluator",
"longest_valid_segment_fraction",
231 "enforce_joint_model_state_space" };
234 std::map<std::string, std::string> specific_group_params;
235 for (std::size_t k = 0; k <
sizeof(KNOWN_GROUP_PARAMS) /
sizeof(std::string); ++k)
237 if (
nh_.
hasParam(group_names[i] +
"/" + KNOWN_GROUP_PARAMS[k]))
240 if (
nh_.
getParam(group_names[i] +
"/" + KNOWN_GROUP_PARAMS[k], value))
243 specific_group_params[KNOWN_GROUP_PARAMS[k]] = value;
248 if (
nh_.
getParam(group_names[i] +
"/" + KNOWN_GROUP_PARAMS[k], value_d))
256 if (
nh_.
getParam(group_names[i] +
"/" + KNOWN_GROUP_PARAMS[k], value_i))
258 specific_group_params[KNOWN_GROUP_PARAMS[k]] = std::to_string(value_i);
263 if (
nh_.
getParam(group_names[i] +
"/" + KNOWN_GROUP_PARAMS[k], value_b))
265 specific_group_params[KNOWN_GROUP_PARAMS[k]] = boost::lexical_cast<std::string>(value_b);
273 std::string default_planner_id;
274 if (
nh_.
getParam(group_names[i] +
"/default_planner_config", default_planner_id))
277 default_planner_id =
"";
279 if (default_planner_id.empty())
281 default_pc.
group = group_names[i];
282 default_pc.
config = specific_group_params;
283 default_pc.
config[
"type"] =
"geometric::RRTConnect";
285 default_pc.
name = group_names[i];
286 pconfig[default_pc.
name] = default_pc;
290 if (
nh_.
getParam(group_names[i] +
"/planner_configs", config_names))
294 ROS_ERROR(
"The planner_configs argument of a group configuration " 295 "should be an array of strings (for group '%s')",
296 group_names[i].c_str());
300 for (
int j = 0; j < config_names.
size(); ++j)
304 ROS_ERROR(
"Planner configuration names must be of type string (for group '%s')", group_names[i].c_str());
307 std::string planner_id =
static_cast<std::string
>(config_names[j]);
311 pconfig[pc.
name] = pc;
316 for (planning_interface::PlannerConfigurationMap::iterator it = pconfig.begin(); it != pconfig.end(); ++it)
319 for (std::map<std::string, std::string>::const_iterator config_it = it->second.config.begin();
320 config_it != it->second.config.end(); ++config_it)
328 ROS_INFO(
"OMPL ROS interface is running.");
#define ROS_DEBUG_STREAM_NAMED(name, args)
ValueStruct::iterator iterator
ModelBasedPlanningContextPtr getPlanningContext(const std::string &config, const std::string &factory_type="") const
bool loadPlannerConfiguration(const std::string &group_name, const std::string &planner_id, const std::map< std::string, std::string > &group_params, planning_interface::PlannerConfigurationSettings &planner_config)
Load planner configurations for specified group into planner_config.
std::map< std::string, PlannerConfigurationSettings > PlannerConfigurationMap
constraint_sampler_manager_loader::ConstraintSamplerManagerLoaderPtr constraint_sampler_manager_loader_
ModelBasedPlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr &planning_scene, const planning_interface::MotionPlanRequest &req) const
void configureContext(const ModelBasedPlanningContextPtr &context) const
std::map< std::string, std::string > config
Type const & getType() const
bool loadConstraintApproximations()
Look up param server 'constraint_approximations' and use its value as the path to load constraint app...
void loadPlannerConfigurations()
Configure the planners.
robot_model::RobotModelConstPtr kmodel_
The ROS node handle.
bool use_constraints_approximations_
void setPlannerConfigurations(const planning_interface::PlannerConfigurationMap &pconfig)
Specify configurations for the planners.
constraint_samplers::ConstraintSamplerManagerPtr constraint_sampler_manager_
ConstraintsLibraryPtr constraints_library_
PlanningContextManager context_manager_
void printStatus()
Print the status of this node.
void loadConstraintSamplers()
Load the additional plugins for sampling constraints.
OMPLInterface(const robot_model::RobotModelConstPtr &kmodel, const ros::NodeHandle &nh=ros::NodeHandle("~"))
Initialize OMPL-based planning for a particular robot model. ROS configuration is read from the speci...
void setPlannerConfigurations(const planning_interface::PlannerConfigurationMap &pconfig)
Specify configurations for the planners.
std::string toString(double d)
moveit_msgs::MotionPlanRequest MotionPlanRequest
bool saveConstraintApproximations()
Look up param server 'constraint_approximations' and use its value as the path to save constraint app...
#define ROS_INFO_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
bool hasParam(const std::string &key) const