PlannerMultiLevel.cpp
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2020,
5  * Max Planck Institute for Intelligent Systems (MPI-IS).
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the MPI-IS nor the names
19  * of its contributors may be used to endorse or promote products
20  * derived from this software without specific prior written
21  * permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *********************************************************************/
36 
37 /* Author: Andreas Orthey */
38 
39 #include <ompl/multilevel/datastructures/PlannerMultiLevel.h>
40 
41 using namespace ompl::multilevel;
42 
43 PlannerMultiLevel::PlannerMultiLevel(std::vector<ompl::base::SpaceInformationPtr> &siVec, std::string type)
44  : BaseT(siVec.back(), type), siVec_(siVec)
45 {
46 }
47 
49 {
50  siVec_.push_back(si);
51 }
52 
53 PlannerMultiLevel::PlannerMultiLevel(ompl::base::SpaceInformationPtr si, std::string type) : BaseT(si, type)
54 {
55  siVec_.push_back(si);
56 }
57 
58 PlannerMultiLevel::~PlannerMultiLevel()
59 {
60 }
61 
63 {
64  BaseT::clear();
65  solutions_.clear();
66  pdef_->clearSolutionPaths();
67  for (unsigned int k = 0; k < pdefVec_.size(); k++)
68  {
69  pdefVec_.at(k)->clearSolutionPaths();
70  }
71 }
72 
74 {
75  std::vector<int> dimensionsPerLevel;
76  for (unsigned int k = 0; k < siVec_.size(); k++)
77  {
78  unsigned int Nk = siVec_.at(k)->getStateDimension();
79  dimensionsPerLevel.push_back(Nk);
80  }
81  return dimensionsPerLevel;
82 }
83 
85 {
86  return siVec_.size();
87 }
88 
90 {
91  return pdefVec_.at(level);
92 }
93 
95 {
96  return pdefVec_.at(level);
97 }
98 
99 const std::vector<ompl::base::ProblemDefinitionPtr> &PlannerMultiLevel::getProblemDefinitionVector() const
100 {
101  return pdefVec_;
102 }
Base class for a planner.
Definition: Planner.h:279
A shared pointer wrapper for ompl::base::SpaceInformation.
ompl::base::ProblemDefinitionPtr & getProblemDefinitionNonConst(int level)
Get ompl::base::ProblemDefinitionPtr for a specific level (non const)
ProblemDefinitionPtr pdef_
The user set problem definition.
Definition: Planner.h:477
This namespace contains datastructures and planners to exploit multilevel abstractions,...
int getLevels() const
Number of multilevel abstractions.
PlannerMultiLevel(std::vector< ompl::base::SpaceInformationPtr > &siVec, std::string type="PlannerMultiLevel")
Constructor for a set of ompl::base::SpaceInformationPtr which represent different abstraction levels...
const std::vector< ompl::base::ProblemDefinitionPtr > & getProblemDefinitionVector() const
Get all ompl::base::ProblemDefinitionPtr for all levels in the hierarchy.
virtual void clear() override
Clear multilevel planner by clearing all levels.
std::vector< ompl::base::ProblemDefinitionPtr > pdefVec_
Sequence of ProblemDefinitionPtr.
std::vector< int > getDimensionsPerLevel() const
Get dimensionality of the multilevel abstraction.
A shared pointer wrapper for ompl::base::ProblemDefinition.
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: Planner.cpp:118
std::vector< ompl::base::SpaceInformationPtr > siVec_
Each abstraction level has a unique ompl::base::SpaceInformationPtr.
std::vector< ompl::base::PathPtr > solutions_
Solution paths on each abstraction level.
const ProblemDefinitionPtr & getProblemDefinition() const
Get the problem definition the planner is trying to solve.
Definition: Planner.cpp:71