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   virtual void testPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00071                          const geometry_msgs::PoseStamped &place_location,
00072                          PlaceExecutionInfo &execution_info) = 0;  
00073 
00075   GraspMarkerPublisher *marker_publisher_;
00076 
00079   boost::function<void(size_t)> feedback_function_;
00080 
00082   boost::function<bool()> interrupt_function_;
00083 
00084 public:
00085   PlaceTester() : marker_publisher_(NULL) {}
00086 
00088   virtual void testPlaces(const object_manipulation_msgs::PlaceGoal &place_goal,
00089                           const std::vector<geometry_msgs::PoseStamped> &place_locations,
00090                           std::vector<PlaceExecutionInfo> &execution_info,
00091                           bool return_on_first_hit);
00092 
00094   void setMarkerPublisher(GraspMarkerPublisher *pub){marker_publisher_ = pub;}
00095 
00097   void setFeedbackFunction(boost::function<void(size_t)> f){feedback_function_ = f;}
00098 
00100   void setInterruptFunction(boost::function<bool()> f){interrupt_function_ = f;}
00101 
00103   object_manipulation_msgs::PlaceLocationResult Result(int result_code, bool continuation)
00104   {
00105     object_manipulation_msgs::PlaceLocationResult result;
00106     result.result_code = result_code;
00107     result.continuation_possible = continuation;
00108     return result;
00109   }
00110 };
00111 
00114 class PlacePerformer {
00115 protected:
00117   virtual void performPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00118                             const geometry_msgs::PoseStamped &place_location,
00119                             PlaceExecutionInfo &execution_info) = 0;
00120 
00122   GraspMarkerPublisher *marker_publisher_;
00123 
00126   boost::function<void(size_t)> feedback_function_;
00127 
00129   boost::function<bool()> interrupt_function_;
00130 
00131 public:
00132   PlacePerformer() : marker_publisher_(NULL) {}
00133 
00135   virtual void performPlaces(const object_manipulation_msgs::PlaceGoal &place_goal,
00136                              const std::vector<geometry_msgs::PoseStamped> &place_locations,
00137                              std::vector<PlaceExecutionInfo> &execution_info);
00138 
00140   void setMarkerPublisher(GraspMarkerPublisher *pub){marker_publisher_ = pub;}
00141 
00143   void setFeedbackFunction(boost::function<void(size_t)> f){feedback_function_ = f;}
00144 
00146   void setInterruptFunction(boost::function<bool()> f){interrupt_function_ = f;}
00147 
00149   object_manipulation_msgs::PlaceLocationResult Result(int result_code, bool continuation)
00150   {
00151     object_manipulation_msgs::PlaceLocationResult result;
00152     result.result_code = result_code;
00153     result.continuation_possible = continuation;
00154     return result;
00155   }
00156 };
00157 
00158 // ---------------------------- Testers ---------------------------------
00159 
00160 class StandardPlaceTester : public PlaceTester
00161 {
00162 protected:
00164   virtual void testPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00165                          const geometry_msgs::PoseStamped &place_location,
00166                          PlaceExecutionInfo &execution_info);  
00167 
00169   static float EPS;
00170 };
00171 
00172 // ---------------------------- Performers ---------------------------------
00173 
00174 class StandardPlacePerformer : public PlacePerformer
00175 {
00177   object_manipulation_msgs::PlaceLocationResult
00178     retreat(const object_manipulation_msgs::PlaceGoal &place_goal);
00179   
00181   bool constraintsUnderstandable(const arm_navigation_msgs::Constraints &constraints);
00182 
00184   virtual object_manipulation_msgs::PlaceLocationResult
00185     placeApproach(const object_manipulation_msgs::PlaceGoal &place_goal,
00186                   const PlaceExecutionInfo &execution_info);
00187 
00189   virtual void performPlace(const object_manipulation_msgs::PlaceGoal &place_goal,
00190                             const geometry_msgs::PoseStamped &place_location,
00191                             PlaceExecutionInfo &execution_info);
00192 };
00193 
00195 
00198 class ReactivePlacePerformer : public StandardPlacePerformer
00199 {
00200 protected:
00202   virtual object_manipulation_msgs::PlaceLocationResult 
00203     placeApproach(const object_manipulation_msgs::PlaceGoal &place_goal,
00204                   const PlaceExecutionInfo &execution_info);
00205 };
00206 
00207 
00208 }
00209 
00210 
00211 #endif


object_manipulator
Author(s): Matei Ciocarlie and Kaijen Hsiao
autogenerated on Mon Oct 6 2014 02:59:50