CForestStateSpaceWrapper.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, Rice University
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Rice University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Authors: Mark Moll */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_CFOREST_CFORESTSTATESPACEWRAPPER_
38 #define OMPL_GEOMETRIC_PLANNERS_CFOREST_CFORESTSTATESPACEWRAPPER_
39 
40 #include "ompl/geometric/planners/cforest/CForestStateSampler.h"
41 #include "ompl/base/StateSpace.h"
42 #include "ompl/base/Planner.h"
43 
44 namespace ompl
45 {
46  namespace geometric
47  {
48  class CForest;
49  }
50 
51  namespace base
52  {
56  {
57  public:
59  : cforest_(cforest), space_(space), planner_(NULL)
60  {
61  setName(space->getName() + "CForestWrapper");
62  }
63 
65  {
66  }
67 
68  void setPlanner(base::Planner *planner)
69  {
70  planner_ = planner;
71  }
72 
73  const base::Planner* getPlanner() const
74  {
75  return planner_;
76  }
77 
78  geometric::CForest* getCForestInstance() const
79  {
80  return cforest_;
81  }
82 
84 
85  virtual StateSamplerPtr allocStateSampler() const;
86 
87  virtual void setup();
88 
89  virtual bool isCompound() const
90  {
91  return space_->isCompound();
92  }
93  virtual bool isDiscrete() const
94  {
95  return space_->isDiscrete();
96  }
97  virtual bool isHybrid() const
98  {
99  return space_->isHybrid();
100  }
101  virtual bool isMetricSpace() const
102  {
103  return space_->isMetricSpace();
104  }
105  virtual bool hasSymmetricDistance() const
106  {
107  return space_->hasSymmetricDistance();
108  }
109  virtual bool hasSymmetricInterpolate() const
110  {
111  return space_->hasSymmetricInterpolate();
112  }
113  virtual double getLongestValidSegmentFraction() const
114  {
115  return space_->getLongestValidSegmentFraction();
116  }
117  virtual void setLongestValidSegmentFraction(double segmentFraction)
118  {
119  space_->setLongestValidSegmentFraction(segmentFraction);
120  }
121  virtual unsigned int validSegmentCount(const State *state1, const State *state2) const
122  {
123  return space_->validSegmentCount(state1, state2);
124  }
125  virtual unsigned int getDimension() const
126  {
127  return space_->getDimension();
128  }
129  virtual double getMaximumExtent() const
130  {
131  return space_->getMaximumExtent();
132  }
133  virtual double getMeasure() const
134  {
135  return space_->getMeasure();
136  }
137  virtual void enforceBounds(State *state) const
138  {
139  space_->enforceBounds(state);
140  }
141  virtual bool satisfiesBounds(const State *state) const
142  {
143  return space_->satisfiesBounds(state);
144  }
145  virtual void copyState(State *destination, const State *source) const
146  {
147  space_->copyState(destination, source);
148  }
149  virtual double distance(const State *state1, const State *state2) const
150  {
151  return space_->distance(state1, state2);
152  }
153  virtual unsigned int getSerializationLength() const
154  {
155  return space_->getSerializationLength();
156  }
157  virtual void serialize(void *serialization, const State *state) const
158  {
159  space_->serialize(serialization, state);
160  }
161  virtual void deserialize(State *state, const void *serialization) const
162  {
163  space_->deserialize(state, serialization);
164  }
165  virtual bool equalStates(const State *state1, const State *state2) const
166  {
167  return space_->equalStates(state1, state2);
168  }
169  virtual void interpolate(const State *from, const State *to, const double t, State *state) const
170  {
171  space_->interpolate(from, to, t, state);
172  }
173  virtual State* allocState() const
174  {
175  return space_->allocState();
176  }
177  virtual void freeState(State *state) const
178  {
179  space_->freeState(state);
180  }
181  virtual double* getValueAddressAtIndex(State *state, const unsigned int index) const
182  {
183  return space_->getValueAddressAtIndex(state, index);
184  }
185  virtual void registerProjections()
186  {
187  space_->registerProjections();
188  }
189  virtual void printState(const State *state, std::ostream &out) const
190  {
191  space_->printState(state, out);
192  }
193  virtual void printSettings(std::ostream &out) const
194  {
195  space_->printSettings(out);
196  }
197  virtual void printProjections(std::ostream &out) const
198  {
199  space_->printProjections(out);
200  }
201  virtual void sanityChecks(double zero, double eps, unsigned int flags) const
202  {
203  space_->sanityChecks(zero, eps, flags);
204  }
205  virtual void sanityChecks() const
206  {
207  space_->sanityChecks();
208  }
209  virtual StateSamplerPtr allocSubspaceStateSampler(const StateSpace *subspace) const
210  {
211  return space_->allocSubspaceStateSampler(subspace);
212  }
213  virtual void computeLocations()
214  {
215  space_->computeLocations();
216  }
217 
218  protected:
219  geometric::CForest *cforest_;
220  StateSpace *space_;
221  Planner *planner_;
222  };
223  }
224 }
225 
226 #endif
void setName(const std::string &name)
Set the name of the state space.
Definition: StateSpace.cpp:203
virtual unsigned int validSegmentCount(const State *state1, const State *state2) const
Count how many segments of the "longest valid length" fit on the motion from state1 to state2...
Definition: StateSpace.cpp:834
virtual void setLongestValidSegmentFraction(double segmentFraction)
When performing discrete validation of motions, the length of the longest segment that does not requi...
virtual bool hasSymmetricInterpolate() const
Check if the interpolation function on this state space is symmetric, i.e. interpolate(from, to, t, state) = interpolate(to, from, 1-t, state). Default implementation returns true.
Definition: StateSpace.cpp:770
virtual void printState(const State *state, std::ostream &out) const
Print a state to a stream.
virtual double * getValueAddressAtIndex(State *state, const unsigned int index) const
Many states contain a number of double values. This function provides a means to get the memory addre...
Definition: StateSpace.cpp:298
virtual bool isHybrid() const
Check if this is a hybrid state space (i.e., both discrete and continuous components exist) ...
Definition: StateSpace.cpp:760
virtual double getLongestValidSegmentFraction() const
When performing discrete validation of motions, the length of the longest segment that does not requi...
Definition: StateSpace.cpp:824
virtual void printProjections(std::ostream &out) const
Print the list of registered projections. This function is also called by printSettings() ...
virtual void printProjections(std::ostream &out) const
Print the list of registered projections. This function is also called by printSettings() ...
Definition: StateSpace.cpp:385
A boost shared pointer wrapper for ompl::base::StateSampler.
virtual double distance(const State *state1, const State *state2) const
Computes distance between two states. This function satisfies the properties of a metric if isMetricS...
virtual unsigned int getDimension() const =0
Get the dimension of the space (not the dimension of the surrounding ambient space) ...
virtual bool isHybrid() const
Check if this is a hybrid state space (i.e., both discrete and continuous components exist) ...
State space wrapper to use together with CForest. It adds some functionalities to the regular state s...
virtual void copyState(State *destination, const State *source) const
Copy a state to another. The memory of source and destination should NOT overlap. ...
virtual void sanityChecks(double zero, double eps, unsigned int flags) const
Perform sanity checks for this state space. Throws an exception if failures are found.
virtual bool isMetricSpace() const
Return true if the distance function associated with the space is a metric.
Definition: StateSpace.h:178
virtual void computeLocations()
Compute the location information for various components of the state space. Either this function or s...
Definition: StateSpace.cpp:215
virtual bool isMetricSpace() const
Return true if the distance function associated with the space is a metric.
virtual void printSettings(std::ostream &out) const
Print the settings for this state space to a stream.
Definition: StateSpace.cpp:379
virtual void computeLocations()
Compute the location information for various components of the state space. Either this function or s...
virtual void registerProjections()
Register the projections for this state space. Usually, this is at least the default projection...
Definition: StateSpace.cpp:227
virtual StateSamplerPtr allocSubspaceStateSampler(const StateSpace *subspace) const
Allocate a sampler that actually samples only components that are part of subspace.
virtual bool hasSymmetricInterpolate() const
Check if the interpolation function on this state space is symmetric, i.e. interpolate(from, to, t, state) = interpolate(to, from, 1-t, state). Default implementation returns true.
virtual void deserialize(State *state, const void *serialization) const
Read the binary representation of a state from serialization and write it to state.
virtual void freeState(State *state) const
Free the memory of the allocated state.
virtual double getMaximumExtent() const
Get the maximum value a call to distance() can return (or an upper bound). For unbounded state spaces...
virtual void setLongestValidSegmentFraction(double segmentFraction)
When performing discrete validation of motions, the length of the longest segment that does not requi...
Definition: StateSpace.cpp:812
Main namespace. Contains everything in this library.
Definition: Cost.h:42
Base class for a planner.
Definition: Planner.h:232
virtual void interpolate(const State *from, const State *to, const double t, State *state) const
Computes the state that lies at time t in [0, 1] on the segment that connects from state to to state...
virtual double getMeasure() const
Get a measure of the space (this can be thought of as a generalization of volume) ...
virtual void setup()
Perform final setup steps. This function is automatically called by the SpaceInformation. If any default projections are to be registered, this call will set them and call their setup() functions. It is safe to call this function multiple times. At a subsequent call, projections that have been previously user configured are not re-instantiated, but their setup() method is still called.
virtual void sanityChecks(double zero, double eps, unsigned int flags) const
Perform sanity checks for this state space. Throws an exception if failures are found.
Definition: StateSpace.cpp:597
Representation of a space in which planning can be performed. Topology specific sampling, interpolation and distance are defined.
Definition: StateSpace.h:73
virtual StateSamplerPtr allocDefaultStateSampler() const
Allocate an instance of the default uniform state sampler for this space.
virtual bool equalStates(const State *state1, const State *state2) const
Checks whether two states are equal.
Definition of an abstract state.
Definition: State.h:50
virtual bool satisfiesBounds(const State *state) const =0
Check if a state is inside the bounding box. For unbounded spaces this function can always return tru...
virtual bool isDiscrete() const
Check if the set of states is discrete.
Definition: StateSpace.cpp:755
virtual bool isDiscrete() const
Check if the set of states is discrete.
virtual void serialize(void *serialization, const State *state) const
Write the binary representation of state to serialization.
StateSamplerPtr allocSubspaceStateSampler(const StateSpacePtr &subspace) const
Allocate a sampler that actually samples only components that are part of subspace.
Definition: StateSpace.cpp:793
virtual double getMeasure() const =0
Get a measure of the space (this can be thought of as a generalization of volume) ...
virtual bool hasSymmetricDistance() const
Check if the distance function on this state space is symmetric, i.e. distance(s1,s2) = distance(s2,s1). Default implementation returns true.
Definition: StateSpace.cpp:765
virtual double * getValueAddressAtIndex(State *state, const unsigned int index) const
Many states contain a number of double values. This function provides a means to get the memory addre...
virtual bool satisfiesBounds(const State *state) const
Check if a state is inside the bounding box. For unbounded spaces this function can always return tru...
virtual void sanityChecks() const
Convenience function that allows derived state spaces to choose which checks should pass (see SanityC...
virtual void enforceBounds(State *state) const =0
Bring the state within the bounds of the state space. For unbounded spaces this function can be a no-...
virtual void deserialize(State *state, const void *serialization) const
Read the binary representation of a state from serialization and write it to state.
Definition: StateSpace.cpp:370
virtual void printSettings(std::ostream &out) const
Print the settings for this state space to a stream.
virtual bool equalStates(const State *state1, const State *state2) const =0
Checks whether two states are equal.
virtual double distance(const State *state1, const State *state2) const =0
Computes distance between two states. This function satisfies the properties of a metric if isMetricS...
virtual unsigned int getDimension() const
Get the dimension of the space (not the dimension of the surrounding ambient space) ...
Coupled Forest of Random Engrafting Search Trees.
Definition: CForest.h:78
virtual void serialize(void *serialization, const State *state) const
Write the binary representation of state to serialization.
Definition: StateSpace.cpp:366
virtual bool isCompound() const
Check if the state space is compound.
Definition: StateSpace.cpp:750
const std::string & getName() const
Get the name of the state space.
Definition: StateSpace.cpp:198
virtual void interpolate(const State *from, const State *to, const double t, State *state) const =0
Computes the state that lies at time t in [0, 1] on the segment that connects from state to to state...
virtual void freeState(State *state) const =0
Free the memory of the allocated state.
virtual void copyState(State *destination, const State *source) const =0
Copy a state to another. The memory of source and destination should NOT overlap. ...
virtual bool isCompound() const
Check if the state space is compound.
virtual State * allocState() const
Allocate a state that can store a point in the described space.
virtual State * allocState() const =0
Allocate a state that can store a point in the described space.
virtual double getLongestValidSegmentFraction() const
When performing discrete validation of motions, the length of the longest segment that does not requi...
virtual bool hasSymmetricDistance() const
Check if the distance function on this state space is symmetric, i.e. distance(s1,s2) = distance(s2,s1). Default implementation returns true.
virtual void printState(const State *state, std::ostream &out) const
Print a state to a stream.
Definition: StateSpace.cpp:374
virtual unsigned int getSerializationLength() const
Get the number of chars in the serialization of a state in this space.
virtual StateSamplerPtr allocStateSampler() const
Allocate an instance of the state sampler for this space. This sampler will be allocated with the sam...
virtual void enforceBounds(State *state) const
Bring the state within the bounds of the state space. For unbounded spaces this function can be a no-...
virtual void registerProjections()
Register the projections for this state space. Usually, this is at least the default projection...
virtual unsigned int getSerializationLength() const
Get the number of chars in the serialization of a state in this space.
Definition: StateSpace.cpp:361
virtual double getMaximumExtent() const =0
Get the maximum value a call to distance() can return (or an upper bound). For unbounded state spaces...
virtual unsigned int validSegmentCount(const State *state1, const State *state2) const
Count how many segments of the "longest valid length" fit on the motion from state1 to state2...