moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
constraint_samplers::JointConstraintSampler Class Reference

JointConstraintSampler is a class that allows the sampling of joints in a particular group of the robot, subject to a set of individual joint constraints. More...

#include <default_constraint_samplers.h>

Inheritance diagram for constraint_samplers::JointConstraintSampler:
Inheritance graph
[legend]
Collaboration diagram for constraint_samplers::JointConstraintSampler:
Collaboration graph
[legend]

Classes

struct  JointInfo
 An internal structure used for maintaining constraints on a particular joint. More...
 

Public Member Functions

 JointConstraintSampler (const planning_scene::PlanningSceneConstPtr &scene, const std::string &group_name)
 
 JointConstraintSampler (const planning_scene::PlanningSceneConstPtr &scene, const std::string &group_name, unsigned int seed)
 
bool configure (const moveit_msgs::msg::Constraints &constr) override
 Configures a joint constraint given a Constraints message.
 
bool configure (const std::vector< kinematic_constraints::JointConstraint > &jc)
 Configures a joint constraint given a vector of constraints.
 
bool sample (moveit::core::RobotState &state, const moveit::core::RobotState &ks, unsigned int max_attempts) override
 Samples given the constraints, populating state. This function allows the parameter max_attempts to be set.
 
std::size_t getConstrainedJointCount () const
 Gets the number of constrained joints - joints that have an additional bound beyond the joint limits.
 
std::size_t getUnconstrainedJointCount () const
 Gets the number of unconstrained joints - joint that have no additional bound beyond the joint limits.
 
const std::string & getName () const override
 Get the name of the constraint sampler, for debugging purposes should be in CamelCase format.
 
- Public Member Functions inherited from constraint_samplers::ConstraintSampler
 ConstraintSampler (const planning_scene::PlanningSceneConstPtr &scene, const std::string &group_name)
 Constructor.
 
virtual ~ConstraintSampler ()
 
const std::string & getGroupName () const
 Gets the group name set in the constructor.
 
const moveit::core::JointModelGroupgetJointModelGroup () const
 Gets the joint model group.
 
const planning_scene::PlanningSceneConstPtr & getPlanningScene () const
 Gets the planning scene.
 
const std::vector< std::string > & getFrameDependency () const
 Return the names of the mobile frames whose pose is needed when sample() is called.
 
const moveit::core::GroupStateValidityCallbackFngetGroupStateValidityCallback () const
 Gets the callback used to determine state validity during sampling. The sampler will attempt to satisfy this constraint if possible, but there is no guarantee.
 
void setGroupStateValidityCallback (const moveit::core::GroupStateValidityCallbackFn &callback)
 Sets the callback used to determine the state validity during sampling. The sampler will attempt to satisfy this constraint if possible, but there is no guarantee.
 
bool sample (moveit::core::RobotState &state)
 Samples given the constraints, populating state. The value DEFAULT_MAX_SAMPLING_ATTEMPTS will be passed in as the maximum number of attempts to make to take a sample.
 
bool sample (moveit::core::RobotState &state, unsigned int max_attempts)
 Samples given the constraints, populating state. This function allows the parameter max_attempts to be set.
 
bool sample (moveit::core::RobotState &state, const moveit::core::RobotState &reference_state)
 Samples given the constraints, populating state. The value DEFAULT_MAX_SAMPLING_ATTEMPTS will be passed in as the maximum number of attempts to make to take a sample.
 
bool isValid () const
 Returns whether or not the constraint sampler is valid or not. To be valid, the joint model group must be available in the kinematic model and configure() must have successfully been called.
 
bool getVerbose () const
 Check if the sampler is set to verbose mode.
 
virtual void setVerbose (bool verbose)
 Enable/disable verbose mode for sampler.
 

Protected Member Functions

void clear () override
 Clears all data from the constraint.
 

Protected Attributes

random_numbers::RandomNumberGenerator random_number_generator_
 Random number generator used to sample.
 
std::vector< JointInfobounds_
 The bounds for any joint with bounds that are more restrictive than the joint limits.
 
std::vector< const moveit::core::JointModel * > unbounded_
 The joints that are not bounded except by joint limits.
 
std::vector< unsigned int > uindex_
 The index of the unbounded joints in the joint state vector.
 
std::vector< double > values_
 Values associated with this group to avoid continuously reallocating.
 
- Protected Attributes inherited from constraint_samplers::ConstraintSampler
bool is_valid_
 Holds the value for validity.
 
planning_scene::PlanningSceneConstPtr scene_
 Holds the planning scene.
 
const moveit::core::JointModelGroup *const jmg_
 Holds the joint model group associated with this constraint.
 
std::vector< std::string > frame_depends_
 Holds the set of frames that must exist in the reference state to allow samples to be drawn.
 
moveit::core::GroupStateValidityCallbackFn group_state_validity_callback_
 Holds the callback for state validity.
 
bool verbose_
 True if verbosity is on.
 

Additional Inherited Members

- Static Public Attributes inherited from constraint_samplers::ConstraintSampler
static const unsigned int DEFAULT_MAX_SAMPLING_ATTEMPTS = 2
 The default value associated with a sampling request. By default if a valid sample cannot be produced in this many attempts, it returns with no sample.
 

Detailed Description

JointConstraintSampler is a class that allows the sampling of joints in a particular group of the robot, subject to a set of individual joint constraints.

The set of individual joint constraint reduce the allowable bounds used in the sampling. Unconstrained values will be sampled within their limits.

Definition at line 59 of file default_constraint_samplers.h.

Constructor & Destructor Documentation

◆ JointConstraintSampler() [1/2]

constraint_samplers::JointConstraintSampler::JointConstraintSampler ( const planning_scene::PlanningSceneConstPtr &  scene,
const std::string &  group_name 
)
inline

Constructor

Parameters
[in]sceneThe planning scene used to check the constraint
[in]group_nameThe group name associated with the constraint. Will be invalid if no group name is passed in or the joint model group cannot be found in the kinematic model

Definition at line 72 of file default_constraint_samplers.h.

◆ JointConstraintSampler() [2/2]

constraint_samplers::JointConstraintSampler::JointConstraintSampler ( const planning_scene::PlanningSceneConstPtr &  scene,
const std::string &  group_name,
unsigned int  seed 
)
inline

Constructor

Parameters
[in]sceneThe planning scene used to check the constraint
[in]group_nameThe group name associated with the constraint. Will be invalid if no group name is passed in or the joint model group cannot be found in the kinematic model
[in]seedThe rng seed to be used

Definition at line 89 of file default_constraint_samplers.h.

Member Function Documentation

◆ clear()

void constraint_samplers::JointConstraintSampler::clear ( )
overrideprotectedvirtual

Clears all data from the constraint.

Reimplemented from constraint_samplers::ConstraintSampler.

Definition at line 199 of file default_constraint_samplers.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ configure() [1/2]

bool constraint_samplers::JointConstraintSampler::configure ( const moveit_msgs::msg::Constraints &  constr)
overridevirtual

Configures a joint constraint given a Constraints message.

If more than one constraint for a particular joint is specified, the most restrictive set of bounds will be used (highest minimum value, lowest maximum value). For the configuration to be successful, the following condition must be met, in addition to the conditions specified in configure(const std::vector<kinematic_constraints::JointConstraint> &jc) :

  • The Constraints message must contain one or more valid joint constraints (where validity is judged by the ability to configure a JointConstraint)
Parameters
[in]constrThe message containing the constraints
Returns
True if the conditions are met, otherwise false

Implements constraint_samplers::ConstraintSampler.

Definition at line 54 of file default_constraint_samplers.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ configure() [2/2]

bool constraint_samplers::JointConstraintSampler::configure ( const std::vector< kinematic_constraints::JointConstraint > &  jc)

Configures a joint constraint given a vector of constraints.

If more than one constraint for a particular joint is specified, the most restrictive set of bounds will be used (highest minimum value, lowest_maximum value. For the configuration to be successful, the following conditions must be met:

  • The vector must contain one or more valid, enabled joint constraints
  • At least one constraint must reference a joint in the indicated group. If no additional bounds exist for this group, then RobotState::setToRandomPositions() can be used to generate a sample independently from the constraint_samplers infrastructure.
  • The constraints must allow a sampleable region for all joints, where the most restrictive minimum bound is less than the most restrictive maximum bound
Parameters
[in]jcThe vector of joint constraints
Returns
True if the conditions are met, otherwise false

Definition at line 68 of file default_constraint_samplers.cpp.

Here is the call graph for this function:

◆ getConstrainedJointCount()

std::size_t constraint_samplers::JointConstraintSampler::getConstrainedJointCount ( ) const
inline

Gets the number of constrained joints - joints that have an additional bound beyond the joint limits.

Returns
The number of constrained joints.

Definition at line 150 of file default_constraint_samplers.h.

Here is the caller graph for this function:

◆ getName()

const std::string & constraint_samplers::JointConstraintSampler::getName ( ) const
inlineoverridevirtual

Get the name of the constraint sampler, for debugging purposes should be in CamelCase format.

Returns
string of name

Implements constraint_samplers::ConstraintSampler.

Definition at line 171 of file default_constraint_samplers.h.

◆ getUnconstrainedJointCount()

std::size_t constraint_samplers::JointConstraintSampler::getUnconstrainedJointCount ( ) const
inline

Gets the number of unconstrained joints - joint that have no additional bound beyond the joint limits.

Returns
The number of unconstrained joints.

Definition at line 161 of file default_constraint_samplers.h.

Here is the caller graph for this function:

◆ sample()

bool constraint_samplers::JointConstraintSampler::sample ( moveit::core::RobotState state,
const moveit::core::RobotState reference_state,
unsigned int  max_attempts 
)
overridevirtual

Samples given the constraints, populating state. This function allows the parameter max_attempts to be set.

Parameters
[out]stateThe state into which the values will be placed. Only values for the group are written.
[in]reference_stateReference state that will be used to do transforms or perform other actions
[in]max_attemptsThe maximum number of times to attempt to draw a sample. If no sample has been drawn in this number of attempts, false will be returned.
Returns
True if a sample was successfully taken, false otherwise

Implements constraint_samplers::ConstraintSampler.

Definition at line 169 of file default_constraint_samplers.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bounds_

std::vector<JointInfo> constraint_samplers::JointConstraintSampler::bounds_
protected

The bounds for any joint with bounds that are more restrictive than the joint limits.

Definition at line 215 of file default_constraint_samplers.h.

◆ random_number_generator_

random_numbers::RandomNumberGenerator constraint_samplers::JointConstraintSampler::random_number_generator_
protected

Random number generator used to sample.

Definition at line 214 of file default_constraint_samplers.h.

◆ uindex_

std::vector<unsigned int> constraint_samplers::JointConstraintSampler::uindex_
protected

The index of the unbounded joints in the joint state vector.

Definition at line 220 of file default_constraint_samplers.h.

◆ unbounded_

std::vector<const moveit::core::JointModel*> constraint_samplers::JointConstraintSampler::unbounded_
protected

The joints that are not bounded except by joint limits.

Definition at line 218 of file default_constraint_samplers.h.

◆ values_

std::vector<double> constraint_samplers::JointConstraintSampler::values_
protected

Values associated with this group to avoid continuously reallocating.

Definition at line 221 of file default_constraint_samplers.h.


The documentation for this class was generated from the following files: