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 
75  virtual double cost(const base::OptimizationObjective &objective) const;
76 
78  virtual bool check(void) const;
79 
81  virtual void print(std::ostream &out) const;
82 
85 
91  void append(const base::State *state);
92 
95  void append(const base::State *state, const Control *control, double duration);
96 
98  void interpolate(void);
99 
101  void random(void);
102 
104  bool randomValid(unsigned int attempts);
105 
112  std::vector<base::State*>& getStates(void)
113  {
114  return states_;
115  }
116 
118  std::vector<Control*>& getControls(void)
119  {
120  return controls_;
121  }
122 
124  std::vector<double>& getControlDurations(void)
125  {
126  return controlDurations_;
127  }
128 
130  base::State* getState(unsigned int index)
131  {
132  return states_[index];
133  }
134 
136  const base::State* getState(unsigned int index) const
137  {
138  return states_[index];
139  }
140 
142  Control* getControl(unsigned int index)
143  {
144  return controls_[index];
145  }
146 
148  const Control* getControl(unsigned int index) const
149  {
150  return controls_[index];
151  }
152 
154  double getControlDuration(unsigned int index) const
155  {
156  return controlDurations_[index];
157  }
158 
160  std::size_t getStateCount(void) const
161  {
162  return states_.size();
163  }
164 
166  std::size_t getControlCount(void) const
167  {
168  return controls_.size();
169  }
170 
173  protected:
174 
176  std::vector<base::State*> states_;
177 
179  std::vector<Control*> controls_;
180 
182  std::vector<double> controlDurations_;
183 
185  void freeMemory(void);
186 
188  void copyFrom(const PathControl& other);
189 
190  };
191 
192  }
193 }
194 
195 #endif