All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
DubinsStateSpace.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2010, 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: Mark Moll */
36 
37 #ifndef OMPL_BASE_SPACES_DUBINS_STATE_SPACE_
38 #define OMPL_BASE_SPACES_DUBINS_STATE_SPACE_
39 
40 #include "ompl/base/spaces/SE2StateSpace.h"
41 #include "ompl/base/MotionValidator.h"
42 #include <boost/math/constants/constants.hpp>
43 
44 namespace ompl
45 {
46  namespace base
47  {
48 
73  {
74  public:
75 
77  enum DubinsPathSegmentType { DUBINS_LEFT=0, DUBINS_STRAIGHT=1, DUBINS_RIGHT=2 };
81  class DubinsPath
82  {
83  public:
85  double t=0., double p=std::numeric_limits<double>::max(), double q=0.)
86  : reverse_(false)
87  {
88  memcpy(type_, type, 3*sizeof(DubinsPathSegmentType));
89  length_[0] = t;
90  length_[1] = p;
91  length_[2] = q;
92  assert(t >= 0.);
93  assert(p >= 0.);
94  assert(q >= 0.);
95  }
96  double length() const
97  {
98  return length_[0] + length_[1] + length_[2];
99  }
100 
104  double length_[3];
106  bool reverse_;
107  };
108 
109  DubinsStateSpace(double turningRadius = 1.0, bool isSymmetric = false)
110  : SE2StateSpace(), rho_(turningRadius), isSymmetric_(isSymmetric)
111  {
112  }
113 
114  virtual double distance(const State *state1, const State *state2) const;
115 
116  virtual void interpolate(const State *from, const State *to, const double t,
117  State *state) const;
118  virtual void interpolate(const State *from, const State *to, const double t,
119  bool& firstTime, DubinsPath& path, State *state) const;
120 
121  virtual void sanityChecks(void) const
122  {
123  double zero = std::numeric_limits<double>::epsilon();
124  double eps = std::numeric_limits<float>::epsilon();
126  if (!isSymmetric_)
128  StateSpace::sanityChecks(zero, eps, flags);
129  }
130 
132  DubinsPath dubins(const State *state1, const State *state2) const;
133 
134  protected:
135  virtual void interpolate(const State *from, const DubinsPath& path, const double t,
136  State *state) const;
137 
139  double rho_;
140 
149  };
150 
158  {
159  public:
161  {
162  defaultSettings();
163  }
165  {
166  defaultSettings();
167  }
168  virtual ~DubinsMotionValidator(void)
169  {
170  }
171  virtual bool checkMotion(const State *s1, const State *s2) const;
172  virtual bool checkMotion(const State *s1, const State *s2, std::pair<State*, double> &lastValid) const;
173  private:
174  DubinsStateSpace *stateSpace_;
175  void defaultSettings(void);
176  };
177 
178  }
179 }
180 
181 #endif