force_torque_sensor_handle.h
Go to the documentation of this file.
1 /****************************************************************
2  *
3  * Copyright 2020 Intelligent Industrial Robotics (IIROB) Group,
4  * Institute for Anthropomatics and Robotics (IAR) -
5  * Intelligent Process Control and Robotics (IPR),
6  * Karlsruhe Institute of Technology
7  *
8  * Maintainer: Denis Štogl, email: denis.stogl@kit.edu
9  *
10  * Date of update: 2014-2020
11  *
12  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are met:
16  *
17  * * Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  * * Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  * * Neither the name of the copyright holder nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * This program is free software: you can redistribute it and/or modify
27  * it under the terms of the GNU Lesser General Public License LGPL as
28  * published by the Free Software Foundation, either version 3 of the
29  * License, or (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34  * GNU Lesser General Public License LGPL for more details.
35  *
36  * You should have received a copy of the GNU Lesser General Public
37  * License LGPL along with this program.
38  * If not, see <http://www.gnu.org/licenses/>.
39  *
40  ****************************************************************/
41 
42 #ifndef FORCETORQUESENSORHANDLE_INCLUDEDEF_H
43 #define FORCETORQUESENSORHANDLE_INCLUDEDEF_H
44 
47 
48 #include <stdint.h>
49 typedef unsigned char uint8_t;
50 #include <inttypes.h>
51 #include <iostream>
52 #include <ros/ros.h>
53 #include <geometry_msgs/Wrench.h>
54 #include <geometry_msgs/WrenchStamped.h>
55 #include <geometry_msgs/PoseStamped.h>
56 #include <geometry_msgs/Vector3Stamped.h>
57 
61 
62 #include <std_srvs/Trigger.h>
63 #include <force_torque_sensor/CalculateAverageMasurement.h>
64 #include <force_torque_sensor/CalculateSensorOffset.h>
65 #include <force_torque_sensor/DiagnosticVoltages.h>
66 #include <force_torque_sensor/SetSensorOffset.h>
67 
68 
70 #include <iirob_filters/GravityCompensationParameters.h>
74 
75 #include <math.h>
76 #include <iostream>
77 #include <mutex>
78 #include <chrono>
79 
80 #include <dynamic_reconfigure/server.h>
81 #include <force_torque_sensor/CoordinateSystemCalibrationParameters.h>
82 #include <force_torque_sensor/HWCommunicationConfigurationParameters.h>
83 #include <force_torque_sensor/FTSConfigurationParameters.h>
84 #include <force_torque_sensor/PublishConfigurationParameters.h>
85 #include <force_torque_sensor/NodeConfigurationParameters.h>
86 #include <force_torque_sensor/CalibrationParameters.h>
87 #include <force_torque_sensor/CalibrationConfig.h>
88 
89 #include <filters/filter_chain.h>
90 #include <filters/filter_base.h>
91 #include <filters/mean.h>
93 
94 #define PI 3.14159265
95 
97 {
98 
100 {
101 public:
102 
103  ForceTorqueSensorHandle(ros::NodeHandle &nh, hardware_interface::ForceTorqueSensorHW *sensor, std::string sensor_name, std::string output_frame);
104  ForceTorqueSensorHandle(ros::NodeHandle &nh, std::string sensor_name, std::string output_frame);
105 
106  void prepareNode(std::string output_frame);
107 
108  void init_sensor(std::string &msg, bool &success);
109  bool srvCallback_Init(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
110  bool srvCallback_CalculateOffset(force_torque_sensor::CalculateSensorOffset::Request &req, force_torque_sensor::CalculateSensorOffset::Response &res);
111  bool srvCallback_CalculateAverageMasurement(force_torque_sensor::CalculateAverageMasurement::Request &req, force_torque_sensor::CalculateAverageMasurement::Response &res);
112  bool calculate_offset(bool apply_after_calculation, geometry_msgs::Wrench *new_offset);
113  bool srvCallback_DetermineCoordinateSystem(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
114  bool srvReadDiagnosticVoltages(force_torque_sensor::DiagnosticVoltages::Request &req,
115  force_torque_sensor::DiagnosticVoltages::Response &res);
116  bool srvCallback_CalculateOffsetWithoutGravity(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res);
117  bool srvCallback_setSensorOffset(force_torque_sensor::SetSensorOffset::Request &req,
118  force_torque_sensor::SetSensorOffset::Response &res);
119 
120 private:
121  void updateFTData(const ros::TimerEvent &event);
122  geometry_msgs::Wrench makeAverageMeasurement(uint number_of_measurements, double time_between_meas, std::string frame_id="");
123 
124  bool transform_wrench(std::string goal_frame, std::string source_frame, geometry_msgs::Wrench wrench, geometry_msgs::Wrench& transformed);
125  bool updateTransform(std::string goal_frame, std::string source_frame);
126 
127  void pullFTData(const ros::TimerEvent &event);
128  void filterFTData();
129 
130 
131  // Arrays for hardware_interface
132  double interface_force_[3];
133  double interface_torque_[3];
134 
135  force_torque_sensor::CoordinateSystemCalibrationParameters CS_params_;
136  force_torque_sensor::HWCommunicationConfigurationParameters HWComm_params_;
137  force_torque_sensor::FTSConfigurationParameters FTS_params_;
138  force_torque_sensor::PublishConfigurationParameters pub_params_;
139  force_torque_sensor::NodeConfigurationParameters node_params_;
140  force_torque_sensor::CalibrationParameters calibration_params_;
141  iirob_filters::GravityCompensationParameters gravity_params_;
142 
143  std::string transform_frame_;
144  std::string sensor_frame_;
145 
146  // Wrenches for dumping FT-Data
147  geometry_msgs::WrenchStamped prefiltered_data_, filtered_data_input_; //Communication between read and filter/publish thread
148  geometry_msgs::WrenchStamped sensor_data, low_pass_filtered_data, moving_mean_filtered_data, transformed_data, gravity_compensated_force, threshold_filtered_force, output_data; //global variables to avoid on-runtime allocation
149 
150  geometry_msgs::TransformStamped output_transform_;
151 
153 
154  //FT Data
156  geometry_msgs::Wrench offset_;
159 
160  // service servers
168 
170 
172 
176 
181 
183  bool useThresholdFilter=false;
184  bool useMovingMean = false;
185  bool useLowPassFilter = false;
186 
187 
188  dynamic_reconfigure::Server<force_torque_sensor::CalibrationConfig> reconfigCalibrationSrv_; // Dynamic reconfiguration service
189 
190  void reconfigureCalibrationRequest(force_torque_sensor::CalibrationConfig& config, uint32_t level);
191 
194 
195  std::timed_mutex ft_data_lock_;
196 };
197 
198 }
199 #endif
bool srvCallback_CalculateOffsetWithoutGravity(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
force_torque_sensor::FTSConfigurationParameters FTS_params_
force_torque_sensor::CalibrationParameters calibration_params_
force_torque_sensor::CoordinateSystemCalibrationParameters CS_params_
bool updateTransform(std::string goal_frame, std::string source_frame)
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * threshold_filtered_pub_
geometry_msgs::Wrench makeAverageMeasurement(uint number_of_measurements, double time_between_meas, std::string frame_id="")
filters::FilterBase< geometry_msgs::WrenchStamped > * gravity_compensator_
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * moving_mean_pub_
filters::FilterBase< geometry_msgs::WrenchStamped > * threshold_filter_
bool srvCallback_CalculateAverageMasurement(force_torque_sensor::CalculateAverageMasurement::Request &req, force_torque_sensor::CalculateAverageMasurement::Response &res)
bool calculate_offset(bool apply_after_calculation, geometry_msgs::Wrench *new_offset)
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * output_data_pub_
filters::FilterBase< geometry_msgs::WrenchStamped > * moving_mean_filter_
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * transformed_data_pub_
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * low_pass_pub_
force_torque_sensor::PublishConfigurationParameters pub_params_
iirob_filters::GravityCompensationParameters gravity_params_
bool srvCallback_setSensorOffset(force_torque_sensor::SetSensorOffset::Request &req, force_torque_sensor::SetSensorOffset::Response &res)
bool srvCallback_Init(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
unsigned char uint8_t
bool transform_wrench(std::string goal_frame, std::string source_frame, geometry_msgs::Wrench wrench, geometry_msgs::Wrench &transformed)
bool srvCallback_CalculateOffset(force_torque_sensor::CalculateSensorOffset::Request &req, force_torque_sensor::CalculateSensorOffset::Response &res)
dynamic_reconfigure::Server< force_torque_sensor::CalibrationConfig > reconfigCalibrationSrv_
force_torque_sensor::HWCommunicationConfigurationParameters HWComm_params_
void reconfigureCalibrationRequest(force_torque_sensor::CalibrationConfig &config, uint32_t level)
void init_sensor(std::string &msg, bool &success)
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * gravity_compensated_pub_
realtime_tools::RealtimePublisher< geometry_msgs::WrenchStamped > * sensor_data_pub_
boost::shared_ptr< hardware_interface::ForceTorqueSensorHW > sensor_
bool srvReadDiagnosticVoltages(force_torque_sensor::DiagnosticVoltages::Request &req, force_torque_sensor::DiagnosticVoltages::Response &res)
boost::shared_ptr< pluginlib::ClassLoader< hardware_interface::ForceTorqueSensorHW > > sensor_loader_
filters::FilterBase< geometry_msgs::WrenchStamped > * low_pass_filter_
force_torque_sensor::NodeConfigurationParameters node_params_
bool srvCallback_DetermineCoordinateSystem(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
hardware_interface::ForceTorqueSensorHW * p_Ftc


force_torque_sensor
Author(s):
autogenerated on Fri Sep 18 2020 03:06:30