Robowflex  v0.1
Making MoveIt Easy
robowflex::darts::JointRegionGoal Class Reference

A joint space goal volume. More...

#include <planning.h>

+ Inheritance diagram for robowflex::darts::JointRegionGoal:

Public Member Functions

 JointRegionGoal (const PlanBuilder &builder, const Eigen::Ref< const Eigen::VectorXd > &state, double tolerance=0.)
 
 JointRegionGoal (const PlanBuilder &builder, const Eigen::Ref< const Eigen::VectorXd > &lower, const Eigen::Ref< const Eigen::VectorXd > &upper)
 
 ~JointRegionGoal ()
 
void sampleGoal (ompl::base::State *state) const override
 
unsigned int maxSampleCount () const override
 
double distanceGoal (const ompl::base::State *state) const override
 
- Public Member Functions inherited from robowflex::darts::ConstraintExtractor
 ConstraintExtractor ()=default
 Constructor. More...
 
 ConstraintExtractor (const ompl::base::SpaceInformationPtr &si)
 Constructor. More...
 
const StateSpacegetSpace () const
 Gets the underlying state space from the space information. More...
 
void setSpaceInformation (const ompl::base::SpaceInformationPtr &si)
 Set space information used for constraint extraction. More...
 
StateSpace::StateTypetoState (ompl::base::State *state) const
 Extract underlying state from a base state. More...
 
const StateSpace::StateTypetoStateConst (const ompl::base::State *state) const
 Extract underlying state from a base state. More...
 
StateSpace::StateTypefromConstrainedState (ompl::base::State *state) const
 Access the underlying state from a constrained OMPL state. More...
 
const StateSpace::StateTypefromConstrainedStateConst (const ompl::base::State *state) const
 Access the underlying state from a constrained OMPL state. More...
 
StateSpace::StateTypefromUnconstrainedState (ompl::base::State *state) const
 Access the underlying state from an unconstrained OMPL state. More...
 
const StateSpace::StateTypefromUnconstrainedStateConst (const ompl::base::State *state) const
 Access the underlying state from an unconstrained OMPL state. More...
 

Private Attributes

ompl::RNG rng_
 
ompl::base::State * lower_
 
ompl::base::State * upper_
 

Detailed Description

A joint space goal volume.

Definition at line 191 of file robowflex_dart/include/robowflex_dart/planning.h.

Constructor & Destructor Documentation

◆ JointRegionGoal() [1/2]

JointRegionGoal::JointRegionGoal ( const PlanBuilder builder,
const Eigen::Ref< const Eigen::VectorXd > &  state,
double  tolerance = 0. 
)

JointRegionGoal

Definition at line 168 of file robowflex_dart/src/planning.cpp.

170  : JointRegionGoal(builder, //
171  state - Eigen::VectorXd::Constant(state.size(), tolerance), //
172  state + Eigen::VectorXd::Constant(state.size(), tolerance))
173 {
174 }
JointRegionGoal(const PlanBuilder &builder, const Eigen::Ref< const Eigen::VectorXd > &state, double tolerance=0.)

◆ JointRegionGoal() [2/2]

JointRegionGoal::JointRegionGoal ( const PlanBuilder builder,
const Eigen::Ref< const Eigen::VectorXd > &  lower,
const Eigen::Ref< const Eigen::VectorXd > &  upper 
)

Definition at line 176 of file robowflex_dart/src/planning.cpp.

178  : ompl::base::GoalSampleableRegion(builder.info)
179  , ConstraintExtractor(builder.info)
180  , lower_(si_->allocState())
181  , upper_(si_->allocState())
182 {
183  if (lower.size() != upper.size())
184  throw std::runtime_error("Bound size mismatch!");
185 
186  if (builder.space->getDimension() != lower.size())
187  throw std::runtime_error("Bound size mismatch!");
188 
189  toState(lower_)->data = lower;
190  toState(upper_)->data = upper;
191 }
StateSpace::StateType * toState(ompl::base::State *state) const
Extract underlying state from a base state.
ConstraintExtractor()=default
Constructor.
ompl::base::SpaceInformationPtr info
Actual Space Information.
ompl::base::StateSpacePtr space
Actual OMPL State Space (might be constrained).
Eigen::VectorXd data
Vector for configuration.
Definition: space.h:76

◆ ~JointRegionGoal()

JointRegionGoal::~JointRegionGoal ( )

Definition at line 193 of file robowflex_dart/src/planning.cpp.

194 {
195  si_->freeState(lower_);
196  si_->freeState(upper_);
197 }

Member Function Documentation

◆ distanceGoal()

double JointRegionGoal::distanceGoal ( const ompl::base::State *  state) const
override

Definition at line 214 of file robowflex_dart/src/planning.cpp.

215 {
216  const auto &s = toStateConst(state)->data;
217  const auto &l = toStateConst(lower_)->data;
218  const auto &u = toStateConst(upper_)->data;
219 
220  const auto &ss = std::dynamic_pointer_cast<StateSpace>(si_->getStateSpace());
221 
222  double d = 0.;
223  for (int i = 0; i < l.size(); ++i)
224  {
225  const auto &joint = ss->getJoint(i);
226  const auto &sv = joint->getSpaceVarsConst(s);
227  const auto &lv = joint->getSpaceVarsConst(l);
228  const auto &uv = joint->getSpaceVarsConst(u);
229 
230  if (sv[0] < lv[0])
231  d += joint->distance(sv, lv);
232  if (sv[0] > uv[0])
233  d += joint->distance(sv, uv);
234  }
235 
236  return d;
237 }
const StateSpace::StateType * toStateConst(const ompl::base::State *state) const
Extract underlying state from a base state.

◆ maxSampleCount()

unsigned int JointRegionGoal::maxSampleCount ( ) const
override

Definition at line 209 of file robowflex_dart/src/planning.cpp.

210 {
212 }
T max(T... args)

◆ sampleGoal()

void JointRegionGoal::sampleGoal ( ompl::base::State *  state) const
override

Definition at line 199 of file robowflex_dart/src/planning.cpp.

200 {
201  auto &s = toState(state)->data;
202  const auto &l = toStateConst(lower_)->data;
203  const auto &u = toStateConst(upper_)->data;
204 
205  for (int i = 0; i < l.size(); ++i)
206  s[i] = rng_.uniformReal(l[i], u[i]);
207 }

Member Data Documentation

◆ lower_

ompl::base::State* robowflex::darts::JointRegionGoal::lower_
private

◆ rng_

ompl::RNG robowflex::darts::JointRegionGoal::rng_
mutableprivate

◆ upper_

ompl::base::State* robowflex::darts::JointRegionGoal::upper_
private

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