All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
PathControl.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: Ioan Sucan */
36 
37 #ifndef OMPL_CONTROL_PATH_CONTROL_
38 #define OMPL_CONTROL_PATH_CONTROL_
39 
40 #include "ompl/control/SpaceInformation.h"
41 #include "ompl/base/Path.h"
42 #include "ompl/geometric/PathGeometric.h"
43 #include <vector>
44 
45 namespace ompl
46 {
47  namespace control
48  {
49 
54  class PathControl : public base::Path
55  {
56  public:
57 
60 
62  PathControl(const PathControl &path);
63 
64  virtual ~PathControl(void)
65  {
66  freeMemory();
67  }
68 
70  PathControl& operator=(const PathControl& other);
71 
73  virtual double length(void) const;
74 
76  virtual bool check(void) const;
77 
79  virtual void print(std::ostream &out) const;
80 
83 
89  void append(const base::State *state);
90 
93  void append(const base::State *state, const Control *control, double duration);
94 
96  void interpolate(void);
97 
99  void random(void);
100 
102  bool randomValid(unsigned int attempts);
103 
110  std::vector<base::State*>& getStates(void)
111  {
112  return states_;
113  }
114 
116  std::vector<Control*>& getControls(void)
117  {
118  return controls_;
119  }
120 
122  std::vector<double>& getControlDurations(void)
123  {
124  return controlDurations_;
125  }
126 
128  base::State* getState(unsigned int index)
129  {
130  return states_[index];
131  }
132 
134  const base::State* getState(unsigned int index) const
135  {
136  return states_[index];
137  }
138 
140  Control* getControl(unsigned int index)
141  {
142  return controls_[index];
143  }
144 
146  const Control* getControl(unsigned int index) const
147  {
148  return controls_[index];
149  }
150 
152  double getControlDuration(unsigned int index) const
153  {
154  return controlDurations_[index];
155  }
156 
158  std::size_t getStateCount(void) const
159  {
160  return states_.size();
161  }
162 
164  std::size_t getControlCount(void) const
165  {
166  return controls_.size();
167  }
168 
171  protected:
172 
174  std::vector<base::State*> states_;
175 
177  std::vector<Control*> controls_;
178 
180  std::vector<double> controlDurations_;
181 
183  void freeMemory(void);
184 
186  void copyFrom(const PathControl& other);
187 
188  };
189 
190  }
191 }
192 
193 #endif