00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2012, 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 Willow Garage, Inc. 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 */ 00036 00037 #ifndef MOVEIT_PLANNING_INTERFACE_PLANNING_INTERFACE_ 00038 #define MOVEIT_PLANNING_INTERFACE_PLANNING_INTERFACE_ 00039 00040 #include <moveit/macros/class_forward.h> 00041 #include <moveit/planning_scene/planning_scene.h> 00042 #include <moveit/planning_interface/planning_request.h> 00043 #include <moveit/planning_interface/planning_response.h> 00044 #include <string> 00045 #include <map> 00046 00048 namespace planning_interface 00049 { 00050 00055 struct PlannerConfigurationSettings 00056 { 00058 std::string group; 00059 00060 /* \brief Name of the configuration. If there is only one configuration, this should be the same as the group name. 00061 If there are multiple configurations, the form "group_name[config_name]" is expected for the name. */ 00062 std::string name; 00063 00065 std::map<std::string, std::string> config; 00066 }; 00067 00069 typedef std::map<std::string, PlannerConfigurationSettings> PlannerConfigurationMap; 00070 00071 00074 class PlanningContext 00075 { 00076 public: 00077 00079 PlanningContext(const std::string &name, const std::string &group); 00080 00081 virtual ~PlanningContext(); 00082 00084 const std::string& getGroupName() const 00085 { 00086 return group_; 00087 } 00088 00090 const std::string& getName() const 00091 { 00092 return name_; 00093 } 00094 00096 const planning_scene::PlanningSceneConstPtr& getPlanningScene() const 00097 { 00098 return planning_scene_; 00099 } 00100 00102 const MotionPlanRequest& getMotionPlanRequest() const 00103 { 00104 return request_; 00105 } 00106 00108 void setPlanningScene(const planning_scene::PlanningSceneConstPtr &planning_scene); 00109 00111 void setMotionPlanRequest(const MotionPlanRequest &request); 00112 00114 virtual bool solve(MotionPlanResponse &res) = 0; 00115 00117 virtual bool solve(MotionPlanDetailedResponse &res) = 0; 00118 00120 virtual bool terminate() = 0; 00121 00123 virtual void clear() = 0; 00124 00125 protected: 00126 00128 std::string name_; 00129 00131 std::string group_; 00132 00134 planning_scene::PlanningSceneConstPtr planning_scene_; 00135 00137 MotionPlanRequest request_; 00138 }; 00139 00140 MOVEIT_CLASS_FORWARD(PlanningContext); 00141 00143 class PlannerManager 00144 { 00145 public: 00146 00147 PlannerManager() 00148 { 00149 } 00150 00151 virtual ~PlannerManager() 00152 { 00153 } 00154 00158 virtual bool initialize(const robot_model::RobotModelConstPtr& model, const std::string &ns); 00159 00161 virtual std::string getDescription() const; 00162 00164 virtual void getPlanningAlgorithms(std::vector<std::string> &algs) const; 00165 00171 virtual PlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene, 00172 const MotionPlanRequest &req, 00173 moveit_msgs::MoveItErrorCodes &error_code) const = 0; 00174 00176 PlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene, 00177 const MotionPlanRequest &req) const; 00178 00180 virtual bool canServiceRequest(const MotionPlanRequest &req) const = 0; 00181 00183 virtual void setPlannerConfigurations(const PlannerConfigurationMap &pcs); 00184 00186 const PlannerConfigurationMap& getPlannerConfigurations() const 00187 { 00188 return config_settings_; 00189 } 00190 00192 void terminate() const; 00193 00194 protected: 00195 00201 PlannerConfigurationMap config_settings_; 00202 }; 00203 00204 MOVEIT_CLASS_FORWARD(PlannerManager); 00205 00206 } // planning_interface 00207 00208 #endif