All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
PathGeometric.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
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 Willow Garage 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: Ioan Sucan */
36 
37 #ifndef OMPL_GEOMETRIC_PATH_GEOMETRIC_
38 #define OMPL_GEOMETRIC_PATH_GEOMETRIC_
39 
40 #include "ompl/base/SpaceInformation.h"
41 #include "ompl/base/Path.h"
42 #include <vector>
43 #include <utility>
44 
45 namespace ompl
46 {
47 
49  namespace geometric
50  {
51 
55  class PathGeometric : public base::Path
56  {
57  public:
58 
61  {
62  }
63 
65  PathGeometric(const PathGeometric &path);
66 
68  PathGeometric(const base::SpaceInformationPtr &si, const base::State *state);
69 
71  PathGeometric(const base::SpaceInformationPtr &si, const base::State *state1, const base::State *state2);
72 
73  virtual ~PathGeometric(void)
74  {
75  freeMemory();
76  }
77 
79  PathGeometric& operator=(const PathGeometric& other);
80 
81 
83  virtual double length(void) const;
84 
86  virtual bool check(void) const;
87 
101  double smoothness(void) const;
102 
114  double clearance(void) const;
115 
117  virtual void print(std::ostream &out) const;
118 
119 
128  void interpolate(unsigned int count);
129 
134  void interpolate(void);
135 
137  void subdivide(void);
138 
140  void reverse(void);
141 
152  std::pair<bool, bool> checkAndRepair(unsigned int attempts);
153 
164  void overlay(const PathGeometric &over, unsigned int startIndex = 0);
165 
167  void append(const base::State *state);
168 
180  void append(const PathGeometric &path);
181 
183  void keepAfter(const base::State *state);
184 
186  void keepBefore(const base::State *state);
187 
189  void random(void);
190 
192  bool randomValid(unsigned int attempts);
204  void computeFastTimeParametrization(double maxVel, double maxAcc, std::vector<double> &times, unsigned int maxSteps = 10) const;
205 
206 
211  int getClosestIndex(const base::State *state) const;
212 
214  std::vector<base::State*>& getStates(void)
215  {
216  return states_;
217  }
218 
220  base::State* getState(unsigned int index)
221  {
222  return states_[index];
223  }
224 
226  const base::State* getState(unsigned int index) const
227  {
228  return states_[index];
229  }
230 
232  std::size_t getStateCount(void) const
233  {
234  return states_.size();
235  }
236 
239  protected:
240 
242  void freeMemory(void);
243 
245  void copyFrom(const PathGeometric& other);
246 
248  std::vector<base::State*> states_;
249  };
250 
251  }
252 }
253 
254 #endif