All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
ControlSampler.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_CONTROL_SAMPLER_
38 #define OMPL_CONTROL_CONTROL_SAMPLER_
39 
40 #include "ompl/base/State.h"
41 #include "ompl/control/Control.h"
42 #include "ompl/util/RandomNumbers.h"
43 #include "ompl/util/ClassForward.h"
44 #include <vector>
45 #include <boost/function.hpp>
46 #include <boost/noncopyable.hpp>
47 
48 namespace ompl
49 {
50  namespace control
51  {
52 
54  OMPL_CLASS_FORWARD(ControlSpace);
56 
58 
59  OMPL_CLASS_FORWARD(ControlSampler);
61 
70  class ControlSampler : private boost::noncopyable
71  {
72  public:
73 
75  ControlSampler(const ControlSpace *space) : space_(space)
76  {
77  }
78 
79  virtual ~ControlSampler(void)
80  {
81  }
82 
86  virtual void sample(Control *control) = 0;
87 
96  virtual void sample(Control *control, const base::State *state);
97 
105  virtual void sampleNext(Control *control, const Control *previous);
106 
114  virtual void sampleNext(Control *control, const Control *previous, const base::State *state);
115 
117  virtual unsigned int sampleStepCount(unsigned int minSteps, unsigned int maxSteps);
118 
119  protected:
120 
123 
126  };
127 
130  {
131  public:
132 
135  {
136  }
137 
140  {
141  }
142 
146  virtual void addSampler(const ControlSamplerPtr &sampler);
147 
148 
149  virtual void sample(Control *control);
150  virtual void sample(Control *control, const base::State *state);
151  virtual void sampleNext(Control *control, const Control *previous);
152  virtual void sampleNext(Control *control, const Control *previous, const base::State *state);
153 
154  protected:
155 
157  std::vector<ControlSamplerPtr> samplers_;
158 
159  private:
160 
162  unsigned int samplerCount_;
163 
164  };
165 
167  typedef boost::function<ControlSamplerPtr(const ControlSpace*)> ControlSamplerAllocator;
168  }
169 }
170 
171 
172 #endif
Abstract definition of a control sampler. Motion planners that need to sample controls will call func...
Definition of a compound control sampler. This is useful to construct samplers for compound controls...
Definition of an abstract control.
Definition: Control.h:48
virtual void sample(Control *control)=0
Sample a control. All other control sampling functions default to this one, unless a user-specified i...
virtual void addSampler(const ControlSamplerPtr &sampler)
Add a sampler as part of the new compound sampler. This sampler is used to sample part of the compoun...
A boost shared pointer wrapper for ompl::control::ControlSampler.
const ControlSpace * space_
The control space this sampler operates on.
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:54
std::vector< ControlSamplerPtr > samplers_
The instances of samplers used for compound sampler.
virtual unsigned int sampleStepCount(unsigned int minSteps, unsigned int maxSteps)
Sample a number of steps to execute a control for.
virtual void sample(Control *control)
Sample a control. All other control sampling functions default to this one, unless a user-specified i...
A control space representing the space of applicable controls.
Definition: ControlSpace.h:66
Definition of an abstract state.
Definition: State.h:50
RNG rng_
Instance of random number generator.
virtual void sampleNext(Control *control, const Control *previous)
Sample a control, given the previously applied control. The default implementation calls the first de...
virtual void sampleNext(Control *control, const Control *previous)
Sample a control, given the previously applied control. The default implementation calls the first de...
virtual ~CompoundControlSampler(void)
Destructor. This frees the added samplers as well.
ControlSampler(const ControlSpace *space)
Constructor takes the state space to construct samples for as argument.
boost::function< ControlSamplerPtr(const ControlSpace *)> ControlSamplerAllocator
Definition of a function that can allocate a control sampler.
CompoundControlSampler(const ControlSpace *space)
Constructor.