Loading...
Searching...
No Matches
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 <functional>
46
47namespace ompl
48{
49 namespace control
50 {
52 OMPL_CLASS_FORWARD(ControlSpace);
54
56
57 OMPL_CLASS_FORWARD(ControlSampler);
59
62
68 class ControlSampler
69 {
70 public:
71 // non-copyable
72 ControlSampler(const ControlSampler &) = delete;
73 ControlSampler &operator=(const ControlSampler &) = delete;
74
76 ControlSampler(const ControlSpace *space) : space_(space)
77 {
78 }
79
80 virtual ~ControlSampler() = default;
81
85 virtual void sample(Control *control) = 0;
86
95 virtual void sample(Control *control, const base::State *state);
96
104 virtual void sampleNext(Control *control, const Control *previous);
105
113 virtual void sampleNext(Control *control, const Control *previous, const base::State *state);
114
116 virtual unsigned int sampleStepCount(unsigned int minSteps, unsigned int maxSteps);
117
118 protected:
121
124 };
125
128 class CompoundControlSampler : public ControlSampler
129 {
130 public:
132 CompoundControlSampler(const ControlSpace *space) : ControlSampler(space)
133 {
134 }
135
137 ~CompoundControlSampler() override = default;
138
142 virtual void addSampler(const ControlSamplerPtr &sampler);
143
144 void sample(Control *control) override;
145 void sample(Control *control, const base::State *state) override;
146 void sampleNext(Control *control, const Control *previous) override;
147 void sampleNext(Control *control, const Control *previous, const base::State *state) override;
148
149 protected:
151 std::vector<ControlSamplerPtr> samplers_;
152
153 private:
155 unsigned int samplerCount_;
156 };
157
160 }
161}
162
163#endif
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition of an abstract state.
Definition State.h:50
void sampleNext(Control *control, const Control *previous) override
Sample a control, given the previously applied control. The default implementation calls the first de...
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...
std::vector< ControlSamplerPtr > samplers_
The instances of samplers used for compound sampler.
CompoundControlSampler(const ControlSpace *space)
Constructor.
~CompoundControlSampler() override=default
Destructor. This frees the added samplers as well.
void sample(Control *control) override
Sample a control. All other control sampling functions default to this one, unless a user-specified i...
A shared pointer wrapper for ompl::control::ControlSampler.
Abstract definition of a control sampler. Motion planners that need to sample controls will call func...
virtual void sampleNext(Control *control, const Control *previous)
Sample a control, given the previously applied control. The default implementation calls the first de...
virtual unsigned int sampleStepCount(unsigned int minSteps, unsigned int maxSteps)
Sample a number of steps to execute a control for.
const ControlSpace * space_
The control space this sampler operates on.
virtual void sample(Control *control)=0
Sample a control. All other control sampling functions default to this one, unless a user-specified i...
ControlSampler(const ControlSpace *space)
Constructor takes the state space to construct samples for as argument.
RNG rng_
Instance of random number generator.
A control space representing the space of applicable controls.
Definition of an abstract control.
Definition Control.h:48
This namespace contains sampling based planning routines used by planning under differential constrai...
Definition Control.h:45
std::function< ControlSamplerPtr(const ControlSpace *)> ControlSamplerAllocator
Definition of a function that can allocate a control sampler.
Main namespace. Contains everything in this library.