Go to the documentation of this file.00001 #ifndef icr_server_h___
00002 #define icr_server_h___
00003
00004 #include "ros/ros.h"
00005 #include "icr.h"
00006
00007
00008 #include "icr_msgs/SetObject.h"
00009 #include "icr_msgs/Grasp.h"
00010 #include "icr_msgs/SetSphericalQuality.h"
00011 #include "icr_msgs/SetPhalangeParameters.h"
00012 #include "icr_msgs/SetActivePhalanges.h"
00013 #include <icr_msgs/ContactRegions.h>
00014 #include <icr_msgs/ContactRegion.h>
00015 #include <icr_msgs/SaveIcr.h>
00016 #include <icr_msgs/GetContactRegions.h>
00017
00018
00019 #include <pcl/point_cloud.h>
00020 #include <pcl/point_types.h>
00021 #include <pcl/ros/conversions.h>
00022 #include <pcl_ros/point_cloud.h>
00023
00024 #include "std_srvs/Empty.h"
00025 #include <boost/thread/mutex.hpp>
00026 #include <vector>
00027 #include <string>
00028 #include <tf/tf.h>
00029
00048 namespace ICR
00049 {
00050 #define MODE_CONTINUOUS 0
00051 #define MODE_STEP_WISE 1
00052
00053 class IcrServer
00054 {
00055 public:
00056
00057 IcrServer();
00058 ~IcrServer(){};
00059
00060 int getComputationMode();
00061 void computeSearchZones();
00062 void computeIcr();
00063 void publish();
00064
00065 private:
00066
00067 ros::NodeHandle nh_,nh_private_;
00068 XmlRpc::XmlRpcValue phalange_config_;
00069 TargetObjectPtr obj_;
00070 GraspPtr pt_grasp_;
00071 SearchZonesPtr sz_;
00072 IndependentContactRegionsPtr icr_;
00073
00074 bool obj_set_;
00075 bool pt_grasp_initialized_;
00076 bool gws_computed_;
00077 bool sz_computed_;
00078 bool icr_computed_;
00079
00080 std::vector<std::string> active_phalanges_;
00081 int computation_mode_;
00082 double qs_;
00083 std::string obj_frame_id_;
00084 std::string icr_database_dir_;
00085 boost::mutex lock_;
00086 icr_msgs::ContactRegions::Ptr icr_msg_;
00087 tf::Transform palm_pose_;
00088
00089 ros::ServiceServer get_icr_srv_;
00090 ros::ServiceServer compute_icr_srv_;
00091 ros::ServiceServer compute_sz_srv_;
00092 ros::ServiceServer set_obj_srv_;
00093 ros::ServiceServer toggle_mode_srv_;
00094 ros::ServiceServer set_qs_srv_;
00095 ros::ServiceServer set_active_phl_srv_;
00096 ros::ServiceServer set_phl_param_srv_;
00097 ros::ServiceServer save_icr_srv_;
00098 ros::Subscriber ct_pts_sub_;
00099 ros::Publisher icr_cloud_pub_;
00100 ros::Publisher icr_pub_;
00101
00102 uint findObjectPointId(Eigen::Vector3d* point_in) const;
00103 void getActivePhalangeParameters(FParamList & phl_param);
00104 unsigned int getPhalangeId(std::string const & name);
00105 void getFingerParameters(std::string const & name,FingerParameters & f_param);
00106 bool cpFromGraspMsg(icr_msgs::Grasp const & c_pts,const std::string & name,Eigen::Vector3d & contact_position,bool & touching)const;
00107 void initPtGrasp();
00108 bool cloudFromContactRegion(unsigned int region_id,pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, std::vector<unsigned int> & point_ids);
00109
00111
00113
00114 bool getIcr(icr_msgs::GetContactRegions::Request &req, icr_msgs::GetContactRegions::Response &res);
00115 bool triggerSearchZonesCmp(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
00116 bool triggerIcrCmp(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
00117 bool toggleMode(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
00118 bool saveIcr(icr_msgs::SaveIcr::Request &req, icr_msgs::SaveIcr::Response &res);
00119 bool setObject(icr_msgs::SetObject::Request &req, icr_msgs::SetObject::Response &res);
00120 bool setSphericalQuality(icr_msgs::SetSphericalQuality::Request &req, icr_msgs::SetSphericalQuality::Response &res);
00121 bool setActivePhalanges(icr_msgs::SetActivePhalanges::Request &req, icr_msgs::SetActivePhalanges::Response &res);
00122 bool setPhalangeParameters(icr_msgs::SetPhalangeParameters::Request &req, icr_msgs::SetPhalangeParameters::Response &res);
00123 void graspCallback(icr_msgs::Grasp const & grasp);
00124 };
00125 }
00126
00127
00128
00129 #endif