ompl_interface.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2011, Willow Garage, Inc.
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the Willow Garage nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00035 /* Author: Ioan Sucan, Sachin Chitta */
00036 
00037 #ifndef MOVEIT_OMPL_INTERFACE_OMPL_INTERFACE_
00038 #define MOVEIT_OMPL_INTERFACE_OMPL_INTERFACE_
00039 
00040 #include <moveit/ompl_interface/planning_context_manager.h>
00041 #include <moveit/ompl_interface/constraints_library.h>
00042 #include <moveit/constraint_samplers/constraint_sampler_manager.h>
00043 #include <moveit/constraint_sampler_manager_loader/constraint_sampler_manager_loader.h>
00044 #include <moveit/planning_interface/planning_interface.h>
00045 #include <moveit_msgs/MotionPlanRequest.h>
00046 #include <moveit_msgs/MotionPlanResponse.h>
00047 #include <string>
00048 #include <map>
00049 #include <ros/ros.h>
00050 
00052 namespace ompl_interface
00053 {
00054 
00057 class OMPLInterface
00058 {
00059 public:
00060 
00062   OMPLInterface(const robot_model::RobotModelConstPtr &kmodel, const ros::NodeHandle &nh = ros::NodeHandle("~"));
00063 
00066   OMPLInterface(const robot_model::RobotModelConstPtr &kmodel, const planning_interface::PlannerConfigurationMap &pconfig, const ros::NodeHandle &nh = ros::NodeHandle("~"));
00067 
00068   virtual ~OMPLInterface();
00069 
00072   void setPlannerConfigurations(const planning_interface::PlannerConfigurationMap &pconfig);
00073 
00076   const planning_interface::PlannerConfigurationMap& getPlannerConfigurations() const
00077   {
00078     return context_manager_.getPlannerConfigurations();
00079   }
00080 
00082   bool solve(const planning_scene::PlanningSceneConstPtr& planning_scene,
00083              const planning_interface::MotionPlanRequest &req, planning_interface::MotionPlanResponse &res) const;
00084 
00086   bool solve(const planning_scene::PlanningSceneConstPtr& planning_scene,
00087              const planning_interface::MotionPlanRequest &req, planning_interface::MotionPlanDetailedResponse &res) const;
00088 
00089   ModelBasedPlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene,
00090                                                   const planning_interface::MotionPlanRequest &req) const;
00091   ModelBasedPlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene,
00092                                                   const planning_interface::MotionPlanRequest &req,
00093                                                   moveit_msgs::MoveItErrorCodes &error_code) const;
00094 
00095   ModelBasedPlanningContextPtr getPlanningContext(const std::string &config, const std::string &factory_type = "") const;
00096 
00097   ModelBasedPlanningContextPtr getLastPlanningContext() const
00098   {
00099     return context_manager_.getLastPlanningContext();
00100   }
00101 
00102   const PlanningContextManager& getPlanningContextManager() const
00103   {
00104     return context_manager_;
00105   }
00106 
00107   PlanningContextManager& getPlanningContextManager()
00108   {
00109     return context_manager_;
00110   }
00111 
00112   ConstraintsLibrary& getConstraintsLibrary()
00113   {
00114     return *constraints_library_;
00115   }
00116 
00117   const ConstraintsLibrary& getConstraintsLibrary() const
00118   {
00119     return *constraints_library_;
00120   }
00121 
00122   constraint_samplers::ConstraintSamplerManager& getConstraintSamplerManager()
00123   {
00124     return *constraint_sampler_manager_;
00125   }
00126 
00127   const constraint_samplers::ConstraintSamplerManager& getConstraintSamplerManager() const
00128   {
00129     return *constraint_sampler_manager_;
00130   }
00131 
00132   void useConstraintsApproximations(bool flag)
00133   {
00134     use_constraints_approximations_ = flag;
00135   }
00136 
00137   bool isUsingConstraintsApproximations() const
00138   {
00139     return use_constraints_approximations_;
00140   }
00141 
00142   void loadConstraintApproximations(const std::string &path);
00143 
00144   void saveConstraintApproximations(const std::string &path);
00145 
00146   bool simplifySolutions() const
00147   {
00148     return simplify_solutions_;
00149   }
00150 
00151   void simplifySolutions(bool flag)
00152   {
00153     simplify_solutions_ = true;
00154   }
00155 
00157   bool saveConstraintApproximations();
00158 
00160   bool loadConstraintApproximations();
00161 
00163   void printStatus();
00164 
00165 protected:
00166 
00168   void loadPlannerConfigurations();
00169 
00171   void loadConstraintSamplers();
00172 
00173   void configureContext(const ModelBasedPlanningContextPtr &context) const;
00174 
00176   ModelBasedPlanningContextPtr prepareForSolve(const planning_interface::MotionPlanRequest &req,
00177                                                const planning_scene::PlanningSceneConstPtr& planning_scene,
00178                                                moveit_msgs::MoveItErrorCodes *error_code,
00179                                                unsigned int *attempts, double *timeout) const;
00180 
00181 
00182   ros::NodeHandle nh_; 
00183 
00185   robot_model::RobotModelConstPtr kmodel_;
00186 
00187   constraint_samplers::ConstraintSamplerManagerPtr constraint_sampler_manager_;
00188 
00189   PlanningContextManager context_manager_;
00190 
00191   ConstraintsLibraryPtr constraints_library_;
00192   bool use_constraints_approximations_;
00193 
00194   bool simplify_solutions_;
00195 
00196 private:
00197 
00198   constraint_sampler_manager_loader::ConstraintSamplerManagerLoaderPtr constraint_sampler_manager_loader_;
00199 
00200 };
00201 
00202 }
00203 
00204 
00205 #endif


ompl
Author(s): Ioan Sucan
autogenerated on Mon Oct 6 2014 11:12:03