/usr/include/ompl/control/ControlSpace.h is in libompl-dev 1.0.0+ds2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2010, Rice University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Rice University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Ioan Sucan */
#ifndef OMPL_CONTROL_CONTROL_SPACE_
#define OMPL_CONTROL_CONTROL_SPACE_
#include "ompl/base/StateSpace.h"
#include "ompl/control/Control.h"
#include "ompl/control/ControlSampler.h"
#include "ompl/control/ControlSpaceTypes.h"
#include "ompl/util/Console.h"
#include "ompl/util/ClassForward.h"
#include <boost/concept_check.hpp>
#include <boost/noncopyable.hpp>
#include <iostream>
#include <vector>
namespace ompl
{
namespace control
{
/// @cond IGNORE
/** \brief Forward declaration of ompl::control::ControlSpace */
OMPL_CLASS_FORWARD(ControlSpace);
/// @endcond
/** \class ompl::control::ControlSpacePtr
\brief A boost shared pointer wrapper for ompl::control::ControlSpace */
/** \brief A control space representing the space of applicable controls */
class ControlSpace : private boost::noncopyable
{
public:
/** \brief Construct a control space, given the state space */
ControlSpace(const base::StateSpacePtr &stateSpace);
virtual ~ControlSpace();
/** \brief Cast this instance to a desired type. */
template<class T>
T* as()
{
/** \brief Make sure the type we are casting to is indeed a control space */
BOOST_CONCEPT_ASSERT((boost::Convertible<T*, ControlSpace*>));
return static_cast<T*>(this);
}
/** \brief Cast this instance to a desired type. */
template<class T>
const T* as() const
{
/** \brief Make sure the type we are casting to is indeed a control space */
BOOST_CONCEPT_ASSERT((boost::Convertible<T*, ControlSpace*>));
return static_cast<const T*>(this);
}
/** \brief Get the name of the control space */
const std::string& getName() const;
/** \brief Set the name of the control space */
void setName(const std::string &name);
/** \brief Get the type of the control space. The type can be
used to verify whether two space instances are of
the same type */
int getType() const
{
return type_;
}
/** \brief Return the state space this control space depends on */
const base::StateSpacePtr& getStateSpace() const
{
return stateSpace_;
}
/** \brief Get the dimension of this control space */
virtual unsigned int getDimension() const = 0;
/** \brief Allocate memory for a control */
virtual Control* allocControl() const = 0;
/** \brief Free the memory of a control */
virtual void freeControl(Control *control) const = 0;
/** \brief Copy a control to another */
virtual void copyControl(Control *destination, const Control *source) const = 0;
/** \brief Check if two controls are the same */
virtual bool equalControls(const Control *control1, const Control *control2) const = 0;
/** \brief Make the control have no effect if it were to be applied to a state for any amount of time. */
virtual void nullControl(Control *control) const = 0;
/** \brief Allocate the default control sampler */
virtual ControlSamplerPtr allocDefaultControlSampler() const = 0;
/** \brief Allocate an instance of the control sampler for this space. This sampler will be allocated with the
sampler allocator that was previously specified by setControlSamplerAllocator() or, if no sampler allocator was specified,
allocDefaultControlSampler() is called */
virtual ControlSamplerPtr allocControlSampler() const;
/** \brief Set the sampler allocator to use */
void setControlSamplerAllocator(const ControlSamplerAllocator &csa);
/** \brief Clear the control sampler allocator (reset to default) */
void clearControlSamplerAllocator();
/** \brief Many controls contain a number of double values. This function provides a means to get the
memory address of a double value from a control \e control located at position \e index. The first double value
is returned for \e index = 0. If \e index is too large (does not point to any double values in the control),
the return value is NULL. */
virtual double* getValueAddressAtIndex(Control *control, const unsigned int index) const;
/** \brief Print a control to a stream */
virtual void printControl(const Control *control, std::ostream &out) const;
/** \brief Print the settings for this control space to a stream */
virtual void printSettings(std::ostream &out) const;
/** \brief Perform final setup steps. This function is automatically called by the SpaceInformation */
virtual void setup();
/** \brief Returns the serialization size for a single control in this space */
virtual unsigned int getSerializationLength() const;
/** \brief Serializes the given control into the serialization buffer. */
virtual void serialize(void *serialization, const Control *ctrl) const;
/** \brief Deserializes a control from the serialization buffer. */
virtual void deserialize(Control *ctrl, const void *serialization) const;
/** \brief Compute an array of ints that uniquely identifies the structure of the control space.
The first element of the signature is the number of integers that follow */
void computeSignature(std::vector<int> &signature) const;
/** \brief Check if the control space is compound */
virtual bool isCompound() const;
protected:
/** \brief A type assigned for this control space */
int type_;
/** \brief The state space controls can be applied to */
base::StateSpacePtr stateSpace_;
/** \brief An optional control sampler allocator */
ControlSamplerAllocator csa_;
private:
/** \brief The name of this control space */
std::string name_;
};
/** \brief A control space to allow the composition of control spaces */
class CompoundControlSpace : public ControlSpace
{
public:
/** \brief Define the type of control allocated by this control space */
typedef CompoundControl ControlType;
/** \brief Constructor. The corresponding state space needs to be specified. */
CompoundControlSpace(const base::StateSpacePtr &stateSpace) : ControlSpace(stateSpace), componentCount_(0), locked_(false)
{
}
virtual ~CompoundControlSpace()
{
}
/** \brief Cast a component of this instance to a desired type. */
template<class T>
T* as(const unsigned int index) const
{
/** \brief Make sure the type we are casting to is indeed a control space */
BOOST_CONCEPT_ASSERT((boost::Convertible<T*, ControlSpace*>));
return static_cast<T*>(getSubspace(index).get());
}
/** \brief Adds a control space as a component of the compound control space. */
virtual void addSubspace(const ControlSpacePtr &component);
/** \brief Get the number of control spaces that make up the compound control space */
unsigned int getSubspaceCount() const;
/** \brief Get a specific subspace from the compound control space */
const ControlSpacePtr& getSubspace(const unsigned int index) const;
/** \brief Get a specific subspace from the compound control space */
const ControlSpacePtr& getSubspace(const std::string &name) const;
virtual unsigned int getDimension() const;
virtual Control* allocControl() const;
virtual void freeControl(Control *control) const;
virtual void copyControl(Control *destination, const Control *source) const;
virtual bool equalControls(const Control *control1, const Control *control2) const;
virtual void nullControl(Control *control) const;
virtual ControlSamplerPtr allocDefaultControlSampler() const;
virtual double* getValueAddressAtIndex(Control *control, const unsigned int index) const;
virtual void printControl(const Control *control, std::ostream &out = std::cout) const;
virtual void printSettings(std::ostream &out) const;
virtual void setup();
/** \brief Returns the serialization size for a single control in this space */
virtual unsigned int getSerializationLength() const;
/** \brief Serializes the given control into the serialization buffer. */
virtual void serialize(void *serialization, const Control *ctrl) const;
/** \brief Deserializes a control from the serialization buffer. */
virtual void deserialize(Control *ctrl, const void *serialization) const;
virtual bool isCompound() const;
/** \brief Lock this control space. This means no further
control spaces can be added as components. This function can
be for instance called from the constructor of a state space
that inherits from CompoundControlSpace to prevent the
user to add further components. */
void lock();
protected:
/** \brief The component control spaces that make up the compound control space */
std::vector<ControlSpacePtr> components_;
/** \brief The number of contained components */
unsigned int componentCount_;
/** \brief Flag indicating whether adding further components is allowed or not */
bool locked_;
};
}
}
#endif
|