37 #ifndef OMPL_BASE_GOALS_GOAL_LAZY_SAMPLES_
38 #define OMPL_BASE_GOALS_GOAL_LAZY_SAMPLES_
40 #include "ompl/base/goals/GoalStates.h"
41 #include <boost/thread/thread.hpp>
42 #include <boost/function.hpp>
56 typedef boost::function<bool(const GoalLazySamples*, State*)>
GoalSamplingFn;
105 bool autoStart =
true,
double minDist = std::numeric_limits<double>::epsilon());
158 virtual void clear(
void);
bool isSampling(void) const
Return true if the sampling thread is active.
unsigned int samplingAttemptsCount(void) const
The number of times the sampling function was called and it returned true.
void startSampling(void)
Start the goal sampling thread.
void stopSampling(void)
Stop the goal sampling thread.
void goalSamplingThread(void)
The function that samples goals by calling samplerFunc_ in a separate thread.
virtual void clear(void)
Clear all goal states.
Definition of a goal region that can be sampled, but the sampling process can be slow. This class allows sampling the happen in a separate thread, and the number of goals may increase, as the planner is running, in a thread-safe manner.
boost::function< void(const base::State *)> NewStateCallbackFn
When new samples are generated and added to the list of possible samples, a callback can be called...
double getMinNewSampleDistance(void) const
Get the minimum distance that a new state returned by the sampling thread needs to be away from previ...
boost::mutex lock_
Lock for updating the set of states.
virtual void sampleGoal(State *st) const
Sample a state in the goal region.
GoalSamplingFn samplerFunc_
Function that produces samples.
double minDist_
Samples returned by the sampling thread are added to the list of states only if they are at least min...
virtual bool couldSample(void) const
Return true if GoalStates::couldSample() is true or if the sampling thread is active, as in this case it is possible a sample can be produced at some point.
virtual const State * getState(unsigned int index) const
Return a pointer to the indexth state in the state list.
Definition of a set of goal states.
virtual std::size_t getStateCount(void) const
Return the number of valid goal states.
bool addStateIfDifferent(const State *st, double minDistance)
Add a state st if it further away that minDistance from previously added states. Return true if the s...
void setNewStateCallback(const NewStateCallbackFn &callback)
Set the callback function to be called when a new state is added to the list of possible samples...
GoalLazySamples(const SpaceInformationPtr &si, const GoalSamplingFn &samplerFunc, bool autoStart=true, double minDist=std::numeric_limits< double >::epsilon())
Create a goal region that can be sampled in a lazy fashion. A function (samplerFunc) that produces sa...
Definition of an abstract state.
virtual void addState(const State *st)
Add a goal state.
virtual bool hasStates(void) const
Check if there are any states in this goal region.
virtual double distanceGoal(const State *st) const
Compute the distance to the goal (heuristic). This function is the one used in computing the distance...
boost::thread * samplingThread_
Additional thread for sampling goal states.
bool terminateSamplingThread_
Flag used to notify the sampling thread to terminate sampling.
unsigned int samplingAttempts_
The number of times the sampling function was called and it returned true.
boost::function< bool(const GoalLazySamples *, State *)> GoalSamplingFn
Goal sampling function. Returns false when no further calls should be made to it. Fills its second ar...
void setMinNewSampleDistance(double dist)
Set the minimum distance that a new state returned by the sampling thread needs to be away from previ...
NewStateCallbackFn callback_
If defined, this function is called when a new state is added to the list of possible samples...