XXLDecomposition.h
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015, 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 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: Ryan Luna */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_XXL_XXLDECOMPOSITION_
38 #define OMPL_GEOMETRIC_PLANNERS_XXL_XXLDECOMPOSITION_
39 
40 #include <vector>
41 #include "ompl/base/State.h"
42 #include "ompl/base/spaces/RealVectorBounds.h"
43 #include "ompl/util/ClassForward.h"
44 #include "ompl/util/Console.h"
45 
46 namespace ompl
47 {
48  namespace geometric
49  {
51 
52  OMPL_CLASS_FORWARD(XXLDecomposition);
54 
59  class XXLDecomposition
60  {
61  public:
64  {
65  }
66 
67  virtual ~XXLDecomposition()
68  {
69  }
70 
72  virtual int getNumRegions() const = 0;
73 
75  virtual int getDimension() const = 0;
76 
78  virtual int numLayers() const = 0;
79 
83  virtual int locateRegion(const base::State *s) const = 0;
84 
86  virtual int locateRegion(const std::vector<double> &coord) const = 0;
87 
89  virtual void getNeighbors(int rid, std::vector<int> &neighbors) const = 0;
90 
95  virtual void getNeighborhood(int rid, std::vector<int> &neighborhood) const
96  {
97  return getNeighbors(rid, neighborhood);
98  }
99 
101  virtual double distanceHeuristic(int r1, int r2) const = 0;
102 
104  virtual bool sampleFromRegion(int r, base::State *s, const base::State *seed = nullptr) const = 0;
105 
107  virtual bool sampleFromRegion(int r, base::State *s, const base::State *seed, int layer) const = 0;
108 
110  virtual void project(const base::State *s, std::vector<double> &coord, int layer = 0) const = 0;
111 
113  virtual void project(const base::State *s, std::vector<int> &layers) const = 0;
114 
116  virtual bool canSteer() const
117  {
118  return false;
119  }
120 
121  virtual bool steerToRegion(int /*r*/, int /*layer*/, const ompl::base::State * /*start*/,
122  std::vector<ompl::base::State *> & /*states*/) const
123  {
124  OMPL_ERROR("steerToRegion has no default implementation");
125  return false;
126  }
127  };
128  } // namespace geometric
129 } // namespace ompl
130 #endif
virtual bool sampleFromRegion(int r, base::State *s, const base::State *seed=nullptr) const =0
Sample a state s from region r in layer 0.
Definition of an abstract state.
Definition: State.h:113
virtual double distanceHeuristic(int r1, int r2) const =0
An admissible and consistent distance heuristic between two regions.
virtual bool canSteer() const
Returns true if the method steerToRegion is available.
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...
virtual int getDimension() const =0
Return the dimension of this XXLDecomposition.
virtual void getNeighborhood(int rid, std::vector< int > &neighborhood) const
Return a list of regions in the neighborhood of rid. This method is intended to retrieve all regions ...
virtual int numLayers() const =0
Return the number of layers possible in this decomposition. Must be at least 1.
virtual void project(const base::State *s, std::vector< double > &coord, int layer=0) const =0
Project the given State into the XXLDecomposition.
virtual void getNeighbors(int rid, std::vector< int > &neighbors) const =0
Stores the given region's neighbors into a given vector. These are adjacent neighbors.
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
Definition: Console.h:64
virtual int getNumRegions() const =0
Returns the number of regions in this XXLDecomposition.
Main namespace. Contains everything in this library.