All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Decomposition.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, 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 /* Author: Matt Maly */
36 
37 #ifndef OMPL_CONTROL_PLANNERS_SYCLOP_DECOMPOSITION_
38 #define OMPL_CONTROL_PLANNERS_SYCLOP_DECOMPOSITION_
39 
40 #include "ompl/base/spaces/RealVectorBounds.h"
41 #include "ompl/base/StateSampler.h"
42 #include "ompl/base/State.h"
43 #include "ompl/util/Console.h"
44 #include "ompl/util/Exception.h"
45 #include "ompl/util/ClassForward.h"
46 #include "ompl/util/RandomNumbers.h"
47 
48 namespace ompl
49 {
50  namespace control
51  {
52 
54 
55  OMPL_CLASS_FORWARD(Decomposition);
57 
63  {
64  public:
65 
69  Decomposition(unsigned int dim, const base::RealVectorBounds& b, unsigned int nreg = 0) : numRegions_(nreg), dimension_(dim), bounds_(b)
70  {
71  if (dim > b.low.size())
72  throw Exception("Decomposition", "argument 'dim' exceeds dimension of given bounds");
73  else if (dim < b.low.size())
74  OMPL_WARN("Decomposition: dimension of given bounds exceeds argument 'dim'. Using the first 'dim' values of bounds");
75  }
76 
77  virtual ~Decomposition()
78  {
79  }
80 
82  virtual unsigned int getNumRegions() const
83  {
84  return numRegions_;
85  }
86 
88  virtual unsigned int getDimension() const
89  {
90  return dimension_;
91  }
92 
94  virtual const base::RealVectorBounds& getBounds() const
95  {
96  return bounds_;
97  }
98 
100  virtual double getRegionVolume(unsigned int rid) = 0;
101 
105  virtual int locateRegion(const base::State* s) const = 0;
106 
108  virtual void project(const base::State* s, std::vector<double>& coord) const = 0;
109 
111  virtual void getNeighbors(unsigned int rid, std::vector<unsigned int>& neighbors) const = 0;
112 
114  virtual void sampleFromRegion(unsigned int rid, RNG& rng, std::vector<double>& coord) const = 0;
115 
117  virtual void sampleFullState(const base::StateSamplerPtr& sampler, const std::vector<double>& coord, base::State* s) const = 0;
118 
119  protected:
120  virtual void setNumRegions(unsigned int n)
121  {
122  numRegions_ = n;
123  }
124 
125  unsigned int numRegions_;
126  unsigned int dimension_;
127  base::RealVectorBounds bounds_;
128  };
129  }
130 }
131 #endif
virtual void getNeighbors(unsigned int rid, std::vector< unsigned int > &neighbors) const =0
Stores a given region's neighbors into a given vector.
std::vector< double > low
Lower bound.
A boost shared pointer wrapper for ompl::base::StateSampler.
A Decomposition is a partition of a bounded Euclidean space into a fixed number of regions which are ...
Definition: Decomposition.h:62
virtual void sampleFullState(const base::StateSamplerPtr &sampler, const std::vector< double > &coord, base::State *s) const =0
Samples a State using a projected coordinate and a StateSampler.
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:54
Definition of an abstract state.
Definition: State.h:50
virtual int locateRegion(const base::State *s) const =0
Returns the index of the region containing a given State. Most often, this is obtained by first calli...
#define OMPL_WARN(fmt,...)
Log a formatted warning string.
Definition: Console.h:66
virtual void project(const base::State *s, std::vector< double > &coord) const =0
Project a given State to a set of coordinates in R^k, where k is the dimension of this Decomposition...
virtual unsigned int getDimension() const
Returns the dimension of this Decomposition.
Definition: Decomposition.h:88
The exception type for ompl.
Definition: Exception.h:47
Decomposition(unsigned int dim, const base::RealVectorBounds &b, unsigned int nreg=0)
Constructor. Creates a Decomposition with a given dimension and a given set of bounds. Accepts as an optional argument a given number of regions.
Definition: Decomposition.h:69
The lower and upper bounds for an Rn space.
virtual double getRegionVolume(unsigned int rid)=0
Returns the volume of a given region in this Decomposition.
virtual void sampleFromRegion(unsigned int rid, RNG &rng, std::vector< double > &coord) const =0
Samples a projected coordinate from a given region.
virtual unsigned int getNumRegions() const
Returns the number of regions in this Decomposition.
Definition: Decomposition.h:82
virtual const base::RealVectorBounds & getBounds() const
Returns the bounds of this Decomposition.
Definition: Decomposition.h:94