00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef OMPL_CONTROL_CONTROL_SPACE_
00038 #define OMPL_CONTROL_CONTROL_SPACE_
00039
00040 #include "ompl/base/StateSpace.h"
00041 #include "ompl/control/Control.h"
00042 #include "ompl/control/ControlSampler.h"
00043 #include "ompl/util/Console.h"
00044 #include "ompl/util/ClassForward.h"
00045 #include <boost/concept_check.hpp>
00046 #include <boost/noncopyable.hpp>
00047 #include <iostream>
00048 #include <vector>
00049
00050 namespace ompl
00051 {
00052
00053 namespace control
00054 {
00055
00057 ClassForward(ControlSpace);
00058
00063 class ControlSpace : private boost::noncopyable
00064 {
00065 public:
00066
00068 ControlSpace(const base::StateSpacePtr &stateSpace);
00069
00070 virtual ~ControlSpace(void);
00071
00073 template<class T>
00074 T* as(void)
00075 {
00077 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, ControlSpace*>));
00078
00079 return static_cast<T*>(this);
00080 }
00081
00083 template<class T>
00084 const T* as(void) const
00085 {
00087 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, ControlSpace*>));
00088
00089 return static_cast<const T*>(this);
00090 }
00091
00093 const std::string& getName(void) const;
00094
00096 void setName(const std::string &name);
00097
00099 const base::StateSpacePtr& getStateSpace(void) const
00100 {
00101 return stateSpace_;
00102 }
00103
00105 virtual unsigned int getDimension(void) const = 0;
00106
00108 virtual Control* allocControl(void) const = 0;
00109
00111 virtual void freeControl(Control *control) const = 0;
00112
00114 virtual void copyControl(Control *destination, const Control *source) const = 0;
00115
00117 virtual bool equalControls(const Control *control1, const Control *control2) const = 0;
00118
00120 virtual void nullControl(Control *control) const = 0;
00121
00123 virtual ControlSamplerPtr allocControlSampler(void) const = 0;
00124
00129 virtual double* getValueAddressAtIndex(Control *control, const unsigned int index) const;
00130
00132 virtual void printControl(const Control *control, std::ostream &out) const;
00133
00135 virtual void printSettings(std::ostream &out) const;
00136
00138 virtual void setup(void);
00139
00140 protected:
00141
00143 base::StateSpacePtr stateSpace_;
00144
00145 private:
00146
00148 std::string name_;
00149 };
00150
00152 class CompoundControlSpace : public ControlSpace
00153 {
00154 public:
00155
00157 typedef CompoundControl ControlType;
00158
00160 CompoundControlSpace(const base::StateSpacePtr &stateSpace) : ControlSpace(stateSpace), componentCount_(0), locked_(false)
00161 {
00162 }
00163
00164 virtual ~CompoundControlSpace(void)
00165 {
00166 }
00167
00169 template<class T>
00170 T* as(const unsigned int index) const
00171 {
00173 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, ControlSpace*>));
00174
00175 return static_cast<T*>(getSubSpace(index).get());
00176 }
00177
00179 virtual void addSubSpace(const ControlSpacePtr &component);
00180
00182 unsigned int getSubSpaceCount(void) const;
00183
00185 const ControlSpacePtr& getSubSpace(const unsigned int index) const;
00186
00188 const ControlSpacePtr& getSubSpace(const std::string &name) const;
00189
00190 virtual unsigned int getDimension(void) const;
00191
00192 virtual Control* allocControl(void) const;
00193
00194 virtual void freeControl(Control *control) const;
00195
00196 virtual void copyControl(Control *destination, const Control *source) const;
00197
00198 virtual bool equalControls(const Control *control1, const Control *control2) const;
00199
00200 virtual void nullControl(Control *control) const;
00201
00202 virtual ControlSamplerPtr allocControlSampler(void) const;
00203
00204 virtual double* getValueAddressAtIndex(Control *control, const unsigned int index) const;
00205
00206 virtual void printControl(const Control *control, std::ostream &out = std::cout) const;
00207
00208 virtual void printSettings(std::ostream &out) const;
00209
00210 virtual void setup(void);
00211
00217 void lock(void);
00218
00219 protected:
00220
00222 std::vector<ControlSpacePtr> components_;
00223
00225 unsigned int componentCount_;
00226
00228 bool locked_;
00229 };
00230 }
00231 }
00232
00233 #endif