00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2008, 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 00037 #ifndef OMPL_ROS_H_ 00038 #define OMPL_ROS_H_ 00039 00040 // ROS 00041 #include <ros/console.h> 00042 #include <ros/ros.h> 00043 #include <tf/tf.h> 00044 00045 // Planning environment and models 00046 #include <planning_environment/monitors/planning_monitor.h> 00047 00048 // OMPL ROS Interface 00049 #include <ompl_ros_interface/planners/ompl_ros_rpy_ik_task_space_planner.h> 00050 #include <ompl_ros_interface/planners/ompl_ros_joint_planner.h> 00051 #include <ompl_ros_interface/helpers/ompl_ros_conversions.h> 00052 00053 // Diagnostics Message 00054 #include <ompl_ros_interface/OmplPlannerDiagnostics.h> 00055 00056 namespace ompl_ros_interface 00057 { 00062 class OmplRos 00063 { 00064 public: 00065 00066 OmplRos(); 00067 ~OmplRos(); 00068 00072 void run(void); 00073 00077 boost::shared_ptr<ompl_ros_interface::OmplRosPlanningGroup>& getPlanner(const std::string &group_name, 00078 const std::string &planner_config_name); 00079 00080 private: 00081 00086 bool computePlan(motion_planning_msgs::GetMotionPlan::Request &request, 00087 motion_planning_msgs::GetMotionPlan::Response &response); 00088 00092 bool getGroupNamesFromParamServer(const std::string ¶m_server_prefix, 00093 std::vector<std::string> &group_names); 00094 00095 bool initialize(planning_environment::PlanningMonitor *planning_monitor, 00096 const std::string ¶m_server_prefix); 00097 00098 bool initializePlanningMap(const std::string ¶m_server_prefix, 00099 const std::vector<std::string> &group_names); 00100 00101 bool initializePlanningInstance(const std::string ¶m_server_prefix, 00102 const std::string &group_name, 00103 const std::string &planner_config_name); 00107 std::map<std::string,boost::shared_ptr<ompl_ros_interface::OmplRosPlanningGroup> > planner_map_; 00108 00109 // ROS interface 00110 boost::shared_ptr<ompl_ros_interface::OmplRosPlanningGroup> empty_ptr; 00111 ros::ServiceServer plan_path_service_; 00112 planning_environment::CollisionModels *collision_models_; 00113 planning_environment::PlanningMonitor *planning_monitor_; 00114 ros::NodeHandle node_handle_; 00115 tf::TransformListener tf_; 00116 std::string default_planner_id_; 00117 bool publish_diagnostics_; 00118 ros::Publisher diagnostic_publisher_; 00119 00120 }; 00121 } 00122 00123 #endif //OMPL_ROS_H_