All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PathLengthDirectInfSampler.cpp
58 PathLengthDirectInfSampler::PathLengthDirectInfSampler(const ProblemDefinitionPtr probDefn, unsigned int maxNumberCalls)
68 // The foci of the PHSs as a std::vector of states. Goals must be nonconst, as we need to allocate them (unfortunately):
74 throw Exception("PathLengthDirectInfSampler: The direct path-length informed sampler currently only supports goals that can be cast to a sampleable goal region (i.e., are countable sets).");
86 throw Exception("PathLengthDirectInfSampler: There must be at least 1 start and and 1 goal state when the informed sampler is created.");
100 throw Exception("PathLengthDirectInfSampler only supports RealVector, SE2 and SE3 StateSpaces.");
106 if (InformedSampler::space_->getType() == STATE_SPACE_SE2 || InformedSampler::space_->getType() == STATE_SPACE_SE3)
116 throw Exception("The provided compound StateSpace is SE(2) or SE(3) but does not have exactly 2 subspaces.");
120 for (unsigned int idx = 0u; idx < InformedSampler::space_->as<CompoundStateSpace>()->getSubspaceCount(); ++idx)
138 throw Exception("The provided compound StateSpace is SE(2) or SE(3) but contains a subspace that is not R^2, R^3, SO(2), or SO(3).");
144 throw Exception("PathLengthDirectInfSampler only supports RealVector, SE2 and SE3 statespaces.");
168 informedSubSpace_ = InformedSampler::space_->as<CompoundStateSpace>()->getSubspace(informedIdx_);
171 uninformedSubSpace_ = InformedSampler::space_->as<CompoundStateSpace>()->getSubspace(uninformedIdx_);
210 listPhsPtrs_.push_back(std::make_shared<ProlateHyperspheroid>(informedSubSpace_->getDimension(), &startFocusVector[0], &goalFocusVector[0]));
223 OMPL_WARN("PathLengthDirectInfSampler: Rejection sampling is used in order to maintain uniform density in the presence of overlapping informed subsets. At some number of independent subsets, this will become prohibitively expensive. Current number of independent subsets: %d", listPhsPtrs_.size());
247 bool PathLengthDirectInfSampler::sampleUniform(State *statePtr, const Cost &minCost, const Cost &maxCost)
250 // Since volume in a sphere/spheroid is proportionately concentrated near the surface, this isn't horribly inefficient, though a direct method would be better
272 foundSample = InformedSampler::opt_->isCostEquivalentTo(minCost, sampledCost) || InformedSampler::opt_->isCostBetterThan(minCost, sampledCost);
296 // The informed measure is then the sum of the measure of the individual PHSs for the given cost:
297 for (std::list<ompl::ProlateHyperspheroidPtr>::const_iterator phsIter = listPhsPtrs_.begin(); phsIter != listPhsPtrs_.end(); ++phsIter)
299 //It is nonsensical for a PHS to have a transverse diameter less than the distance between its foci, so skip those that do
328 for (std::list<ompl::ProlateHyperspheroidPtr>::const_iterator phsIter = listPhsPtrs_.begin(); phsIter != listPhsPtrs_.end(); ++phsIter)
331 minCost = InformedSampler::opt_->betterCost(minCost, Cost((*phsIter)->getPathLength(&rawData[0])));
342 bool PathLengthDirectInfSampler::sampleUniform(State *statePtr, const Cost &maxCost, unsigned int *iters)
368 // When the summed measure of the PHSes are suitably large, it makes more sense to just sample from the entire planning space and keep the sample if it lies in any PHS
369 // Check if the average measure is greater than half the domain's measure. Half is an arbitrary number.
377 // The measure is sufficiently small that we will directly sample the PHSes, with the weighting given by their relative measures
422 // Due to the possibility of overlap between multiple PHSs, we keep a sample with a probability of 1/K, where K is the number of PHSs the sample is in.
455 std::vector<double> PathLengthDirectInfSampler::getInformedSubstate(const State *statePtr) const
468 informedSubSpace_->copyToReals(rawData, statePtr->as<CompoundState>()->components[informedIdx_]);
476 void PathLengthDirectInfSampler::createFullState(State * statePtr, const std::vector<double> &informedVector)
479 // If there is an extra "uninformed" subspace, we need to add that to the state before converting the raw vector representation into a state....
494 informedSubSpace_->copyFromReals(statePtr->as<CompoundState>()->components[informedIdx_], informedVector);
500 uninformedSubSpace_->copyState(statePtr->as<CompoundState>()->components[uninformedIdx_], uninformedState);
520 // Check if the specific PHS can ever be better than the given maxCost, i.e., if the distance between the foci is less than the current max cost
584 // The probability of using each PHS is weighted by it's measure. Therefore, if we iterate up the list of PHSs, the first one who's relative measure is greater than the PHS randomly selected
585 for (std::list<ompl::ProlateHyperspheroidPtr>::const_iterator phsIter = listPhsPtrs_.begin(); phsIter != listPhsPtrs_.end() && static_cast<bool>(rval) == false; ++phsIter)
640 for (std::list<ompl::ProlateHyperspheroidPtr>::const_iterator phsIter = listPhsPtrs_.begin(); phsIter != listPhsPtrs_.end() && inPhs == false; ++ phsIter)
650 bool PathLengthDirectInfSampler::isInPhs(const ProlateHyperspheroidCPtr &phsCPtr, const std::vector<double> &informedVector) const
657 unsigned int PathLengthDirectInfSampler::numberOfPhsInclusions(const std::vector<double>& informedVector) const
664 for (std::list<ompl::ProlateHyperspheroidPtr>::const_iterator phsIter = listPhsPtrs_.begin(); phsIter != listPhsPtrs_.end(); ++ phsIter)
A shared pointer wrapper for ompl::base::ProblemDefinition.
A shared pointer wrapper for ompl::base::StateSpace.
A shared pointer wrapper for ompl::base::StateSampler.
virtual Cost heuristicSolnCost(const State *statePtr) const
A helper function to calculate the heuristic estimate of the solution cost for the informed subset of...
Definition: PathLengthDirectInfSampler.cpp:319
OptimizationObjectivePtr opt_
A copy of the optimization objective.
Definition: InformedStateSampler.h:99
An abstract class for the concept of using information about the state space and the current solution...
Definition: InformedStateSampler.h:61
const StateSpacePtr & getSubspace(const unsigned int index) const
Get a specific subspace from the compound state space.
Definition: StateSpace.cpp:898
PathLengthDirectInfSampler(const ProblemDefinitionPtr probDefn, unsigned int maxNumberCalls)
Construct a sampler that only generates states with a heuristic solution estimate that is less than t...
Definition: PathLengthDirectInfSampler.cpp:58
virtual bool sampleUniform(State *statePtr, const Cost &maxCost)
Sample uniformly in the subset of the state space whose heuristic solution estimates are less than th...
Definition: PathLengthDirectInfSampler.cpp:235
Abstract definition of a goal region that can be sampled.
Definition: GoalSampleableRegion.h:49
A space to allow the composition of state spaces.
Definition: StateSpace.h:549
virtual bool hasInformedMeasure() const
Whether the sampler can provide a measure of the informed subset.
Definition: PathLengthDirectInfSampler.cpp:283
ompl::base::RealVectorStateSpace
Definition: StateSpaceTypes.h:53
ProblemDefinitionPtr probDefn_
A copy of the problem definition.
Definition: InformedStateSampler.h:97
unsigned int getSubspaceCount() const
Get the number of state spaces that make up the compound state space.
Definition: StateSpace.cpp:893
virtual double getInformedMeasure(const Cost ¤tCost) const
The measure of the subset of the state space defined by the current solution cost that is being searc...
Definition: PathLengthDirectInfSampler.cpp:290
unsigned int numIters_
The number of iterations I'm allowed to attempt.
Definition: InformedStateSampler.h:103
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition: Cost.h:47
This bit is set if casting to sampleable goal regions (ompl::base::GoalSampleableRegion) is possible...
Definition: GoalTypes.h:55