$search
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_IK_GOAL_SAMPLEABLE_H_ 00038 #define OMPL_ROS_IK_GOAL_SAMPLEABLE_H_ 00039 00040 // OMPL 00041 #include <ompl/base/GoalSampleableRegion.h> 00042 #include <ompl/base/ScopedState.h> 00043 #include <ompl/base/State.h> 00044 00045 // Planning environment and models 00046 #include <planning_environment/models/collision_models_interface.h> 00047 #include <planning_models/kinematic_model.h> 00048 #include <planning_models/kinematic_state.h> 00049 00050 // OMPL ROS Interface 00051 #include <ompl_ros_interface/ompl_ros_state_validity_checker.h> 00052 #include <ompl_ros_interface/ompl_ros_projection_evaluator.h> 00053 #include <ompl_ros_interface/ompl_ros_planner_config.h> 00054 00055 #include <ompl_ros_interface/helpers/ompl_ros_conversions.h> 00056 00057 // Kinematics 00058 #include <pluginlib/class_loader.h> 00059 #include <kinematics_base/kinematics_base.h> 00060 00061 namespace ompl_ros_interface 00062 { 00067 class OmplRosIKSampleableRegion : public ompl::base::GoalSampleableRegion 00068 { 00069 public: 00074 OmplRosIKSampleableRegion(const ompl::base::SpaceInformationPtr &space_information) 00075 : GoalSampleableRegion(space_information), 00076 kinematics_loader_("kinematics_base","kinematics::KinematicsBase"), 00077 scoped_state_(space_information) 00078 { 00079 } 00080 00089 bool initialize(const ompl::base::StateSpacePtr &state_space, 00090 const std::string &kinematics_solver_name, 00091 const std::string &group_name, 00092 const std::string &end_effector_name, 00093 const planning_environment::CollisionModelsInterface* cmi); 00094 00101 bool configureOnRequest(const arm_navigation_msgs::GetMotionPlan::Request &request, 00102 arm_navigation_msgs::GetMotionPlan::Response &response, 00103 const unsigned int &max_sample_count = 100); 00104 00109 virtual void sampleGoal(ompl::base::State *state) const; 00110 00115 virtual unsigned int maxSampleCount(void) const; 00116 00117 private: 00118 void sampleGoals(const unsigned int &number_goals, 00119 std::vector<arm_navigation_msgs::RobotState> &sampled_states_vector) const; 00120 00121 std::vector<geometry_msgs::PoseStamped> ik_poses_; 00122 unsigned int max_sample_count_; 00123 unsigned int ik_poses_counter_; 00124 ompl::base::StateSpacePtr state_space_; 00125 kinematics::KinematicsBase* kinematics_solver_; 00126 00127 std::string kinematics_solver_name_, group_name_, end_effector_name_; 00128 pluginlib::ClassLoader<kinematics::KinematicsBase> kinematics_loader_; 00129 ompl::base::ScopedState<ompl::base::CompoundStateSpace> scoped_state_; 00130 arm_navigation_msgs::RobotState seed_state_, solution_state_; 00131 00132 ompl_ros_interface::OmplStateToRobotStateMapping ompl_state_to_robot_state_mapping_; 00133 ompl_ros_interface::RobotStateToOmplStateMapping robot_state_to_ompl_state_mapping_; 00134 const planning_environment::CollisionModelsInterface* collision_models_interface_; 00135 00136 }; 00137 00138 } 00139 00140 #endif //OMPL_ROS_IK_GOAL_SAMPLEABLE_H_