ParallelPlan.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, Willow Garage, Inc.
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 Willow Garage 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: Ioan Sucan */
36 
37 #ifndef OMPL_TOOLS_MULTIPLAN_PARALLEL_PLAN_
38 #define OMPL_TOOLS_MULTIPLAN_PARALLEL_PLAN_
39 
40 #include "ompl/base/Planner.h"
41 #include "ompl/geometric/PathGeometric.h"
42 #include <mutex>
43 
44 namespace ompl
45 {
47  namespace geometric
48  {
49  OMPL_CLASS_FORWARD(PathHybridization);
50  }
52 
53  namespace tools
54  {
56  OMPL_CLASS_FORWARD(ParallelPlan);
58 
67  {
68  public:
71 
72  virtual ~ParallelPlan();
73 
75  void addPlanner(const base::PlannerPtr &planner);
76 
78  void addPlannerAllocator(const base::PlannerAllocator &pa);
79 
81  void clearHybridizationPaths();
82 
84  void clearPlanners();
85 
88  {
89  return pdef_;
90  }
91 
98  base::PlannerStatus solve(double solveTime, bool hybridize = true);
99 
106  base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc, bool hybridize = true);
107 
116  base::PlannerStatus solve(double solveTime, std::size_t minSolCount, std::size_t maxSolCount,
117  bool hybridize = true);
118 
127  base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc, std::size_t minSolCount,
128  std::size_t maxSolCount, bool hybridize = true);
129 
130  protected:
133  void solveOne(base::Planner *planner, std::size_t minSolCount,
135 
137  void solveMore(base::Planner *planner, std::size_t minSolCount, std::size_t maxSolCount,
139 
142 
144  std::vector<base::PlannerPtr> planners_;
145 
148 
150  std::mutex phlock_;
151 
152  private:
154  unsigned int foundSolCount_;
155 
157  std::mutex foundSolCountLock_;
158  };
159  }
160 }
161 
162 #endif
A shared pointer wrapper for ompl::geometric::PathHybridization.
This is a utility that allows executing multiple planners in parallel, until one or more find a solut...
Definition: ParallelPlan.h:66
A shared pointer wrapper for ompl::base::ProblemDefinition.
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
base::ProblemDefinitionPtr pdef_
The problem definition used.
Definition: ParallelPlan.h:141
Main namespace. Contains everything in this library.
Definition: AppBase.h:21
std::vector< base::PlannerPtr > planners_
The set of planners to be used.
Definition: ParallelPlan.h:144
geometric::PathHybridizationPtr phybrid_
The instance of the class that performs path hybridization.
Definition: ParallelPlan.h:147
A shared pointer wrapper for ompl::base::Planner.
std::mutex phlock_
Lock for phybrid_.
Definition: ParallelPlan.h:150
Base class for a planner.
Definition: Planner.h:223
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
std::function< PlannerPtr(const SpaceInformationPtr &)> PlannerAllocator
Definition of a function that can allocate a planner.
Definition: Planner.h:433
const base::ProblemDefinitionPtr & getProblemDefinition() const
Get the problem definition used.
Definition: ParallelPlan.h:87