Skip to content

Commit c07be63

Browse files
rhaschkev4hn
authored andcommitted
Cleanup OMPL's PlanningContextManager's protected API
- Calling the factory_selector lambda causes the returned value to be NULL. There is no value in having this selector function. We could directly pass the correct factory. - MotionPlanRequest isn't actually used.
1 parent 9804c19 commit c07be63

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/planning_context_manager.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ class PlanningContextManager
206206
ConfiguredPlannerSelector getPlannerSelector() const;
207207

208208
protected:
209-
typedef std::function<const ModelBasedStateSpaceFactoryPtr&(const std::string&)> StateSpaceFactoryTypeSelector;
210-
211209
ConfiguredPlannerAllocator plannerSelector(const std::string& planner) const;
212210

213211
void registerDefaultPlanners();
@@ -218,8 +216,7 @@ class PlanningContextManager
218216

219217
/** \brief This is the function that constructs new planning contexts if no previous ones exist that are suitable */
220218
ModelBasedPlanningContextPtr getPlanningContext(const planning_interface::PlannerConfigurationSettings& config,
221-
const StateSpaceFactoryTypeSelector& factory_selector,
222-
const moveit_msgs::MotionPlanRequest& req) const;
219+
const ModelBasedStateSpaceFactoryPtr& factory) const;
223220

224221
const ModelBasedStateSpaceFactoryPtr& getStateSpaceFactory(const std::string& factory_type) const;
225222
const ModelBasedStateSpaceFactoryPtr& getStateSpaceFactory(const std::string& group_name,

moveit_planners/ompl/ompl_interface/src/planning_context_manager.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,8 @@ void ompl_interface::PlanningContextManager::setPlannerConfigurations(
310310
}
311311

312312
ompl_interface::ModelBasedPlanningContextPtr ompl_interface::PlanningContextManager::getPlanningContext(
313-
const planning_interface::PlannerConfigurationSettings& config,
314-
const StateSpaceFactoryTypeSelector& factory_selector, const moveit_msgs::MotionPlanRequest& /*req*/) const
313+
const planning_interface::PlannerConfigurationSettings& config, const ModelBasedStateSpaceFactoryPtr& factory) const
315314
{
316-
const ompl_interface::ModelBasedStateSpaceFactoryPtr& factory = factory_selector(config.group);
317-
318315
// Check for a cached planning context
319316
ModelBasedPlanningContextPtr context;
320317

@@ -461,17 +458,15 @@ ompl_interface::ModelBasedPlanningContextPtr ompl_interface::PlanningContextMana
461458
// However consecutive IK solutions are not checked for proximity at the moment and sometimes happen to be flipped,
462459
// leading to invalid trajectories. This workaround lets the user prevent this problem by forcing rejection sampling
463460
// in JointModelStateSpace.
464-
StateSpaceFactoryTypeSelector factory_selector;
461+
ModelBasedStateSpaceFactoryPtr factory;
465462
auto it = pc->second.config.find("enforce_joint_model_state_space");
466463

467464
if (it != pc->second.config.end() && boost::lexical_cast<bool>(it->second))
468-
factory_selector = [this](const std::string&) {
469-
return getStateSpaceFactory(JointModelStateSpace::PARAMETERIZATION_TYPE);
470-
};
465+
factory = getStateSpaceFactory(JointModelStateSpace::PARAMETERIZATION_TYPE);
471466
else
472-
factory_selector = [this, &req](const std::string& group) { return getStateSpaceFactory(group, req); };
467+
factory = getStateSpaceFactory(pc->second.group, req);
473468

474-
ModelBasedPlanningContextPtr context = getPlanningContext(pc->second, factory_selector, req);
469+
ModelBasedPlanningContextPtr context = getPlanningContext(pc->second, factory);
475470

476471
if (context)
477472
{

0 commit comments

Comments
 (0)