Aikido
CRRT.hpp
Go to the documentation of this file.
1 #ifndef AIKIDO_PLANNER_OMPL_CRRT_HPP_
2 #define AIKIDO_PLANNER_OMPL_CRRT_HPP_
3 
4 #include <ompl/base/Planner.h>
5 #include <ompl/datastructures/NearestNeighbors.h>
6 #include <ompl/geometric/planners/PlannerIncludes.h>
7 
10 
11 namespace aikido {
12 namespace planner {
13 namespace ompl {
14 
16 class CRRT : public ::ompl::base::Planner
17 {
18 public:
21  explicit CRRT(const ::ompl::base::SpaceInformationPtr& _si);
22 
26  CRRT(const ::ompl::base::SpaceInformationPtr& _si, const std::string& _name);
27 
29  virtual ~CRRT();
30 
36  void getPlannerData(::ompl::base::PlannerData& _data) const override;
37 
48  ::ompl::base::PlannerStatus solve(
49  const ::ompl::base::PlannerTerminationCondition& _ptc) override;
50 
53  ::ompl::base::PlannerStatus solve(double _solveTime);
54 
57  void clear() override;
58 
65  void setGoalBias(double _goalBias);
66 
68  double getGoalBias() const;
69 
75  void setRange(double _distance);
76 
78  double getRange() const;
79 
85 
91  void setProjectionResolution(double _resolution);
92 
96  double getProjectionResolution() const;
97 
102  void setMinStateDifference(double _mindist);
103 
108  double getMinStateDifference() const;
109 
111  template <template <typename T> class NN>
112  void setNearestNeighbors();
113 
117  void setup() override;
118 
119 protected:
122  class Motion
123  {
124  public:
126  Motion() : state(nullptr), parent(nullptr)
127  {
128  // Do nothing
129  }
130 
132  explicit Motion(const ::ompl::base::SpaceInformationPtr& _si)
133  : state(_si->allocState()), parent(nullptr)
134  {
135  // Do nothing
136  }
137 
140  {
141  // Do nothing
142  }
143 
145  ::ompl::base::State* state;
146 
149  };
150 
152  virtual void freeMemory();
153 
156  double distanceFunction(const Motion* a, const Motion* b) const;
157 
160 
163 
179  const ::ompl::base::PlannerTerminationCondition& ptc,
180  TreeData& tree,
181  Motion* nmotion,
182  ::ompl::base::State* gstate,
183  ::ompl::base::State* xstate,
184  ::ompl::base::Goal* goal,
185  bool returnlast,
186  double& dist,
187  bool& foundgoal);
188 
190  ::ompl::base::StateSamplerPtr mSampler;
191 
194  double mGoalBias;
195 
197  double mMaxDistance;
198 
201  ::ompl::RNG mRng;
202 
205 
208 
210  double mMaxStepsize;
211 
214  double mMinStepsize;
215 };
216 
217 } // namespace ompl
218 } // namespace planner
219 } // namespace aikido
220 
221 #include "detail/CRRT-impl.hpp"
222 
223 #endif // AIKIDO_PLANNER_OMPL_CRRT_HPP_
aikido::planner::ompl::CRRT::Motion::~Motion
~Motion()
Destructor.
Definition: CRRT.hpp:139
aikido::planner::ompl::CRRT::Motion::Motion
Motion(const ::ompl::base::SpaceInformationPtr &_si)
Constructor that allocates memory for the state.
Definition: CRRT.hpp:132
aikido::planner::ompl::ompl_shared_ptr
boost::shared_ptr< T > ompl_shared_ptr
Definition: BackwardCompatibility.hpp:83
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::planner::ompl::CRRT::mCons
constraint::ProjectablePtr mCons
The constraint that must be satisfied throughout the trajectory.
Definition: CRRT.hpp:207
aikido::constraint::ProjectablePtr
std::shared_ptr< Projectable > ProjectablePtr
Definition: Projectable.hpp:33
aikido::planner::ompl::CRRT::freeMemory
virtual void freeMemory()
Free the memory allocated by this planner.
aikido::planner::ompl::CRRT::CRRT
CRRT(const ::ompl::base::SpaceInformationPtr &_si)
Constructor.
aikido::planner::ompl::CRRT::setMinStateDifference
void setMinStateDifference(double _mindist)
Set the minimum distance between two states for them to be considered "equivalent".
aikido::planner::ompl::CRRT::mRng
::ompl::RNG mRng
The random number generator used to determine whether to sample a goal state or a state uniformly fro...
Definition: CRRT.hpp:201
aikido::planner::ompl::CRRT::setProjectionResolution
void setProjectionResolution(double _resolution)
Set the resolution for the projection.
aikido::planner::ompl::CRRT::mGoalBias
double mGoalBias
The fraction of time the goal is picked as the state to expand towards (if such a state is available)
Definition: CRRT.hpp:194
aikido::planner::ompl::CRRT::getGoalBias
double getGoalBias() const
Get the goal bias the planner is using.
aikido::planner::ompl::CRRT::constrainedExtend
Motion * constrainedExtend(const ::ompl::base::PlannerTerminationCondition &ptc, TreeData &tree, Motion *nmotion, ::ompl::base::State *gstate, ::ompl::base::State *xstate, ::ompl::base::Goal *goal, bool returnlast, double &dist, bool &foundgoal)
Perform an extension that projects to a constraint.
aikido::planner::ompl::CRRT::mMaxStepsize
double mMaxStepsize
The maximum length of a step before projecting.
Definition: CRRT.hpp:210
aikido::planner::ompl::CRRT::setup
void setup() override
Perform extra configuration steps, if needed.
Projectable.hpp
aikido::planner::ompl::CRRT::Motion::state
::ompl::base::State * state
The state contained in this node.
Definition: CRRT.hpp:145
aikido::planner::ompl::CRRT::getPlannerData
void getPlannerData(::ompl::base::PlannerData &_data) const override
Get information about the current run of the motion planner.
aikido::planner::ompl::CRRT::getMinStateDifference
double getMinStateDifference() const
Get the minimum distance between two states for them to be considered "equivalent".
aikido::planner::ompl::CRRT::clear
void clear() override
Clear all internal datastructures.
CRRT-impl.hpp
aikido::planner::ompl::CRRT::setPathConstraint
void setPathConstraint(constraint::ProjectablePtr _projectable)
Set a projectable constraint to be applied throughout the trajectory.
aikido::planner::ompl::CRRT::getRange
double getRange() const
Get the range the planner is using.
aikido::planner::ompl::CRRT::Motion::Motion
Motion()
Constructor. Sets state and parent to null ptr.
Definition: CRRT.hpp:126
aikido::planner::ompl::CRRT::Motion
Representation of a node in the tree.
Definition: CRRT.hpp:122
aikido::planner::ompl::CRRT::setRange
void setRange(double _distance)
Set the range the planner is supposed to use.
aikido::planner::ompl::CRRT::mLastGoalMotion
Motion * mLastGoalMotion
The most recent goal motion. Used for PlannerData computation.
Definition: CRRT.hpp:204
aikido::planner::ompl::CRRT::mStartTree
TreeData mStartTree
A nearest-neighbors datastructure containing the tree of motions.
Definition: CRRT.hpp:162
aikido::planner::ompl::CRRT::getProjectionResolution
double getProjectionResolution() const
Get the resolution for the projection.
aikido::planner::ompl::CRRT::mMinStepsize
double mMinStepsize
The minumum step size along the constraint.
Definition: CRRT.hpp:214
aikido::planner::ompl::CRRT::setNearestNeighbors
void setNearestNeighbors()
Set a nearest neighbors data structure.
Definition: CRRT-impl.hpp:7
aikido::planner::ompl::CRRT::solve
::ompl::base::PlannerStatus solve(const ::ompl::base::PlannerTerminationCondition &_ptc) override
Function that can solve the motion planning problem.
BackwardCompatibility.hpp
aikido::planner::ompl::CRRT::Motion::parent
Motion * parent
The parent of this node.
Definition: CRRT.hpp:148
aikido::planner::ompl::CRRT::mSampler
::ompl::base::StateSamplerPtr mSampler
State sampler.
Definition: CRRT.hpp:190
aikido::planner::ompl::CRRT::mMaxDistance
double mMaxDistance
The maximum length of a motion to be added to a tree.
Definition: CRRT.hpp:197
aikido::planner::ompl::CRRT
Implements a constrained RRT planner.
Definition: CRRT.hpp:16
aikido::planner::ompl::CRRT::setGoalBias
void setGoalBias(double _goalBias)
Set the goal bias.
aikido::planner::ompl::CRRT::TreeData
ompl_shared_ptr<::ompl::NearestNeighbors< Motion * > > TreeData
A nearest-neighbor datastructure representing a tree of motions *‍/.
Definition: CRRT.hpp:159
aikido::planner::ompl::CRRT::distanceFunction
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states.
aikido::planner::ompl::CRRT::~CRRT
virtual ~CRRT()
Destructor.