Program Listing for File SimpleSetup.h
↰ Return to documentation for file (src/ompl/control/SimpleSetup.h
)
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2010, Rice University
* 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 Rice University 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_CONTROL_SIMPLE_SETUP_
#define OMPL_CONTROL_SIMPLE_SETUP_
#include "ompl/base/Planner.h"
#include "ompl/control/SpaceInformation.h"
#include "ompl/control/PlannerData.h"
#include "ompl/base/ProblemDefinition.h"
#include "ompl/control/PathControl.h"
#include "ompl/geometric/PathGeometric.h"
#include "ompl/util/Console.h"
#include "ompl/util/Exception.h"
namespace ompl
{
namespace control
{
OMPL_CLASS_FORWARD(SimpleSetup);
class SimpleSetup
{
public:
explicit SimpleSetup(const SpaceInformationPtr &si);
explicit SimpleSetup(const ControlSpacePtr &space);
virtual ~SimpleSetup() = default;
const SpaceInformationPtr &getSpaceInformation() const
{
return si_;
}
const base::ProblemDefinitionPtr &getProblemDefinition() const
{
return pdef_;
}
base::ProblemDefinitionPtr &getProblemDefinition()
{
return pdef_;
}
const base::StateSpacePtr &getStateSpace() const
{
return si_->getStateSpace();
}
const ControlSpacePtr &getControlSpace() const
{
return si_->getControlSpace();
}
const base::StateValidityCheckerPtr &getStateValidityChecker() const
{
return si_->getStateValidityChecker();
}
const StatePropagatorPtr &getStatePropagator() const
{
return si_->getStatePropagator();
}
const base::GoalPtr &getGoal() const
{
return pdef_->getGoal();
}
const base::PlannerPtr &getPlanner() const
{
return planner_;
}
const base::PlannerAllocator &getPlannerAllocator() const
{
return pa_;
}
bool haveExactSolutionPath() const;
bool haveSolutionPath() const
{
return pdef_->getSolutionPath() != nullptr;
}
PathControl &getSolutionPath() const;
void getPlannerData(base::PlannerData &pd) const;
void setStateValidityChecker(const base::StateValidityCheckerPtr &svc)
{
si_->setStateValidityChecker(svc);
}
void setStateValidityChecker(const base::StateValidityCheckerFn &svc)
{
si_->setStateValidityChecker(svc);
}
void setStatePropagator(const StatePropagatorFn &sp)
{
si_->setStatePropagator(sp);
}
void setStatePropagator(const StatePropagatorPtr &sp)
{
si_->setStatePropagator(sp);
}
void setOptimizationObjective(const base::OptimizationObjectivePtr &optimizationObjective)
{
pdef_->setOptimizationObjective(optimizationObjective);
}
void setStartAndGoalStates(const base::ScopedState<> &start, const base::ScopedState<> &goal,
const double threshold = std::numeric_limits<double>::epsilon())
{
pdef_->setStartAndGoalStates(start, goal, threshold);
}
void setGoalState(const base::ScopedState<> &goal,
const double threshold = std::numeric_limits<double>::epsilon())
{
pdef_->setGoalState(goal, threshold);
}
void addStartState(const base::ScopedState<> &state)
{
pdef_->addStartState(state);
}
void clearStartStates()
{
pdef_->clearStartStates();
}
void setStartState(const base::ScopedState<> &state)
{
clearStartStates();
addStartState(state);
}
void setGoal(const base::GoalPtr &goal)
{
pdef_->setGoal(goal);
}
void setPlanner(const base::PlannerPtr &planner)
{
if (planner && planner->getSpaceInformation().get() != si_.get())
throw Exception("Planner instance does not match space information");
planner_ = planner;
configured_ = false;
}
void setPlannerAllocator(const base::PlannerAllocator &pa)
{
pa_ = pa;
planner_.reset();
configured_ = false;
}
virtual base::PlannerStatus solve(double time = 1.0);
virtual base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc);
base::PlannerStatus getLastPlannerStatus() const
{
return last_status_;
}
double getLastPlanComputationTime() const
{
return planTime_;
}
virtual void clear();
virtual void print(std::ostream &out = std::cout) const;
virtual void setup();
protected:
SpaceInformationPtr si_;
base::ProblemDefinitionPtr pdef_;
base::PlannerPtr planner_;
base::PlannerAllocator pa_;
bool configured_;
double planTime_;
base::PlannerStatus last_status_;
};
}
}
#endif