FTSensor.h
Go to the documentation of this file.
1 /**
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
17  * @date 2022
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <VirtualRobot/Robot.h>
25 #include <VirtualRobot/IK/DifferentialIK.h>
26 
29 
31 {
32  /// TODO: this has to be moved to the robot model (e.g. the corresponding hand model)
33  /// The values below corresponds to the Armar-6 hands,
34  /// keep it here for now to continue working on controllers
36  {
37  float tcpMassRight = 1.16064;
38  Eigen::Vector3f tcpCoMInFTFrameRight {-0.00258287, -0.00108265, 0.09719};
39  float tcpMassLeft = 1.14715;
40  Eigen::Vector3f tcpCoMInFTFrameLeft {-0.00330519, 0.000470962, 0.100648};
41  };
42 
43 
44  class FTSensor
45  {
46  public:
47  struct FTConfig
48  {
49  std::string sensorName;
50  float ftFilter = 1.0f;
51  float deadZoneForce = 0.0f;
52  float deadZoneTorque = 0.0f;
53  float timeLimit = 0.1f;
54 
55  // float tcpMass = 0.0f;
56  // Eigen::Vector3f tcpCoMInFTSensorFrame;
57 
59  bool reCalibrate = false;
60 
61  Eigen::Vector3f forceBaseline;
62  Eigen::Vector3f torqueBaseline;
63  };
64 
65  FTSensor(){};
66  ~FTSensor(){};
67  void initialize(
68  const VirtualRobot::RobotNodeSetPtr& rns,
69  const armarx::RobotUnitPtr& robotUnit,
70  const FTConfig& c
71  );
72  void reset();
73  bool calibrate(const FTConfig& c, double deltaT);
74  Eigen::Vector6f& compensateTCPGravity(const FTConfig &data);
76 
77  std::atomic_bool calibrated = false;
78 
79  private:
80  std::string sensorName;
81  std::string sensorFrame;
82 
83  FTCalibrateDefaultValue calibDefalts;
84 
85  const SensorValueForceTorque* forceSensor;
86  VirtualRobot::RobotNodePtr sensorNode;
87 
88  Eigen::Vector6f tcpGravityCompensation;
89  Eigen::Vector6f ft;
90 
91  /// local variables
92  float tcpMass = 0.0f;
93  Eigen::Vector3f tcpCoMInFTSensorFrame;
94 
95  /// for filtering and calibration
96  Eigen::Vector3f forceOffset;
97  Eigen::Vector3f torqueOffset;
98  Eigen::Vector3f filteredForce;
99  Eigen::Vector3f filteredTorque;
100  Eigen::Vector3f filteredForceInRoot;
101  Eigen::Vector3f filteredTorqueInRoot;
102  float timeForCalibration;
103 
104 
105  /// for gravity compensation
106  const Eigen::Vector3f gravity { 0.0, 0.0, -9.8 };
107 
108  Eigen::Matrix4f forceFrameInTCP = Eigen::Matrix4f::Identity();
109  Eigen::Vector3f tcpCoMInTCPFrame;
110 
111  };
112 }
armarx::control::common::ft::FTSensor::initialize
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const armarx::RobotUnitPtr &robotUnit, const FTConfig &c)
Definition: FTSensor.cpp:19
armarx::control::common::ft::FTSensor::FTConfig::sensorName
std::string sensorName
Definition: FTSensor.h:49
armarx::control::common::ft::FTCalibrateDefaultValue::tcpMassRight
float tcpMassRight
Definition: FTSensor.h:37
RobotUnit.h
armarx::control::common::ft
This file is part of ArmarX.
Definition: aron_conversions.cpp:25
SensorValueForceTorque.h
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::control::common::ft::FTCalibrateDefaultValue::tcpCoMInFTFrameRight
Eigen::Vector3f tcpCoMInFTFrameRight
Definition: FTSensor.h:38
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::control::common::ft::FTSensor::FTConfig::ftFilter
float ftFilter
Definition: FTSensor.h:50
armarx::control::common::ft::FTSensor::FTConfig::deadZoneTorque
float deadZoneTorque
Definition: FTSensor.h:52
armarx::control::common::ft::FTSensor::FTSensor
FTSensor()
Definition: FTSensor.h:65
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::control::common::ft::FTSensor::calibrated
std::atomic_bool calibrated
Definition: FTSensor.h:77
armarx::control::common::ft::FTCalibrateDefaultValue::tcpCoMInFTFrameLeft
Eigen::Vector3f tcpCoMInFTFrameLeft
Definition: FTSensor.h:40
armarx::control::common::ft::FTCalibrateDefaultValue
TODO: this has to be moved to the robot model (e.g.
Definition: FTSensor.h:35
armarx::control::common::ft::FTSensor::FTConfig::enableTCPGravityCompensation
bool enableTCPGravityCompensation
Definition: FTSensor.h:58
armarx::control::common::ft::FTSensor::FTConfig::deadZoneForce
float deadZoneForce
Definition: FTSensor.h:51
armarx::control::common::ft::FTSensor::FTConfig::forceBaseline
Eigen::Vector3f forceBaseline
Definition: FTSensor.h:61
armarx::control::common::ft::FTSensor::reset
void reset()
Definition: FTSensor.cpp:80
armarx::control::common::ft::FTSensor::FTConfig::reCalibrate
bool reCalibrate
Definition: FTSensor.h:59
armarx::control::common::ft::FTSensor::FTConfig::torqueBaseline
Eigen::Vector3f torqueBaseline
Definition: FTSensor.h:62
armarx::control::common::ft::FTSensor::getFilteredForceTorque
Eigen::Vector6f & getFilteredForceTorque(const FTConfig &data)
Definition: FTSensor.cpp:158
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::control::common::ft::FTSensor::calibrate
bool calibrate(const FTConfig &c, double deltaT)
Definition: FTSensor.cpp:98
armarx::control::common::ft::FTCalibrateDefaultValue::tcpMassLeft
float tcpMassLeft
Definition: FTSensor.h:39
Eigen::Matrix< float, 6, 1 >
armarx::control::common::ft::FTSensor::~FTSensor
~FTSensor()
Definition: FTSensor.h:66
armarx::SensorValueForceTorque
Definition: SensorValueForceTorque.h:31
armarx::control::common::ft::FTSensor::FTConfig::timeLimit
float timeLimit
Definition: FTSensor.h:53
armarx::control::common::ft::FTSensor
Definition: FTSensor.h:44
armarx::control::common::ft::FTSensor::FTConfig
Definition: FTSensor.h:47
armarx::control::common::ft::FTSensor::compensateTCPGravity
Eigen::Vector6f & compensateTCPGravity(const FTConfig &data)
Definition: FTSensor.cpp:131