ReedsSheppStateSpace.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_REEDS_SHEPP_STATE_SPACE_
38 #define OMPL_BASE_SPACES_REEDS_SHEPP_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 
65  {
66  public:
67 
69  enum ReedsSheppPathSegmentType { RS_NOP=0, RS_LEFT=1, RS_STRAIGHT=2, RS_RIGHT=3 };
74  {
75  public:
76  ReedsSheppPath(const ReedsSheppPathSegmentType* type=reedsSheppPathType[0],
77  double t=std::numeric_limits<double>::max(), double u=0., double v=0.,
78  double w=0., double x=0.);
79  double length() const { return totalLength_; }
80 
84  double length_[5];
86  double totalLength_;
87  };
88 
89  ReedsSheppStateSpace(double turningRadius = 1.0)
90  : SE2StateSpace(), rho_(turningRadius)
91  {
92  }
93 
94  virtual double distance(const State *state1, const State *state2) const;
95 
96  virtual void interpolate(const State *from, const State *to, const double t,
97  State *state) const;
98  virtual void interpolate(const State *from, const State *to, const double t,
99  bool &firstTime, ReedsSheppPath &path, State *state) const;
100 
101  virtual void sanityChecks() const
102  {
103  double zero = std::numeric_limits<double>::epsilon();
104  double eps = .1; // rarely such a large error will occur
106  }
107 
109  ReedsSheppPath reedsShepp(const State *state1, const State *state2) const;
110 
111  protected:
112  virtual void interpolate(const State *from, const ReedsSheppPath &path, const double t,
113  State *state) const;
114 
116  double rho_;
117  };
118 
126  {
127  public:
129  {
130  defaultSettings();
131  }
133  {
134  defaultSettings();
135  }
136  virtual ~ReedsSheppMotionValidator()
137  {
138  }
139  virtual bool checkMotion(const State *s1, const State *s2) const;
140  virtual bool checkMotion(const State *s1, const State *s2, std::pair<State*, double> &lastValid) const;
141  private:
142  ReedsSheppStateSpace *stateSpace_;
143  void defaultSettings();
144  };
145 
146  }
147 }
148 
149 #endif
Complete description of a ReedsShepp path.
static const ReedsSheppPathSegmentType reedsSheppPathType[18][5]
Reeds-Shepp path types.
Abstract definition for a class checking the validity of motions – path segments between states...
Main namespace. Contains everything in this library.
Definition: Cost.h:42
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...
A state space representing SE(2)
Definition: SE2StateSpace.h:50
ReedsSheppPathSegmentType
The Reeds-Shepp path segment types.
virtual void sanityChecks() const
Convenience function that allows derived state spaces to choose which checks should pass (see SanityC...
A Reeds-Shepp motion validator that only uses the state validity checker. Motions are checked for val...
A boost shared pointer wrapper for ompl::base::SpaceInformation.
The base class for space information. This contains all the information about the space planning is d...
Definition of an abstract state.
Definition: State.h:50
virtual void sanityChecks() const
Convenience function that allows derived state spaces to choose which checks should pass (see SanityC...
Definition: StateSpace.cpp:591
An SE(2) state space where distance is measured by the length of Reeds-Shepp curves.
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...
ReedsSheppPath reedsShepp(const State *state1, const State *state2) const
Return the shortest Reeds-Shepp path from SE(2) state state1 to SE(2) state state2.
Check whether calling StateSpace::interpolate() works as expected.
Definition: StateSpace.h:141