Loading...
Searching...
No Matches
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#include <optional>
44
45namespace ompl
46{
47 namespace base
48 {
64 class ReedsSheppStateSpace : public SE2StateSpace
65 {
66 public:
69 {
70 RS_NOP = 0,
71 RS_LEFT = 1,
72 RS_STRAIGHT = 2,
73 RS_RIGHT = 3
74 };
75
78 class PathType
79 {
80 public:
81 PathType(const ReedsSheppPathSegmentType *type = reedsSheppPathType[0],
82 double t = std::numeric_limits<double>::max(), double u = 0., double v = 0., double w = 0.,
83 double x = 0.);
84 double length() const
85 {
86 return totalLength_;
87 }
88
92 double length_[5];
95 };
96
97 ReedsSheppStateSpace(double turningRadius = 1.0) : rho_(turningRadius)
98 {
99 setName("ReedsShepp" + getName());
101 }
102
103 double distance(const State *state1, const State *state2) const override;
104 unsigned int validSegmentCount(const State *state1, const State *state2) const override
105 {
107 (unsigned int)ceil(distance(state1, state2) / longestValidSegment_);
108 }
109
110 void interpolate(const State *from, const State *to, double t, State *state) const override;
111 virtual void interpolate(const State *from, const State *to, double t, bool &firstTime, PathType &path,
112 State *state) const;
113
114 void sanityChecks() const override
115 {
116 double zero = std::numeric_limits<double>::epsilon();
117 double eps = .1; // rarely such a large error will occur
119 }
120
122 PathType getPath(const State *state1, const State *state2) const;
123
124 protected:
125 virtual void interpolate(const State *from, const PathType &path, double t, State *state) const;
126
128 double rho_;
129 };
130 } // namespace base
131} // namespace ompl
132
133#endif
const ReedsSheppPathSegmentType * type_
void sanityChecks() const override
Convenience function that allows derived state spaces to choose which checks should pass (see SanityC...
ReedsSheppPathSegmentType
The Reeds-Shepp path segment types.
unsigned int validSegmentCount(const State *state1, const State *state2) const override
Count how many segments of the "longest valid length" fit on the motion from state1 to state2....
void interpolate(const State *from, const State *to, double t, State *state) const override
Computes the state that lies at time t in [0, 1] on the segment that connects from state to to state....
PathType getPath(const State *state1, const State *state2) const
Return a shortest Reeds-Shepp path from SE(2) state state1 to SE(2) state state2.
double distance(const State *state1, const State *state2) const override
Computes distance between two states. This function satisfies the properties of a metric if isMetricS...
static const ReedsSheppPathSegmentType reedsSheppPathType[18][5]
Reeds-Shepp path types.
@ STATESPACE_INTERPOLATION
Check whether calling StateSpace::interpolate() works as expected.
Definition StateSpace.h:145
int type_
A type assigned for this state space.
Definition StateSpace.h:531
virtual void sanityChecks() const
Convenience function that allows derived state spaces to choose which checks should pass (see SanityC...
double longestValidSegment_
The longest valid segment at the time setup() was called.
Definition StateSpace.h:543
unsigned int longestValidSegmentCountFactor_
The factor to multiply the value returned by validSegmentCount(). Rarely used but useful for things l...
Definition StateSpace.h:547
void setName(const std::string &name)
Set the name of the state space.
const std::string & getName() const
Get the name of the state space.
Definition of an abstract state.
Definition State.h:50
This namespace contains sampling based planning routines shared by both planning under geometric cons...
@ STATE_SPACE_REEDS_SHEPP
ompl::base::ReedsSheppStateSpace
Main namespace. Contains everything in this library.