force_torque_sensor.h
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright 2016 Intelligent Industrial Robotics (IIROB) Group,
00004  * Institute for Anthropomatics and Robotics (IAR) -
00005  * Intelligent Process Control and Robotics (IPR),
00006  * Karlsruhe Institute of Technology
00007  *
00008  * Maintainers: Denis Štogl, email: denis.stogl@kit.edu
00009  *                     Florian Heller
00010  *                     Vanessa Streuer
00011  *
00012  * Date of update: 2014-2016
00013  *
00014  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00015  *
00016  * Copyright (c) 2010
00017  *
00018  * Fraunhofer Institute for Manufacturing Engineering
00019  * and Automation (IPA)
00020  *
00021  * Author: Alexander Bubeck, email:alexander.bubeck@ipa.fhg.de
00022  * Supervised by: Alexander Bubeck, email:alexander.bubeck@ipa.fhg.de
00023  *
00024  * Date of creation: June 2010
00025  *
00026  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00027  *
00028  * Redistribution and use in source and binary forms, with or without
00029  * modification, are permitted provided that the following conditions are met:
00030  *
00031  *     * Redistributions of source code must retain the above copyright
00032  *       notice, this list of conditions and the following disclaimer.
00033  *     * Redistributions in binary form must reproduce the above copyright
00034  *       notice, this list of conditions and the following disclaimer in the
00035  *       documentation and/or other materials provided with the distribution.
00036  *     * Neither the name of the copyright holder nor the names of its
00037  *       contributors may be used to endorse or promote products derived from
00038  *       this software without specific prior written permission.
00039  *
00040  * This program is free software: you can redistribute it and/or modify
00041  * it under the terms of the GNU Lesser General Public License LGPL as
00042  * published by the Free Software Foundation, either version 3 of the
00043  * License, or (at your option) any later version.
00044  *
00045  * This program is distributed in the hope that it will be useful,
00046  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00047  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00048  * GNU Lesser General Public License LGPL for more details.
00049  *
00050  * You should have received a copy of the GNU Lesser General Public
00051  * License LGPL along with this program.
00052  * If not, see <http://www.gnu.org/licenses/>.
00053  *
00054  ****************************************************************/
00055 #include <stdint.h>
00056 typedef unsigned char uint8_t;
00057 #include <inttypes.h>
00058 #include <iostream>
00059 #include <ros/ros.h>
00060 #include <cob_forcetorque/ForceTorqueCtrl.h>
00061 #include <geometry_msgs/Wrench.h>
00062 #include <geometry_msgs/WrenchStamped.h>
00063 #include <geometry_msgs/PoseStamped.h>
00064 #include <geometry_msgs/Vector3Stamped.h>
00065 
00066 #include <tf2/LinearMath/Transform.h>
00067 #include <tf2_ros/transform_listener.h>
00068 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
00069 
00070 #include <std_srvs/Trigger.h>
00071 #include <ati_force_torque/CalculateAverageMasurement.h>
00072 #include <ati_force_torque/CalculateSensorOffset.h>
00073 #include <ati_force_torque/DiagnosticVoltages.h>
00074 
00075 
00076 #include <iirob_filters/gravity_compensation.h>
00077 #include <iirob_filters/GravityCompensationParameters.h>
00078 #include <iirob_filters/low_pass_filter.h>
00079 #include <iirob_filters/threshold_filter.h>
00080 #include <iirob_filters/moving_mean_filter.h>
00081 
00082 #include <math.h>
00083 #include <iostream>
00084 
00085 #include <dynamic_reconfigure/server.h>
00086 #include <ati_force_torque/CoordinateSystemCalibrationParameters.h>
00087 #include <ati_force_torque/CanConfigurationParameters.h>
00088 #include <ati_force_torque/FTSConfigurationParameters.h>
00089 #include <ati_force_torque/PublishConfigurationParameters.h>
00090 #include <ati_force_torque/NodeConfigurationParameters.h>
00091 #include <ati_force_torque/CalibrationParameters.h>
00092 #include <ati_force_torque/CalibrationConfig.h>
00093 
00094 #include <filters/filter_chain.h>
00095 #include <filters/filter_base.h>
00096 #include <filters/mean.h>
00097 #include <realtime_tools/realtime_publisher.h>
00098 
00099 #define PI 3.14159265
00100 
00101 class ForceTorqueSensor
00102 {
00103 public:
00104   ForceTorqueSensor(ros::NodeHandle &nh);
00105 
00106 
00107   void init_sensor(std::string &msg, bool &success);
00108   bool srvCallback_Init(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
00109   bool srvCallback_CalculateOffset(ati_force_torque::CalculateSensorOffset::Request &req, ati_force_torque::CalculateSensorOffset::Response &res);
00110   bool srvCallback_CalculateAverageMasurement(ati_force_torque::CalculateAverageMasurement::Request &req, ati_force_torque::CalculateAverageMasurement::Response &res);
00111   bool calibrate(bool apply_after_calculation,  geometry_msgs::Wrench *new_offset);
00112   bool srvCallback_DetermineCoordinateSystem(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
00113   bool srvReadDiagnosticVoltages(ati_force_torque::DiagnosticVoltages::Request &req,
00114                                  ati_force_torque::DiagnosticVoltages::Response &res);
00115   bool srvCallback_recalibrate(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
00116 
00117 protected:
00118   ati_force_torque::CoordinateSystemCalibrationParameters CS_params_;
00119   ati_force_torque::CanConfigurationParameters can_params_;
00120   ati_force_torque::FTSConfigurationParameters FTS_params_;
00121   ati_force_torque::PublishConfigurationParameters pub_params_;
00122   ati_force_torque::NodeConfigurationParameters node_params_;
00123   ati_force_torque::CalibrationParameters calibration_params_;
00124   iirob_filters::GravityCompensationParameters gravity_params_;
00125 
00126   std::string transform_frame_;
00127   std::string sensor_frame_;
00128 
00129   void pullFTData(const ros::TimerEvent &event);
00130   void filterFTData();
00131 
00132   // Arrays for dumping FT-Data
00133   geometry_msgs::WrenchStamped gravity_compensated_force, moving_mean_filtered_wrench, threshold_filtered_force, transformed_data, sensor_data, low_pass_filtered_data;
00134 
00135   double force_buffer_[3];
00136   double torque_buffer_[3];
00137   double force_buffer_transformed_[3];
00138   double torque_buffer_transformed_[3];
00139   
00140   ros::NodeHandle nh_;
00141 
00142 private:
00143   virtual void updateFTData(const ros::TimerEvent &event)  = 0;
00144   geometry_msgs::Wrench makeAverageMeasurement(uint number_of_measurements, double time_between_meas, std::string frame_id="");
00145   bool transform_wrench(std::string goal_frame, std::string source_frame, geometry_msgs::Wrench wrench, geometry_msgs::Wrench *transformed);
00146 
00147   //FT Data
00148   ForceTorqueCtrl *p_Ftc;
00149   geometry_msgs::Wrench offset_;
00150   geometry_msgs::TransformStamped transform_ee_base_stamped;
00151   tf2_ros::Buffer *p_tfBuffer;
00152   realtime_tools::RealtimePublisher<geometry_msgs::WrenchStamped>  *gravity_compensated_pub_, *threshold_filtered_pub_, *transformed_data_pub_, *sensor_data_pub_, *low_pass_pub_, *moving_mean_pub_;
00153   bool is_pub_gravity_compensated_ = false;
00154   bool is_pub_threshold_filtered_ = false;
00155   bool is_pub_transformed_data_ = false;
00156   bool is_pub_sensor_data_ = false;
00157   bool is_pub_low_pass_ = false;
00158   bool is_pub_moving_mean_ = false;
00159   
00160   uint _num_transform_errors;
00161 
00162   // CAN parameters
00163   int canType;
00164   std::string canPath;
00165   int canBaudrate;
00166   int ftsBaseID;
00167   double nodePubFreq, nodePullFreq;
00168   uint calibrationNMeasurements;
00169   double calibrationTBetween;
00170   int coordinateSystemNMeasurements;
00171   int coordinateSystemTBetween;
00172   int coordinateSystemPushDirection;
00173 
00174   // service servers
00175   ros::ServiceServer srvServer_Init_;
00176   ros::ServiceServer srvServer_CalculateAverageMasurement_;
00177   ros::ServiceServer srvServer_CalculateOffset_;
00178   ros::ServiceServer srvServer_DetermineCoordianteSystem_;
00179   ros::ServiceServer srvServer_Temp_;
00180   ros::ServiceServer srvServer_ReCalibrate;
00181 
00182   ros::Timer ftUpdateTimer_, ftPullTimer_;
00183 
00184   tf2_ros::TransformListener *p_tfListener;
00185   tf2::Transform transform_ee_base;
00186 
00187   bool m_isInitialized;
00188   bool m_isCalibrated;
00189   bool apply_offset;
00190 
00191   // Variables for Static offset
00192   bool m_staticCalibration;
00193   geometry_msgs::Wrench m_calibOffset;
00194 
00195   filters::FilterBase<geometry_msgs::WrenchStamped> *moving_mean_filter_ = new iirob_filters::MovingMeanFilter<geometry_msgs::WrenchStamped>();
00196   filters::FilterBase<geometry_msgs::WrenchStamped> *low_pass_filter_ = new iirob_filters::LowPassFilter<geometry_msgs::WrenchStamped>();
00197   filters::FilterBase<geometry_msgs::WrenchStamped> *threshold_filter_ = new iirob_filters::ThresholdFilter<geometry_msgs::WrenchStamped>();  
00198   filters::FilterBase<geometry_msgs::WrenchStamped> *gravity_compensator_ = new iirob_filters::GravityCompensator<geometry_msgs::WrenchStamped>();
00199   
00200   bool useGravityCompensator=false;
00201   bool useThresholdFilter=false;
00202 
00203   bool useMovingMean = false;
00204   bool useLowPassFilter = false;
00205   
00206   dynamic_reconfigure::Server<ati_force_torque::CalibrationConfig> reconfigCalibrationSrv_; // Dynamic reconfiguration service  
00207 
00208   void reconfigureCalibrationRequest(ati_force_torque::CalibrationConfig& config, uint32_t level);  
00209 };
00210 


ati_force_torque
Author(s): Denis Štogl, Alexander Bubeck
autogenerated on Thu Jun 6 2019 21:13:29