52 : ompl::base::StateSpace(), spec_(std::move(spec))
63 RCLCPP_ERROR(
getLogger(),
"Joint group '%s' has incorrect bounds specified. Using the default bounds instead.",
84 params_.declareParam<
double>(
85 "tag_snap_to_segment", [
this](
double tag_snap_to_segment) {
setTagSnapToSegment(tag_snap_to_segment); },
98 if (snap < 0.0 || snap > 1.0)
101 "Snap to segment for tags is a ratio. It's value must be between 0.0 and 1.0. "
102 "Value remains as previously set (%lf)",
140 *
reinterpret_cast<int*
>(serialization) = state->as<
StateType>()->
tag;
146 state->as<
StateType>()->tag = *
reinterpret_cast<const int*
>(serialization);
154 d += i->getStateSpaceDimension();
170 m *= bound.max_position_ - bound.min_position_;
193 std::numeric_limits<double>::epsilon())
207 std::numeric_limits<double>::epsilon());
211 ompl::base::State* state)
const
214 state->as<
StateType>()->clearKnownInformation();
242 return state->as<
StateType>()->values + index;
271 class DefaultStateSampler :
public ompl::base::StateSampler
276 : ompl::base::StateSampler(space), joint_model_group_(group), joint_bounds_(joint_bounds)
280 void sampleUniform(ompl::base::State* state)
override
282 joint_model_group_->getVariableRandomPositions(moveit_rng_, state->as<
StateType>()->
values, *joint_bounds_);
283 state->as<
StateType>()->clearKnownInformation();
286 void sampleUniformNear(ompl::base::State* state,
const ompl::base::State* near,
const double distance)
override
288 joint_model_group_->getVariableRandomPositionsNearBy(moveit_rng_, state->as<
StateType>()->
values, *joint_bounds_,
290 state->as<
StateType>()->clearKnownInformation();
293 void sampleGaussian(ompl::base::State* state,
const ompl::base::State* mean,
const double stdDev)
override
295 sampleUniformNear(state, mean, rng_.gaussian(0.0, stdDev));
299 random_numbers::RandomNumberGenerator moveit_rng_;
304 return ompl::base::StateSamplerPtr(
static_cast<ompl::base::StateSampler*
>(
310 out <<
"ModelBasedStateSpace '" << getName() <<
"' at " <<
this <<
'\n';
317 out << j->getName() <<
" = ";
319 const int vc = j->getVariableCount();
320 for (
int i = 0; i < vc; ++i)
326 out <<
"* start state \n";
328 out <<
"* goal state \n";
333 out <<
"* valid state \n";
337 out <<
"* invalid state \n";
340 out <<
"Tag: " << state->as<
StateType>()->tag <<
'\n';
353 state->as<
StateType>()->clearKnownInformation();
358 int ompl_state_joint_index)
const
366 state->as<
StateType>()->clearKnownInformation();
const std::vector< const JointModel * > & getActiveJointModels() const
Get the active joints in this group (that have controllable DOF). This does not include mimic joints.
const std::string & getName() const
Get the name of the joint group.
double distance(const double *state1, const double *state2) const
bool enforcePositionBounds(double *state) const
void interpolate(const double *from, const double *to, double t, double *state) const
bool satisfiesPositionBounds(const double *state, double margin=0.0) const
const JointBoundsVector & getActiveJointModelsBounds() const
Get the bounds for all the active joints.
unsigned int getVariableCount() const
Get the number of variables that describe this joint group. This includes variables necessary for mim...
double getMaximumExtent() const
int getVariableGroupIndex(const std::string &variable) const
Get the index of a variable within the group. Return -1 on error.
A joint from the robot. Models the transform that this joint applies in the kinematic chain....
std::vector< VariableBounds > Bounds
The datatype for the joint bounds.
size_t getFirstVariableIndex() const
Get the index of this joint's first variable within the full robot state.
std::size_t getVariableCount() const
Get the number of variables that describe this joint.
Representation of a robot's state. This includes position, velocity, acceleration and effort.
void setJointGroupPositions(const std::string &joint_group_name, const double *gstate)
Given positions for the variables that make up a group, in the order found in the group (including va...
void copyJointGroupPositions(const std::string &joint_group_name, std::vector< double > &gstate) const
For a given group, copy the position values of the variables that make up the group into another loca...
double * getVariablePositions()
Get a raw pointer to the positions of the variables stored in this state. Use carefully....
void update(bool force=false)
Update all transforms.
bool isValidityKnown() const
bool isStartState() const
bool isMarkedValid() const
double tag_snap_to_segment_
double tag_snap_to_segment_complement_
unsigned int getDimension() const override
bool satisfiesBounds(const ompl::base::State *state) const override
double getMeasure() const override
virtual void copyJointToOMPLState(ompl::base::State *state, const moveit::core::RobotState &robot_state, const moveit::core::JointModel *joint_model, int ompl_state_joint_index) const
Copy a single joint's values (which might have multiple variables) from a MoveIt robot_state to an OM...
bool equalStates(const ompl::base::State *state1, const ompl::base::State *state2) const override
void serialize(void *serialization, const ompl::base::State *state) const override
double * getValueAddressAtIndex(ompl::base::State *state, const unsigned int index) const override
size_t state_values_size_
DistanceFunction distance_function_
double getMaximumExtent() const override
std::vector< const moveit::core::JointModel * > joint_model_vector_
void deserialize(ompl::base::State *state, const void *serialization) const override
std::vector< moveit::core::JointModel::Bounds > joint_bounds_storage_
ModelBasedStateSpaceSpecification spec_
unsigned int getSerializationLength() const override
ompl::base::State * allocState() const override
virtual void setPlanningVolume(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)
Set the planning volume for the possible SE2 and/or SE3 components of the state space.
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override
InterpolationFunction interpolation_function_
virtual void copyToRobotState(moveit::core::RobotState &rstate, const ompl::base::State *state) const
Copy the data from an OMPL state to a set of joint states.
double getTagSnapToSegment() const
void setTagSnapToSegment(double snap)
void interpolate(const ompl::base::State *from, const ompl::base::State *to, const double t, ompl::base::State *state) const override
void printState(const ompl::base::State *state, std::ostream &out) const override
ModelBasedStateSpace(ModelBasedStateSpaceSpecification spec)
void freeState(ompl::base::State *state) const override
void copyState(ompl::base::State *destination, const ompl::base::State *source) const override
virtual void copyToOMPLState(ompl::base::State *state, const moveit::core::RobotState &rstate) const
Copy the data from a set of joint states to an OMPL state.
unsigned int variable_count_
~ModelBasedStateSpace() override
void printSettings(std::ostream &out) const override
void enforceBounds(ompl::base::State *state) const override
double distance(const ompl::base::State *state1, const ompl::base::State *state2) const override
rclcpp::Logger getLogger()
std::vector< const JointModel::Bounds * > JointBoundsVector
rclcpp::Logger getLogger(const std::string &name)
Creates a namespaced logger.
The MoveIt interface to OMPL.
moveit::core::JointBoundsVector joint_bounds_
const moveit::core::JointModelGroup * joint_model_group_