/usr/include/ompl/geometric/PathSimplifier.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 | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage 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_GEOMETRIC_PATH_SIMPLIFIER_
#define OMPL_GEOMETRIC_PATH_SIMPLIFIER_
#include "ompl/base/SpaceInformation.h"
#include "ompl/geometric/PathGeometric.h"
#include "ompl/base/PlannerTerminationCondition.h"
#include "ompl/util/ClassForward.h"
#include "ompl/util/RandomNumbers.h"
#include "ompl/util/Console.h"
#include <limits>
namespace ompl
{
namespace geometric
{
/// @cond IGNORE
/** \brief Forward declaration of ompl::geometric::PathSimplifier */
OMPL_CLASS_FORWARD(PathSimplifier);
/// @endcond
/** \class ompl::geometric::PathSimplifierPtr
\brief A boost shared pointer wrapper for ompl::geometric::PathSimplifier */
/** \brief This class contains routines that attempt to simplify geometric paths.
Some of these are in fact routines that shorten the path, and do not
necessarily make it smoother. */
class PathSimplifier
{
public:
/** \brief Create an instance for a specified space information */
PathSimplifier(const base::SpaceInformationPtr &si) : si_(si), freeStates_(true)
{
}
virtual ~PathSimplifier()
{
}
/** \brief Given a path, attempt to remove vertices from
it while keeping the path valid. This is an iterative
process that attempts to do "short-cutting" on the
path. Connection is attempted between non-consecutive
way-points on the path. If the connection is
successful, the path is shortened by removing the
in-between way-points. This function returns true if
changes were made to the path.
\param path the path to reduce vertices from
\param maxSteps the maximum number of attempts to
"short-cut" the path. If this value is set to 0 (the
default), the number of attempts made is equal to the
number of states in \e path.
\param maxEmptySteps not all iterations of this function
produce a simplification. If an iteration does not
produce a simplification, it is called an empty
step. \e maxEmptySteps denotes the maximum number of
consecutive empty steps before the simplification
process terminates. If this value is set to 0 (the
default), the number of attempts made is equal to the
number of states in \e path.
\param rangeRatio the maximum distance between states
a connection is attempted, as a fraction relative to
the total number of states (between 0 and 1).
*/
bool reduceVertices(PathGeometric &path, unsigned int maxSteps = 0, unsigned int maxEmptySteps = 0, double rangeRatio = 0.33);
/** \brief Given a path, attempt to shorten it while
maintaining its validity. This is an iterative process
that attempts to do "short-cutting" on the path.
Connection is attempted between random points along
the path segments. Unlike the reduceVertices()
function, this function does not sample only vertices
produced by the planner, but intermediate points on
the path. If the connection is successful, the path is
shortened by removing the in-between states (and new
vertices are created when needed). This function returns
true if changes were made to the path.
\param path the path to reduce vertices from
\param maxSteps the maximum number of attempts to
"short-cut" the path. If this value is set to 0 (the
default), the number of attempts made is equal to the
number of states in \e path.
\param maxEmptySteps not all iterations of this function
produce a simplification. If an iteration does not
produce a simplification, it is called an empty
step. \e maxEmptySteps denotes the maximum number of
consecutive empty steps before the simplification
process terminates. If this value is set to 0 (the
default), the number of attempts made is equal to the
number of states in \e path.
\param rangeRatio the maximum distance between states
a connection is attempted, as a fraction relative to
the total number of states (between 0 and 1).
\param snapToVertex While sampling random points on
the path, sometimes the points may be close to
vertices on the original path (way-points). This
function will then "snap to the near vertex", if the
distance is less than \e snapToVertex fraction of the
total path length. This should usually be a small
value (e.g., one percent of the total path length:
0.01; the default is half a percent)
\note This function assumes the triangle inequality holds and should not be run on non-metric spaces.
*/
bool shortcutPath(PathGeometric &path, unsigned int maxSteps = 0, unsigned int maxEmptySteps = 0, double rangeRatio = 0.33, double snapToVertex = 0.005);
/** \brief Given a path, attempt to remove vertices from
it while keeping the path valid. This is an iterative
process that attempts to do "short-cutting" on the
path. Connection is attempted between non-consecutive
states that are close along the path. If the
connection is successful, the path is shortened by
removing the in-between states. This function returns
true if changes were made to the path.
\param path the path to reduce vertices from
\param maxSteps the maximum number of attempts to
"short-cut" the path. If this value is set to 0 (the
default), the number of attempts made is equal to the
number of states in \e path. If this value is set to 0 (the
default), the number of attempts made is equal to the
number of states in \e path.
\param maxEmptySteps not all iterations of this function
produce a simplification. If an iteration does not
produce a simplification, it is called an empty
step. \e maxEmptySteps denotes the maximum number of
consecutive empty steps before the simplification
process terminates.
*/
bool collapseCloseVertices(PathGeometric &path, unsigned int maxSteps = 0, unsigned int maxEmptySteps = 0);
/** \brief Given a path, attempt to smooth it (the
validity of the path is maintained).
This function applies \e maxSteps steps of smoothing
with B-Splines. Fewer steps are applied if no progress
is detected: states are either not updated or their
update is smaller than \e minChange. At each step the
path is subdivided and states along it are updated
such that the smoothness is improved.
\note This function may significantly increase the number of states along the solution path.
\note This function assumes the triangle inequality holds and should not be run on non-metric spaces.
*/
void smoothBSpline(PathGeometric &path, unsigned int maxSteps = 5, double minChange = std::numeric_limits<double>::epsilon());
/** \brief Given a path, attempt to remove vertices from it while keeping the path valid. Then, try to smooth
the path. This function applies the same set of default operations to the path, except in non-metric spaces,
with the intention of simplifying it. In non-metric spaces, some operations are skipped because they do
not work correctly when the triangle inequality may not hold. */
void simplifyMax(PathGeometric &path);
/** \brief Run simplification algorithms on the path for at most \e maxTime seconds */
void simplify(PathGeometric &path, double maxTime);
/** \brief Run simplification algorithms on the path as long as the termination condition does not become true */
void simplify(PathGeometric &path, const base::PlannerTerminationCondition &ptc);
/** \brief Set this flag to false to avoid freeing the memory allocated for states that are removed from a path during simplification.
Setting this to true makes this free memory. Memory is freed by default (flag is true by default) */
void freeStates(bool flag);
/** \brief Return true if the memory of states is freed when they are removed from a path during simplification */
bool freeStates() const;
protected:
/** \brief The space information this path simplifier uses */
base::SpaceInformationPtr si_;
/** \brief Flag indicating whether the states removed from a motion should be freed */
bool freeStates_;
/** \brief Instance of random number generator */
RNG rng_;
};
}
}
#endif
|