Program Listing for File PathGeometric.h

Return to documentation for file (src/ompl/geometric/PathGeometric.h)

/*********************************************************************
 * 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_GEOMETRIC_
#define OMPL_GEOMETRIC_PATH_GEOMETRIC_

#include "ompl/base/SpaceInformation.h"
#include "ompl/base/Path.h"
#include <vector>
#include <utility>

namespace ompl
{
    namespace base
    {
        OMPL_CLASS_FORWARD(OptimizationObjective);
    }  // namespace base

    namespace geometric
    {

        OMPL_CLASS_FORWARD(PathGeometric);

        class PathGeometric : public base::Path
        {
        public:
            PathGeometric(const base::SpaceInformationPtr &si) : base::Path(si)
            {
            }

            PathGeometric(const PathGeometric &path);

            PathGeometric(const base::SpaceInformationPtr &si, const base::State *state);

            PathGeometric(const base::SpaceInformationPtr &si, const base::State *state1, const base::State *state2);

            PathGeometric(const base::SpaceInformationPtr &si, std::vector<const base::State *> &states);

            ~PathGeometric() override
            {
                freeMemory();
            }

            PathGeometric &operator=(const PathGeometric &other);

            base::Cost cost(const base::OptimizationObjectivePtr &obj) const override;

            double length() const override;

            bool check() const override;

            double smoothness() const;

            double clearance() const;

            void print(std::ostream &out) const override;

            virtual void printAsMatrix(std::ostream &out) const;

            void interpolate(unsigned int count);

            void interpolate();

            void subdivide();

            void reverse();

            std::pair<bool, bool> checkAndRepair(unsigned int attempts);

            void overlay(const PathGeometric &over, unsigned int startIndex = 0);

            void append(const base::State *state);

            void append(const PathGeometric &path);

            void prepend(const base::State *state);

            void keepAfter(const base::State *state);

            void keepBefore(const base::State *state);

            void random();

            bool randomValid(unsigned int attempts);
            int getClosestIndex(const base::State *state) const;

            std::vector<base::State *> &getStates()
            {
                return states_;
            }

            base::State *getState(unsigned int index)
            {
                return states_[index];
            }

            const base::State *getState(unsigned int index) const
            {
                return states_[index];
            }

            std::size_t getStateCount() const
            {
                return states_.size();
            }

            void clear();

        protected:
            void freeMemory();

            void copyFrom(const PathGeometric &other);

            std::vector<base::State *> states_;
        };
    }  // namespace geometric
}  // namespace ompl

#endif