ForceTorqueCtrl.h
Go to the documentation of this file.
1 /****************************************************************
2  *
3  * Copyright 2016 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-2016
11  *
12  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13  *
14  * Copyright (c) 2010
15  *
16  * Fraunhofer Institute for Manufacturing Engineering
17  * and Automation (IPA)
18  *
19  * Date of creation: June 2010
20  *
21  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions are met:
25  *
26  * * Redistributions of source code must retain the above copyright
27  * notice, this list of conditions and the following disclaimer.
28  * * Redistributions in binary form must reproduce the above copyright
29  * notice, this list of conditions and the following disclaimer in the
30  * documentation and/or other materials provided with the distribution.
31  * * Neither the name of the copyright holder nor the names of its
32  * contributors may be used to endorse or promote products derived from
33  * this software without specific prior written permission.
34  *
35  * This program is free software: you can redistribute it and/or modify
36  * it under the terms of the GNU Lesser General Public License LGPL as
37  * published by the Free Software Foundation, either version 3 of the
38  * License, or (at your option) any later version.
39  *
40  * This program is distributed in the hope that it will be useful,
41  * but WITHOUT ANY WARRANTY; without even the implied warranty of
42  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43  * GNU Lesser General Public License LGPL for more details.
44  *
45  * You should have received a copy of the GNU Lesser General Public
46  * License LGPL along with this program.
47  * If not, see <http://www.gnu.org/licenses/>.
48  *
49  ****************************************************************/
50 
51 #ifndef FORCETORQUECTRL_INCLUDEDEF_H
52 #define FORCETORQUECTRL_INCLUDEDEF_H
53 
54 #include <iostream>
55 #include <fstream>
56 #include <Eigen/Core>
57 
58 // Headers provided by other cob-packages
59 #include <cob_generic_can/CanItf.h>
60 
61 #define DEBUG 0
62 
63 // opCodes for the ForceTorque Can Interface
64 // set as Can Message ID
65 #define READ_SG 0x0
66 #define READ_MATRIX 0x2
67 #define READ_SERIALNR 0x5
68 #define SET_CALIB 0x6
69 #define READ_COUNTSPERU 0x7
70 #define READ_UNITCODE 0x8
71 #define READ_DIAGNOV 0X9
72 #define RESET 0xC
73 #define SET_BASEID 0xD
74 #define SET_BAUD 0xE
75 #define READ_FIRMWARE 0xF
76 
77 #define ATI_CAN_BAUD_2M 0
78 #define ATI_CAN_BAUD_1M 1
79 #define ATI_CAN_BAUD_500K 3
80 #define ATI_CAN_BAUD_250K 7
81 
83 {
84 public:
86  ForceTorqueCtrl(int can_type, std::string can_path, int can_baudrate, int base_identifier);
88 
89  bool Init();
90  bool ReadFTSerialNumber();
91  bool ReadCountsPerUnit();
92  bool ReadUnitCodes();
93  bool readDiagnosticADCVoltages(int index, short int& value);
94  bool SetActiveCalibrationMatrix(int num);
95  bool SetBaudRate(int value);
96  bool SetBaseIdentifier(int identifier);
97  bool Reset();
98  bool ReadSGData(int statusCode, double& Fx, double& Fy, double& Fz, double& Tx, double& Ty, double& Tz);
99  bool ReadFirmwareVersion();
100  void ReadCalibrationMatrix();
101 
102  void SetGaugeOffset(float sg0Off, float sg1Off, float sg2Off, float sg3Off, float sg4Off, float sg5Off);
103  void SetGaugeGain(float gg0, float gg1, float gg2, float gg3, float gg4, float gg5);
104  void SetFXGain(float fxg0, float fxg1, float fxg2, float fxg3, float fxg4, float fxg5);
105  void SetFYGain(float fyg0, float fyg1, float fyg2, float fyg3, float fyg4, float fyg5);
106  void SetFZGain(float fzg0, float fzg1, float fzg2, float fzg3, float fzg4, float fzg5);
107  void SetTXGain(float txg0, float txg1, float txg2, float txg3, float txg4, float txg5);
108  void SetTYGain(float tyg0, float tyg1, float tyg2, float tyg3, float tyg4, float tyg5);
109  void SetTZGain(float tzg0, float tzg1, float tzg2, float tzg3, float tzg4, float tzg5);
110 
111  void SetCalibMatrix();
112  void CalcCalibMatrix();
113  void StrainGaugeToForce(int& sg0, int& sg1, int& sg2, int& sg3, int& sg4, int& sg5);
114 
115 protected:
116  bool initCan();
117 
118  //--------------------------------- Variables
121 
122 private:
125 
127  std::string m_CanDevice;
130 
131  unsigned int d_len;
132  Eigen::VectorXf m_v3StrainGaigeOffset;
133  Eigen::VectorXf m_v3GaugeGain;
134  Eigen::VectorXf m_v3FXGain;
135  Eigen::VectorXf m_v3FYGain;
136  Eigen::VectorXf m_v3FZGain;
137  Eigen::VectorXf m_v3TXGain;
138  Eigen::VectorXf m_v3TYGain;
139  Eigen::VectorXf m_v3TZGain;
140  Eigen::MatrixXf m_mXCalibMatrix;
141  Eigen::MatrixXf m_vForceData;
142 
143  // the Parameter indicates the Axis row to Read
144  // Fx = 0 | Fy = 1 | Fz = 2 | Tx = 3 | Ty = 4 | Tz = 5
145  void ReadMatrix(int axis, Eigen::VectorXf& vec);
146 
147  union
148  {
149  char bytes[2];
150  short int value;
151  } ibBuf;
152 
153  union
154  {
155  char bytes[4];
156  int value;
157  } intbBuf;
158 
159  union
160  {
161  char bytes[4];
162  float value;
163  } fbBuf;
164 
165  std::ofstream out;
166 };
167 
168 #endif
Eigen::VectorXf m_v3GaugeGain
Eigen::MatrixXf m_vForceData
std::string m_CanDevice
Eigen::VectorXf m_v3FXGain
void SetFYGain(float fyg0, float fyg1, float fyg2, float fyg3, float fyg4, float fyg5)
void SetTYGain(float tyg0, float tyg1, float tyg2, float tyg3, float tyg4, float tyg5)
bool ReadSGData(int statusCode, double &Fx, double &Fy, double &Fz, double &Tx, double &Ty, double &Tz)
Eigen::MatrixXf m_mXCalibMatrix
void SetTZGain(float tzg0, float tzg1, float tzg2, float tzg3, float tzg4, float tzg5)
void SetFZGain(float fzg0, float fzg1, float fzg2, float fzg3, float fzg4, float fzg5)
bool readDiagnosticADCVoltages(int index, short int &value)
void SetTXGain(float txg0, float txg1, float txg2, float txg3, float txg4, float txg5)
Eigen::VectorXf m_v3FYGain
bool SetBaudRate(int value)
bool SetActiveCalibrationMatrix(int num)
Eigen::VectorXf m_v3TZGain
void SetFXGain(float fxg0, float fxg1, float fxg2, float fxg3, float fxg4, float fxg5)
void ReadMatrix(int axis, Eigen::VectorXf &vec)
union ForceTorqueCtrl::@3 ibBuf
void SetGaugeOffset(float sg0Off, float sg1Off, float sg2Off, float sg3Off, float sg4Off, float sg5Off)
Eigen::VectorXf m_v3TYGain
union ForceTorqueCtrl::@4 intbBuf
bool SetBaseIdentifier(int identifier)
Eigen::VectorXf m_v3FZGain
std::ofstream out
unsigned int d_len
union ForceTorqueCtrl::@5 fbBuf
Eigen::VectorXf m_v3StrainGaigeOffset
Eigen::VectorXf m_v3TXGain
void StrainGaugeToForce(int &sg0, int &sg1, int &sg2, int &sg3, int &sg4, int &sg5)
void SetGaugeGain(float gg0, float gg1, float gg2, float gg3, float gg4, float gg5)


ati_force_torque
Author(s): Denis Štogl, Alexander Bubeck
autogenerated on Thu Sep 17 2020 03:18:35