Go to the documentation of this file.00001 #ifndef NET_FT_UTILS_H
00002 #define NET_FT_UTILS_H
00003
00004 #include "ros/ros.h"
00005 #include "std_msgs/String.h"
00006 #include "tf/transform_listener.h"
00007 #include "geometry_msgs/WrenchStamped.h"
00008 #include "netft_utils/SetBias.h"
00009 #include "netft_utils/SetMax.h"
00010 #include "netft_utils/SetThreshold.h"
00011 #include "netft_utils/SetToolData.h"
00012 #include "netft_utils/SetFilter.h"
00013 #include "netft_utils/GetDouble.h"
00014 #include "netft_utils/Cancel.h"
00015 #include "lpfilter.h"
00016 #include <math.h>
00017
00022 class NetftUtils
00023 {
00024 public:
00025 NetftUtils(ros::NodeHandle nh);
00026 ~NetftUtils();
00027
00028 void initialize();
00029 void setUserInput(std::string world, std::string ft, double force, double torque);
00030 void update();
00031
00032 private:
00033
00034 ros::NodeHandle n;
00035
00036
00037 LPFilter* lp;
00038 bool isFilterOn;
00039 double deltaTFilter;
00040 double cutoffFrequency;
00041 bool newFilter;
00042
00043
00044 tf::TransformListener* listener;
00045 tf::StampedTransform ft_to_world;
00046 std::string world_frame;
00047 std::string ft_frame;
00048
00049
00050 geometry_msgs::WrenchStamped bias;
00051 geometry_msgs::WrenchStamped weight_bias;
00052 geometry_msgs::WrenchStamped raw_data_world;
00053 geometry_msgs::WrenchStamped raw_data_tool;
00054 geometry_msgs::WrenchStamped tf_data_world;
00055 geometry_msgs::WrenchStamped tf_data_tool;
00056 geometry_msgs::WrenchStamped zero_wrench;
00057 geometry_msgs::WrenchStamped threshold;
00058
00059 double payloadWeight;
00060 double payloadLeverArm;
00061
00062 bool isBiased;
00063 bool isNewBias;
00064 bool isNewGravityBias;
00065 bool isGravityBiased;
00066
00067
00068 netft_utils::Cancel cancel_msg;
00069 static const int MAX_CANCEL = 5;
00070 static const int MAX_WAIT = 100;
00071 int cancel_count;
00072 int cancel_wait;
00073 double forceMaxB;
00074 double torqueMaxB;
00075 double forceMaxU;
00076 double torqueMaxU;
00077
00078
00079 ros::Subscriber raw_data_sub;
00080
00081
00082 ros::Publisher netft_raw_world_data_pub;
00083 ros::Publisher netft_world_data_pub;
00084 ros::Publisher netft_tool_data_pub;
00085 ros::Publisher netft_cancel_pub;
00086
00088
00090 ros::ServiceServer bias_service;
00091 ros::ServiceServer gravity_comp_service;
00092 ros::ServiceServer set_max_service;
00093 ros::ServiceServer theshold_service;
00094 ros::ServiceServer weight_bias_service;
00095 ros::ServiceServer get_weight_service;
00096 ros::ServiceServer filter_service;
00097
00099
00101
00102
00103 void netftCallback(const geometry_msgs::WrenchStamped::ConstPtr& data);
00104
00105
00106
00107
00108 bool fixedOrientationBias(netft_utils::SetBias::Request &req, netft_utils::SetBias::Response &res);
00109
00110
00111
00112
00113
00114
00115 bool compensateForGravity(netft_utils::SetBias::Request &req, netft_utils::SetBias::Response &res);
00116
00117 bool setMax(netft_utils::SetMax::Request &req, netft_utils::SetMax::Response &res);
00118 bool setWeightBias(netft_utils::SetBias::Request &req, netft_utils::SetBias::Response &res);
00119 bool getWeight(netft_utils::GetDouble::Request &req, netft_utils::GetDouble::Response &res);
00120 bool setThreshold(netft_utils::SetThreshold::Request &req, netft_utils::SetThreshold::Response &res);
00121 bool setFilter(netft_utils::SetFilter::Request &req, netft_utils::SetFilter::Response &res);
00122
00123
00124 void copyWrench(geometry_msgs::WrenchStamped &in, geometry_msgs::WrenchStamped &out, geometry_msgs::WrenchStamped &bias);
00125 void applyThreshold(double &value, double thresh);
00126 void transformFrame(geometry_msgs::WrenchStamped in_data, geometry_msgs::WrenchStamped &out_data, char target_frame);
00127 void checkMaxForce();
00128 };
00129
00130 #endif