44 const constraint_samplers::ConstraintSamplerPtr& cs)
45 : ob::GoalLazySamples(pc->getOMPLSimpleSetup()->getSpaceInformation(),
47 , planning_context_(pc)
48 , kinematic_constraint_set_(ks)
49 , constraint_sampler_(cs)
50 , work_state_(pc->getCompleteInitialRobotState())
51 , invalid_sampled_constraints_(0)
52 , warned_invalid_samples_(false)
57 ROS_DEBUG_NAMED(
"constrained_goal_sampler",
"Constructed a ConstrainedGoalSampler instance at address %p",
this);
62 const robot_state::RobotState& state,
66 return static_cast<const StateValidityChecker*
>(si_->getStateValidityChecker().get())->isValid(new_goal, verbose);
70 robot_state::RobotState
const* state,
71 const robot_model::JointModelGroup* jmg,
72 const double* jpos,
bool verbose)
const 75 robot_state::RobotState solution_state(*state);
76 solution_state.setJointGroupPositions(jmg, jpos);
77 solution_state.update();
87 unsigned int attempts_so_far = gls->samplingAttemptsCount();
90 if (attempts_so_far >= max_attempts)
101 unsigned int max_attempts_div2 = max_attempts / 2;
102 for (
unsigned int a = gls->samplingAttemptsCount(); a < max_attempts && gls->isSampling(); ++a)
105 if (gls->getStateCount() == 0 && a >= max_attempts_div2)
115 robot_state::GroupStateValidityCallbackFn gsvcf =
137 ROS_WARN_NAMED(
"constrained_goal_sampler",
"More than 80%% of the sampled goal states " 138 "fail to satisfy the constraints imposed on the goal sampler. " 139 "Is the constrained sampler working correctly?");
147 if (static_cast<const StateValidityChecker*>(si_->getStateValidityChecker().get())->isValid(new_goal, verbose))
bool stateValidityCallback(ompl::base::State *new_goal, robot_state::RobotState const *state, const robot_model::JointModelGroup *, const double *, bool verbose=false) const
bool warned_invalid_samples_
ompl::base::StateSamplerPtr default_sampler_
const ModelBasedPlanningContext * planning_context_
#define ROS_WARN_NAMED(name,...)
const og::SimpleSetupPtr & getOMPLSimpleSetup() const
unsigned int getMaximumGoalSamples() const
unsigned int getMaximumGoalSamplingAttempts() const
#define ROS_DEBUG_NAMED(name,...)
robot_state::RobotState work_state_
unsigned int invalid_sampled_constraints_
unsigned int getMaximumStateSamplingAttempts() const
ConstrainedGoalSampler(const ModelBasedPlanningContext *pc, const kinematic_constraints::KinematicConstraintSetPtr &ks, const constraint_samplers::ConstraintSamplerPtr &cs=constraint_samplers::ConstraintSamplerPtr())
constraint_samplers::ConstraintSamplerPtr constraint_sampler_
bool checkStateValidity(ompl::base::State *new_goal, const robot_state::RobotState &state, bool verbose=false) const
An interface for a OMPL state validity checker.
bool sampleUsingConstraintSampler(const ompl::base::GoalLazySamples *gls, ompl::base::State *new_goal)
unsigned int verbose_display_
kinematic_constraints::KinematicConstraintSetPtr kinematic_constraint_set_
const ModelBasedStateSpacePtr & getOMPLStateSpace() const