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

A sampleable goal region for OMPL for a set of TSRs. Samples goals in a separate thread using a clone of the world. More...

#include <planning.h>

+ Inheritance diagram for robowflex::darts::TSRGoal:

Public Member Functions

bool sample (const ompl::base::GoalLazySamples *gls, ompl::base::State *state)
 Sampling routine. Generates IK samples from the TSR goal. More...
 
double distanceGoal (const ompl::base::State *state) const override
 Distance to the goal. More...
 
TSRSetPtr getTSRSet ()
 Get the TSR set of this goal region. More...
 
Constructors.
 TSRGoal (const ompl::base::SpaceInformationPtr &si, const WorldPtr &world, const std::vector< TSRPtr > &tsrs)
 Constructor. More...
 
 TSRGoal (const ompl::base::SpaceInformationPtr &si, const WorldPtr &world, const TSRPtr tsr)
 Constructor. More...
 
 TSRGoal (const PlanBuilder &builder, TSRPtr tsr)
 Constructor. More...
 
 TSRGoal (const PlanBuilder &builder, const std::vector< TSRPtr > &tsrs)
 Constructor. More...
 
 ~TSRGoal ()
 Destructor. Stops sampling thread. More...
 
- 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...
 

Public Attributes

struct {
   bool   use_gradient {false}
 Use gradient-based TSR solver. More...
 
   std::size_t   max_samples {10}
 Maximum samples. More...
 
options
 Public options. More...
 

Private Attributes

WorldPtr world_
 World used. More...
 
TSRSetPtr tsr_
 TSR set to sample from. More...
 
ompl::base::StateSamplerPtr sampler_
 State sampler. More...
 

Detailed Description

A sampleable goal region for OMPL for a set of TSRs. Samples goals in a separate thread using a clone of the world.

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

Constructor & Destructor Documentation

◆ TSRGoal() [1/4]

TSRGoal::TSRGoal ( const ompl::base::SpaceInformationPtr &  si,
const WorldPtr world,
const std::vector< TSRPtr > &  tsrs 
)

Constructor.

Parameters
[in]siSpace information.
[in]worldWorld to use.
[in]tsrsTSRs to sample.

TSRGoal

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

84  : ompl::base::GoalLazySamples(
85  si, std::bind(&TSRGoal::sample, this, std::placeholders::_1, std::placeholders::_2), false, 1e-3)
87  , world_(world->clone())
88  , tsr_(std::make_shared<TSRSet>(world_, tsrs))
89  // Have to allocate our own sampler from scratch since the constrained sampler might use the underlying
90  // world used by the planner (e.g., in project)
91  , sampler_(std::make_shared<StateSpace::StateSampler>(getSpace()))
92 {
93  tsr_->useWorldIndices(getSpace()->getIndices());
94  tsr_->setWorldIndices(getSpace()->getIndices());
95 
96  tsr_->setWorldLowerLimits(getSpace()->getLowerBound());
97  tsr_->setWorldUpperLimits(getSpace()->getUpperBound());
98 
99  tsr_->initialize();
100 }
T bind(T... args)
const StateSpace * getSpace() const
Gets the underlying state space from the space information.
ConstraintExtractor()=default
Constructor.
ompl::base::StateSamplerPtr sampler_
State sampler.
bool sample(const ompl::base::GoalLazySamples *gls, ompl::base::State *state)
Sampling routine. Generates IK samples from the TSR goal.

◆ TSRGoal() [2/4]

TSRGoal::TSRGoal ( const ompl::base::SpaceInformationPtr &  si,
const WorldPtr world,
const TSRPtr  tsr 
)

Constructor.

Parameters
[in]siSpace information.
[in]worldWorld to use.
[in]tsrTSR to sample.

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

103  : TSRGoal(si, world, std::vector<TSRPtr>{tsr})
104 {
105 }
TSRGoal(const ompl::base::SpaceInformationPtr &si, const WorldPtr &world, const std::vector< TSRPtr > &tsrs)
Constructor.

◆ TSRGoal() [3/4]

TSRGoal::TSRGoal ( const PlanBuilder builder,
TSRPtr  tsr 
)

Constructor.

Parameters
[in]builderPlan builder to use as base for goal.
[in]tsrTSR to sample.

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

108  : TSRGoal(builder, std::vector<TSRPtr>{std::move(tsr)})
109 {
110 }
T move(T... args)

◆ TSRGoal() [4/4]

TSRGoal::TSRGoal ( const PlanBuilder builder,
const std::vector< TSRPtr > &  tsrs 
)

Constructor.

Parameters
[in]builderPlan builder to use as base for goal.
[in]tsrsTSRs to sample.

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

113  : TSRGoal(builder.info, builder.world, [&] {
114  std::vector<TSRPtr> temp = builder.path_constraints;
115  temp.insert(temp.end(), tsrs.begin(), tsrs.end());
116  return temp;
117  }())
118 {
119 }
ompl::base::SpaceInformationPtr info
Actual Space Information.

◆ ~TSRGoal()

TSRGoal::~TSRGoal ( )

Destructor. Stops sampling thread.

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

122 {
123  stopSampling();
124 }

Member Function Documentation

◆ distanceGoal()

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

Distance to the goal.

Parameters
[in]stateState to measure.

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

153 {
154  auto &&as = toStateConst(state);
155  auto &&x = Eigen::Map<const Eigen::VectorXd>(as->values, si_->getStateDimension());
156  return tsr_->distanceWorldState(x);
157 }
const StateSpace::StateType * toStateConst(const ompl::base::State *state) const
Extract underlying state from a base state.

◆ getTSRSet()

TSRSetPtr TSRGoal::getTSRSet ( )

Get the TSR set of this goal region.

Returns
The TSR set.

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

160 {
161  return tsr_;
162 }

◆ sample()

bool TSRGoal::sample ( const ompl::base::GoalLazySamples *  gls,
ompl::base::State *  state 
)

Sampling routine. Generates IK samples from the TSR goal.

Parameters
[in]glsThis class.
[in]stateState to sample.

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

127 {
128  if (getStateCount() >= options.max_samples)
129  return false;
130 
131  bool success = false;
132  while (not terminateSamplingThread_ and not success)
133  {
134  auto &&as = toState(state);
135  sampler_->sampleUniform(as);
136 
137  auto &&x = Eigen::Map<Eigen::VectorXd>(as->values, si_->getStateDimension());
138 
139  if (tsr_->numTSRs() == 1 or not options.use_gradient)
140  success = tsr_->solveWorldState(x);
141 
142  else if (options.use_gradient)
143  success = tsr_->solveGradientWorldState(x);
144 
145  success &= si_->satisfiesBounds(state);
146  si_->enforceBounds(state);
147  }
148 
149  return true;
150 }
StateSpace::StateType * toState(ompl::base::State *state) const
Extract underlying state from a base state.
struct robowflex::darts::TSRGoal::@0 options
Public options.

Member Data Documentation

◆ max_samples

std::size_t robowflex::darts::TSRGoal::max_samples {10}

Maximum samples.

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

◆ 

struct { ... } robowflex::darts::TSRGoal::options

Public options.

◆ sampler_

ompl::base::StateSamplerPtr robowflex::darts::TSRGoal::sampler_
private

State sampler.

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

◆ tsr_

TSRSetPtr robowflex::darts::TSRGoal::tsr_
private

TSR set to sample from.

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

◆ use_gradient

bool robowflex::darts::TSRGoal::use_gradient {false}

Use gradient-based TSR solver.

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

◆ world_

WorldPtr robowflex::darts::TSRGoal::world_
private

World used.

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


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