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 <Eigen/Core>
25
26#include <VirtualRobot/VirtualRobot.h>
27
29
30#include <armarx/control/common/ft/aron/FTConfig.aron.generated.h>
31
32namespace armarx
33{
36} // namespace armarx
37
39{
40 /// TODO: this has to be moved to the robot model (e.g. the corresponding hand model)
41 /// The values below corresponds to the Armar-6 hands,
42 /// keep it here for now to continue working on controllers
44 {
45 float tcpMassRight = 1.16064;
46 Eigen::Vector3f tcpCoMInFTFrameRight{-0.00258287, -0.00108265, 0.09719};
47 float tcpMassLeft = 1.14715;
48 Eigen::Vector3f tcpCoMInFTFrameLeft{-0.00330519, 0.000470962, 0.100648};
49 };
50
52 {
53 public:
54 using FTConfig = arondto::FTConfig;
55
58
59 void initialize(const VirtualRobot::RobotNodeSetPtr& rns,
60 const armarx::RobotUnitPtr& robotUnit,
61 const FTConfig& c);
62 void reset();
63 void
64 updateStatus(const FTConfig& c, Eigen::Vector6f& currentFT, double deltaT, bool firstRun);
65 void resetSafeGuardOffset(const FTConfig& c);
66 void enableSafeGuard(bool enableForceGuard, bool enableTorqueGuard);
69 // bool isForceGuardEnabled();
70 // bool isTorqueGuardEnabled();
71 bool isSafe(const FTConfig& c);
72 bool calibrate(const FTConfig& c, double deltaT);
75
76 std::atomic_bool calibrated{false};
77 std::atomic_bool ftSafe{true};
78 std::atomic_bool ftWasNotSafe{false};
79
80 Eigen::Vector3f& getSafeGuardForceOffset();
81
82 private:
83 std::string sensorName;
84 std::string sensorFrame;
85
86 FTCalibrateDefaultValue calibDefaults;
87
88 const SensorValueForceTorque* forceSensor;
89 VirtualRobot::RobotNodePtr sensorNode;
90
91 Eigen::Vector6f tcpGravityCompensation;
93
94 /// local variables
95 float tcpMass = 0.0f;
96 Eigen::Vector3f tcpCoMInFTSensorFrame;
97
98 Eigen::Matrix3f sensorOriInRoot;
99
100 /// for filtering and calibration
101 Eigen::Vector3f forceOffset;
102 Eigen::Vector3f torqueOffset;
103 Eigen::Vector3f filteredForce;
104 Eigen::Vector3f filteredTorque;
105 Eigen::Vector3f rawForce;
106 Eigen::Vector3f rawTorque;
107 Eigen::Vector3f filteredForceInRoot;
108 Eigen::Vector3f filteredTorqueInRoot;
109 Eigen::Vector3f safeGuardForceOffset;
110 Eigen::Vector3f safeGuardTorqueOffset;
111 std::atomic_bool safeGuardEnabledForce{false};
112 std::atomic_bool safeGuardEnabledTorque{false};
113 std::atomic_bool resetForceGuard{false};
114 std::atomic_bool resetTorqueGuard{false};
115 float timeForCalibration;
116
117
118 /// for gravity compensation
119 Eigen::Vector3f gravity{0.0, 0.0, -9.8};
120 Eigen::Vector3f tcpGravForceVec;
121 Eigen::Vector3f tcpGravTorqueVec;
122
123 Eigen::Matrix4f forceFrameInTCP = Eigen::Matrix4f::Identity();
124 Eigen::Vector3f tcpCoMInTCPFrame;
125 };
126} // namespace armarx::control::common::ft
constexpr T c
bool isSafe(const FTConfig &c)
Definition FTSensor.cpp:202
Eigen::Vector3f & getSafeGuardForceOffset()
Definition FTSensor.cpp:340
Eigen::Vector6f & getFilteredForceTorque(const FTConfig &data)
Definition FTSensor.cpp:301
void enableSafeGuard(bool enableForceGuard, bool enableTorqueGuard)
Definition FTSensor.cpp:177
Eigen::Vector6f & compensateTCPGravity(const FTConfig &data)
Definition FTSensor.cpp:272
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const armarx::RobotUnitPtr &robotUnit, const FTConfig &c)
Definition FTSensor.cpp:23
bool calibrate(const FTConfig &c, double deltaT)
Definition FTSensor.cpp:219
void updateStatus(const FTConfig &c, Eigen::Vector6f &currentFT, double deltaT, bool firstRun)
Definition FTSensor.cpp:121
void resetSafeGuardOffset(const FTConfig &c)
Definition FTSensor.cpp:156
Matrix< float, 6, 1 > Vector6f
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
TODO: this has to be moved to the robot model (e.g.
Definition FTSensor.h:44