pick_place.h
Go to the documentation of this file.
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 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_PICK_PLACE_PICK_PLACE_
00038 #define MOVEIT_PICK_PLACE_PICK_PLACE_
00039 
00040 #include <moveit/pick_place/manipulation_pipeline.h>
00041 #include <moveit/constraint_sampler_manager_loader/constraint_sampler_manager_loader.h>
00042 #include <moveit/planning_pipeline/planning_pipeline.h>
00043 #include <moveit_msgs/PickupAction.h>
00044 #include <moveit_msgs/PlaceAction.h>
00045 #include <boost/noncopyable.hpp>
00046 #include <boost/enable_shared_from_this.hpp>
00047 
00048 namespace pick_place
00049 {
00050 
00051 class PickPlace;
00052 typedef boost::shared_ptr<PickPlace> PickPlacePtr;
00053 typedef boost::shared_ptr<const PickPlace> PickPlaceConstPtr;
00054 
00055 class PickPlacePlanBase
00056 {
00057 public:
00058 
00059   PickPlacePlanBase(const PickPlaceConstPtr &pick_place, const std::string &name);
00060   ~PickPlacePlanBase();
00061 
00062   const std::vector<ManipulationPlanPtr>& getSuccessfulManipulationPlans() const
00063   {
00064     return pipeline_.getSuccessfulManipulationPlans();
00065   }
00066   const std::vector<ManipulationPlanPtr>& getFailedManipulationPlans() const
00067   {
00068     return pipeline_.getFailedManipulationPlans();
00069   }
00070 
00071   const moveit_msgs::MoveItErrorCodes& getErrorCode() const
00072   {
00073     return error_code_;
00074   }
00075 
00076 protected:
00077 
00078   void initialize();
00079   void waitForPipeline(const ros::WallTime &endtime);
00080   void foundSolution();
00081   void emptyQueue();
00082 
00083   PickPlaceConstPtr pick_place_;
00084   ManipulationPipeline pipeline_;
00085 
00086   double last_plan_time_;
00087   bool done_;
00088   bool pushed_all_poses_;
00089   boost::condition_variable done_condition_;
00090   boost::mutex done_mutex_;
00091   moveit_msgs::MoveItErrorCodes error_code_;
00092 };
00093 
00094 class PickPlan : public PickPlacePlanBase
00095 {
00096 public:
00097 
00098   PickPlan(const PickPlaceConstPtr &pick_place);
00099   bool plan(const planning_scene::PlanningSceneConstPtr &planning_scene, const moveit_msgs::PickupGoal &goal);
00100 };
00101 
00102 typedef boost::shared_ptr<PickPlan> PickPlanPtr;
00103 typedef boost::shared_ptr<const PickPlan> PickPlanConstPtr;
00104 
00105 class PlacePlan : public PickPlacePlanBase
00106 {
00107 public:
00108 
00109   PlacePlan(const PickPlaceConstPtr &pick_place);
00110   bool plan(const planning_scene::PlanningSceneConstPtr &planning_scene, const moveit_msgs::PlaceGoal &goal);
00111 
00112 private:
00113 
00114   bool transformToEndEffectorGoal(const geometry_msgs::PoseStamped &goal_pose,
00115                   const robot_state::AttachedBody* body,
00116                   geometry_msgs::PoseStamped &place_pose) const;
00117 };
00118 
00119 typedef boost::shared_ptr<PlacePlan> PlacePlanPtr;
00120 typedef boost::shared_ptr<const PlacePlan> PlacePlanConstPtr;
00121 
00122 class PickPlace : private boost::noncopyable,
00123                   public boost::enable_shared_from_this<PickPlace>
00124 {
00125 public:
00126 
00127   static const std::string DISPLAY_PATH_TOPIC;
00128   static const std::string DISPLAY_GRASP_TOPIC;
00129 
00130   // the amount of time (maximum) to wait for achieving a grasp posture
00131   static const double DEFAULT_GRASP_POSTURE_COMPLETION_DURATION; // seconds
00132 
00133   PickPlace(const planning_pipeline::PlanningPipelinePtr &planning_pipeline);
00134 
00135   const constraint_samplers::ConstraintSamplerManagerPtr& getConstraintsSamplerManager() const
00136   {
00137     return constraint_sampler_manager_loader_->getConstraintSamplerManager();
00138   }
00139 
00140   const planning_pipeline::PlanningPipelinePtr& getPlanningPipeline() const
00141   {
00142     return planning_pipeline_;
00143   }
00144 
00145   const robot_model::RobotModelConstPtr& getRobotModel() const
00146   {
00147     return planning_pipeline_->getRobotModel();
00148   }
00149 
00151   PickPlanPtr planPick(const planning_scene::PlanningSceneConstPtr &planning_scene, const moveit_msgs::PickupGoal &goal) const;
00152 
00154   PlacePlanPtr planPlace(const planning_scene::PlanningSceneConstPtr &planning_scene, const moveit_msgs::PlaceGoal &goal) const;
00155 
00156   void displayComputedMotionPlans(bool flag);
00157   void displayProcessedGrasps(bool flag);
00158 
00159   void visualizePlan(const ManipulationPlanPtr &plan) const;
00160 
00161   void visualizeGrasp(const ManipulationPlanPtr &plan) const;
00162 
00163   void visualizeGrasps(const std::vector<ManipulationPlanPtr>& plans) const;
00164 
00165 private:
00166 
00167   ros::NodeHandle nh_;
00168   planning_pipeline::PlanningPipelinePtr planning_pipeline_;
00169   bool display_computed_motion_plans_;
00170   bool display_grasps_;
00171   ros::Publisher display_path_publisher_;
00172   ros::Publisher grasps_publisher_;
00173 
00174   constraint_sampler_manager_loader::ConstraintSamplerManagerLoaderPtr constraint_sampler_manager_loader_;
00175 };
00176 
00177 }
00178 
00179 #endif


manipulation
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Mon Oct 6 2014 02:33:06