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: Andreea Tulbure, email: andreea.tulbure@student.kit.edu 00009 * 00010 * Date of update: 2016-2017 00011 * 00012 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions are met: 00016 * 00017 * * Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * * Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in the 00021 * documentation and/or other materials provided with the distribution. 00022 * * Neither the name of the copyright holder nor the names of its 00023 * contributors may be used to endorse or promote products derived from 00024 * this software without specific prior written permission. 00025 * 00026 * This program is free software: you can redistribute it and/or modify 00027 * it under the terms of the GNU Lesser General Public License LGPL as 00028 * published by the Free Software Foundation, either version 3 of the 00029 * License, or (at your option) any later version. 00030 * 00031 * This program is distributed in the hope that it will be useful, 00032 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00033 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00034 * GNU Lesser General Public License LGPL for more details. 00035 * 00036 * You should have received a copy of the GNU Lesser General Public 00037 * License LGPL along with this program. 00038 * If not, see <http://www.gnu.org/licenses/>. 00039 * 00040 ****************************************************************/ 00041 #include <stdint.h> 00042 typedef unsigned char uint8_t; 00043 #include <inttypes.h> 00044 #include <iostream> 00045 #include <ros/ros.h> 00046 #include <geometry_msgs/Wrench.h> 00047 #include <geometry_msgs/Twist.h> 00048 #include <geometry_msgs/WrenchStamped.h> 00049 #include <geometry_msgs/PoseStamped.h> 00050 #include <geometry_msgs/Vector3Stamped.h> 00051 #include <cob_forcetorque/ForceTorqueCtrl.h> 00052 00053 #include <tf2/LinearMath/Transform.h> 00054 #include <tf2_ros/transform_listener.h> 00055 #include <tf2_geometry_msgs/tf2_geometry_msgs.h> 00056 00057 #include <ati_force_torque/PublishConfigurationParameters.h> 00058 #include <ati_force_torque/NodeConfigurationParameters.h> 00059 00060 #include <math.h> 00061 #include <iostream> 00062 00063 #define PI 3.14159265 00064 00065 class ForceTorqueSensorSim 00066 { 00067 public: 00068 ForceTorqueSensorSim(ros::NodeHandle &nh); 00069 void init_sensor(); 00070 00071 protected: 00072 00073 std::string transform_frame_; 00074 std::string sensor_frame_; 00075 ati_force_torque::NodeConfigurationParameters node_params_; 00076 ati_force_torque::PublishConfigurationParameters pub_params_; 00077 void pullFTData(const ros::TimerEvent &event); 00078 void filterFTData(); 00079 void subscribeData(const geometry_msgs::Twist::ConstPtr& msg); 00080 // Arrays for dumping FT-Data 00081 geometry_msgs::WrenchStamped threshold_filtered_force, transformed_data, joystick_data; 00082 virtual void updateFTData(const ros::TimerEvent &event) = 0; 00083 00084 00085 private: 00086 bool transform_wrench(std::string goal_frame, std::string source_frame, geometry_msgs::Wrench wrench, geometry_msgs::Wrench *transformed); 00087 ros::Subscriber force_input_subscriber; 00088 uint _num_transform_errors; 00089 tf2_ros::Buffer *p_tfBuffer; 00090 tf2_ros::TransformListener *p_tfListener; 00091 ros::NodeHandle nh_; 00092 ros::Publisher transformed_data_pub_,sensor_data_pub_; 00093 ros::Timer ftUpdateTimer_, ftPullTimer_; 00094 bool is_pub_transformed_data_ =false; 00095 bool is_pub_sensor_data_=false; 00096 00097 }; 00098