AnytimePathShortening.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, Rice University
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Rice University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Ryan Luna */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_ANYTIMEOPTIMIZATION_ANYTIMEPATHSHORTENING_
38 #define OMPL_GEOMETRIC_PLANNERS_ANYTIMEOPTIMIZATION_ANYTIMEPATHSHORTENING_
39 
40 #include "ompl/base/Planner.h"
41 #include <vector>
42 
43 namespace ompl
44 {
45  namespace geometric
46  {
68  {
69  public:
72 
74  ~AnytimePathShortening() override;
75 
78  void addPlanner(base::PlannerPtr &planner);
79 
84  void setProblemDefinition(const base::ProblemDefinitionPtr &pdef) override;
85 
93 
97  void clear() override;
98 
102  void getPlannerData(base::PlannerData &data) const override;
103 
105  virtual void getPlannerData(ompl::base::PlannerData &data, unsigned int idx) const;
106 
110  void setup() override;
111 
116  void checkValidity() override;
117 
119  unsigned int getNumPlanners() const;
120 
122  base::PlannerPtr getPlanner(unsigned int i) const;
123 
125  bool isShortcutting() const;
126 
128  void setShortcut(bool shortcut);
129 
131  bool isHybridizing() const;
132 
134  void setHybridize(bool hybridize);
135 
137  unsigned int maxHybridizationPaths() const;
138 
140  void setMaxHybridizationPath(unsigned int maxPathCount);
141 
143  void setDefaultNumPlanners(unsigned int numPlanners);
144 
146  unsigned int getDefaultNumPlanners() const;
147 
149  std::string getBestCost() const;
150 
151  protected:
154  virtual void threadSolve(base::Planner *planner, const base::PlannerTerminationCondition &ptc);
155 
157  std::vector<base::PlannerPtr> planners_;
158 
160  bool shortcut_;
161 
164 
167  unsigned int maxHybridPaths_;
168 
171  unsigned int defaultNumPlanners_;
172  };
173  }
174 }
175 #endif
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:174
bool isHybridizing() const
Return whether the anytime planner will extract a hybrid path from the set of solution paths...
base::PlannerPtr getPlanner(unsigned int i) const
Retrieve a pointer to the ith planner instance.
A shared pointer wrapper for ompl::base::ProblemDefinition.
void setMaxHybridizationPath(unsigned int maxPathCount)
Set the maximum number of paths that will be hybridized.
~AnytimePathShortening() override
Destructor.
void clear() override
Clear all internal planning datastructures. Planner settings are not affected. Subsequent calls to so...
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
void getPlannerData(base::PlannerData &data) const override
Get information about the most recent run of the motion planner.
AnytimePathShortening(const base::SpaceInformationPtr &si)
Constructor requires the space information to plan in.
unsigned int getDefaultNumPlanners() const
Get default number of planners used if none are specified.
void setHybridize(bool hybridize)
Enable/disable path hybridization on the set of solution paths.
void setDefaultNumPlanners(unsigned int numPlanners)
Set default number of planners to use if none are specified.
std::string getBestCost() const
Return best cost found so far by algorithm.
Main namespace. Contains everything in this library.
Definition: AppBase.h:21
unsigned int maxHybridPaths_
The maximum number of paths that will be hybridized. This prohibits hybridization of a very large pat...
A shared pointer wrapper for ompl::base::Planner.
Base class for a planner.
Definition: Planner.h:232
void checkValidity() override
Check to see if the planners are in a working state (setup has been called, a goal was set...
bool hybridize_
Flag indicating whether to hybridize the set of solution paths.
virtual void threadSolve(base::Planner *planner, const base::PlannerTerminationCondition &ptc)
The function that the planning threads execute when solving a motion planning problem.
void setShortcut(bool shortcut)
Enable/disable shortcutting on paths.
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
A shared pointer wrapper for ompl::base::SpaceInformation.
void setup() override
Perform any necessary configuration steps. This method also invokes ompl::base::SpaceInformation::set...
unsigned int defaultNumPlanners_
The number of planners to use if none are specified. This defaults to the number of cores...
bool isShortcutting() const
Return whether the anytime planner will perform shortcutting on paths.
base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override
Method that solves the motion planning problem. This method terminates under just two conditions...
void addPlanner(base::PlannerPtr &planner)
Adds the given planner to the set of planners used to compute candidate paths.
std::vector< base::PlannerPtr > planners_
The list of planners used for solving the problem.
unsigned int getNumPlanners() const
Retrieve the number of planners added.
void setProblemDefinition(const base::ProblemDefinitionPtr &pdef) override
Set the problem definition for the planners. The problem needs to be set before calling solve()...
unsigned int maxHybridizationPaths() const
Return the maximum number of paths that will be hybridized.
bool shortcut_
Flag indicating whether to shortcut paths.