descend_retreat_place.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 *  Copyright (c) 2009, Willow Garage, Inc.
00004 *  All rights reserved.
00005 *
00006 *  Redistribution and use in source and binary forms, with or without
00007 *  modification, are permitted provided that the following conditions
00008 *  are met:
00009 *
00010 *   * Redistributions of source code must retain the above copyright
00011 *     notice, this list of conditions and the following disclaimer.
00012 *   * Redistributions in binary form must reproduce the above
00013 *     copyright notice, this list of conditions and the following
00014 *     disclaimer in the documentation and/or other materials provided
00015 *     with the distribution.
00016 *   * Neither the name of the Willow Garage nor the names of its
00017 *     contributors may be used to endorse or promote products derived
00018 *     from this software without specific prior written permission.
00019 *
00020 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 *  POSSIBILITY OF SUCH DAMAGE.
00032 *********************************************************************/
00033 
00034 #ifndef _DESCEND_RETREAT_PLACE_
00035 #define _DESCEND_RETREAT_PLACE_
00036 
00037 #include <ros/ros.h>
00038 
00039 #include <tf/transform_listener.h>
00040 
00041 #include <object_manipulation_msgs/PlaceLocationResult.h>
00042 #include <object_manipulation_msgs/PlaceGoal.h>
00043 
00044 #include <trajectory_msgs/JointTrajectory.h>
00045 
00046 #include "object_manipulator/tools/grasp_marker_publisher.h"
00047 
00048 namespace object_manipulator {
00049 
00052 struct PlaceExecutionInfo {
00053   trajectory_msgs::JointTrajectory descend_trajectory_; 
00054   trajectory_msgs::JointTrajectory retreat_trajectory_; 
00055   geometry_msgs::PoseStamped gripper_place_pose_;
00056   object_manipulation_msgs::PlaceLocationResult result_;
00057   int marker_id_;
00058 };
00059 
00060 // ---------------------------- Definitions ---------------------------------
00061 
00064 class PlaceTester {
00065 protected:
00067   tf::TransformListener listener_;
00068 
00070   geometry_msgs::PoseStamped computeGripperPose(geometry_msgs::PoseStamped place_location, 
00071                                                 geometry_msgs::Pose grasp_pose,
00072                                                 std::string frame_id);
00073 
00075   virtual void testPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00076                          const geometry_msgs::PoseStamped &place_location,
00077                          PlaceExecutionInfo &execution_info) = 0;  
00078 
00080   GraspMarkerPublisher *marker_publisher_;
00081 
00084   boost::function<void(size_t)> feedback_function_;
00085 
00087   boost::function<bool()> interrupt_function_;
00088 
00089 public:
00090   PlaceTester() : marker_publisher_(NULL) {}
00091 
00093   virtual void testPlaces(const object_manipulation_msgs::PlaceGoal &place_goal,
00094                           const std::vector<geometry_msgs::PoseStamped> &place_locations,
00095                           std::vector<PlaceExecutionInfo> &execution_info,
00096                           bool return_on_first_hit);
00097 
00099   void setMarkerPublisher(GraspMarkerPublisher *pub){marker_publisher_ = pub;}
00100 
00102   void setFeedbackFunction(boost::function<void(size_t)> f){feedback_function_ = f;}
00103 
00105   void setInterruptFunction(boost::function<bool()> f){interrupt_function_ = f;}
00106 
00108   object_manipulation_msgs::PlaceLocationResult Result(int result_code, bool continuation)
00109   {
00110     object_manipulation_msgs::PlaceLocationResult result;
00111     result.result_code = result_code;
00112     result.continuation_possible = continuation;
00113     return result;
00114   }
00115 };
00116 
00119 class PlacePerformer {
00120 protected:
00122   virtual void performPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00123                             const geometry_msgs::PoseStamped &place_location,
00124                             PlaceExecutionInfo &execution_info) = 0;
00125 
00127   GraspMarkerPublisher *marker_publisher_;
00128 
00131   boost::function<void(size_t)> feedback_function_;
00132 
00134   boost::function<bool()> interrupt_function_;
00135 
00136 public:
00137   PlacePerformer() : marker_publisher_(NULL) {}
00138 
00140   virtual void performPlaces(const object_manipulation_msgs::PlaceGoal &place_goal,
00141                              const std::vector<geometry_msgs::PoseStamped> &place_locations,
00142                              std::vector<PlaceExecutionInfo> &execution_info);
00143 
00145   void setMarkerPublisher(GraspMarkerPublisher *pub){marker_publisher_ = pub;}
00146 
00148   void setFeedbackFunction(boost::function<void(size_t)> f){feedback_function_ = f;}
00149 
00151   void setInterruptFunction(boost::function<bool()> f){interrupt_function_ = f;}
00152 
00154   object_manipulation_msgs::PlaceLocationResult Result(int result_code, bool continuation)
00155   {
00156     object_manipulation_msgs::PlaceLocationResult result;
00157     result.result_code = result_code;
00158     result.continuation_possible = continuation;
00159     return result;
00160   }
00161 };
00162 
00163 // ---------------------------- Testers ---------------------------------
00164 
00165 class StandardPlaceTester : public PlaceTester
00166 {
00167 protected:
00169   virtual void testPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00170                          const geometry_msgs::PoseStamped &place_location,
00171                          PlaceExecutionInfo &execution_info);  
00172 
00174   static float EPS;
00175 };
00176 
00177 // ---------------------------- Performers ---------------------------------
00178 
00179 class StandardPlacePerformer : public PlacePerformer
00180 {
00182   object_manipulation_msgs::PlaceLocationResult
00183     retreat(const object_manipulation_msgs::PlaceGoal &place_goal);
00184   
00186   bool constraintsUnderstandable(const arm_navigation_msgs::Constraints &constraints);
00187 
00189   virtual object_manipulation_msgs::PlaceLocationResult
00190     placeApproach(const object_manipulation_msgs::PlaceGoal &place_goal,
00191                   const PlaceExecutionInfo &execution_info);
00192 
00194   virtual void performPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00195                             const geometry_msgs::PoseStamped &place_location,
00196                             PlaceExecutionInfo &execution_info);
00197 };
00198 
00200 
00203 class ReactivePlacePerformer : public StandardPlacePerformer
00204 {
00205 protected:
00207   virtual object_manipulation_msgs::PlaceLocationResult 
00208     placeApproach(const object_manipulation_msgs::PlaceGoal &place_goal,
00209                   const PlaceExecutionInfo &execution_info);
00210 };
00211 
00212 
00213 }
00214 
00215 
00216 #endif


object_manipulator
Author(s): Matei Ciocarlie and Kaijen Hsiao
autogenerated on Thu Jan 2 2014 11:39:04