ompl/base/spaces/RealVectorStateProjections.h
00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Rice University 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of the Rice University nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 /* Author: Ioan Sucan */ 00036 00037 #ifndef OMPL_BASE_SPACES_REAL_VECTOR_STATE_PROJECTIONS_ 00038 #define OMPL_BASE_SPACES_REAL_VECTOR_STATE_PROJECTIONS_ 00039 00040 #include "ompl/base/ProjectionEvaluator.h" 00041 #include "ompl/base/spaces/RealVectorStateSpace.h" 00042 00043 namespace ompl 00044 { 00045 namespace base 00046 { 00047 00053 class RealVectorLinearProjectionEvaluator : public ProjectionEvaluator 00054 { 00055 public: 00056 00059 RealVectorLinearProjectionEvaluator(const StateSpace *space, const std::vector<double> &cellSizes, 00060 const ProjectionMatrix::Matrix &projection); 00061 00064 RealVectorLinearProjectionEvaluator(const StateSpacePtr &space, const std::vector<double> &cellSizes, 00065 const ProjectionMatrix::Matrix &projection); 00066 00069 RealVectorLinearProjectionEvaluator(const StateSpace *space, 00070 const ProjectionMatrix::Matrix &projection); 00071 00074 RealVectorLinearProjectionEvaluator(const StateSpacePtr &space, 00075 const ProjectionMatrix::Matrix &projection); 00076 00077 virtual unsigned int getDimension() const; 00078 00079 virtual void project(const State *state, EuclideanProjection &projection) const; 00080 00081 protected: 00082 00084 ProjectionMatrix projection_; 00085 00086 }; 00087 00089 class RealVectorRandomLinearProjectionEvaluator : public RealVectorLinearProjectionEvaluator 00090 { 00091 public: 00092 00095 RealVectorRandomLinearProjectionEvaluator(const StateSpace *space, const std::vector<double> &cellSizes) : 00096 RealVectorLinearProjectionEvaluator(space, cellSizes, ProjectionMatrix::ComputeRandom(space->getDimension(), cellSizes.size())) 00097 { 00098 } 00099 00102 RealVectorRandomLinearProjectionEvaluator(const StateSpacePtr &space, const std::vector<double> &cellSizes) : 00103 RealVectorLinearProjectionEvaluator(space, cellSizes, ProjectionMatrix::ComputeRandom(space->getDimension(), cellSizes.size())) 00104 { 00105 } 00106 00109 RealVectorRandomLinearProjectionEvaluator(const StateSpace *space, unsigned int dim) : 00110 RealVectorLinearProjectionEvaluator(space, ProjectionMatrix::ComputeRandom(space->getDimension(), dim, 00111 space->as<RealVectorStateSpace>()->getBounds().getDifference())) 00112 { 00113 } 00114 00117 RealVectorRandomLinearProjectionEvaluator(const StateSpacePtr &space, unsigned int dim) : 00118 RealVectorLinearProjectionEvaluator(space, ProjectionMatrix::ComputeRandom(space->getDimension(), dim, 00119 space->as<RealVectorStateSpace>()->getBounds().getDifference())) 00120 { 00121 } 00122 00123 }; 00124 00126 class RealVectorOrthogonalProjectionEvaluator : public ProjectionEvaluator 00127 { 00128 public: 00129 00132 RealVectorOrthogonalProjectionEvaluator(const StateSpace *space, const std::vector<double> &cellSizes, 00133 const std::vector<unsigned int> &components); 00134 00137 RealVectorOrthogonalProjectionEvaluator(const StateSpacePtr &space, const std::vector<double> &cellSizes, 00138 const std::vector<unsigned int> &components); 00139 00142 RealVectorOrthogonalProjectionEvaluator(const StateSpace *space, const std::vector<unsigned int> &components); 00143 00146 RealVectorOrthogonalProjectionEvaluator(const StateSpacePtr &space, const std::vector<unsigned int> &components); 00147 00148 virtual unsigned int getDimension() const; 00149 00150 virtual void defaultCellSizes(); 00151 00152 virtual void project(const State *state, EuclideanProjection &projection) const; 00153 00154 protected: 00155 00157 void copyBounds(); 00158 00160 std::vector<unsigned int> components_; 00161 00162 }; 00163 00165 class RealVectorIdentityProjectionEvaluator : public ProjectionEvaluator 00166 { 00167 public: 00168 00171 RealVectorIdentityProjectionEvaluator(const StateSpace *space, const std::vector<double> &cellSizes); 00172 00175 RealVectorIdentityProjectionEvaluator(const StateSpacePtr &space, const std::vector<double> &cellSizes); 00176 00179 RealVectorIdentityProjectionEvaluator(const StateSpace *space); 00180 00183 RealVectorIdentityProjectionEvaluator(const StateSpacePtr &space); 00184 00185 virtual unsigned int getDimension() const; 00186 00187 virtual void defaultCellSizes(); 00188 00189 virtual void setup(); 00190 00191 virtual void project(const State *state, EuclideanProjection &projection) const; 00192 00193 private: 00194 00196 void copyBounds(); 00197 00199 std::size_t copySize_; 00200 00201 }; 00202 00203 } 00204 } 00205 #endif