1 /* ATIDAQ F/T C Library * 2 * Copyright (c) ATI Industrial Automation 3 * 4 * The MIT License 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included 14 * in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 /* ftconfig.h - calibration file and configuration routines 26 modifications: 27 June.15.2005 - Sam Skuce (ATI Industrial Automation) and Gabriel Baud-Bovy - 28 moved some stuff out of ftrt.h in ftsharedrt.h, moved some 'private' function declarations 29 that were in ftconfig.h into ftconfig.c, moved #include dom.h into ftconfig.c as well, 30 added #ifndef FTCONFIG_H statements 31 */ 32 33 #ifndef FTCONFIG_H 34 #define FTCONFIG_H /*june.15.2005 - ss - added*/ 35 36 // #include "ftrt.h" // GBB: commented out (required #include inserted below) 37 // #include "dom.h" // GBB: commented out (moved into ftconfig.c) 38 #include "ftsharedrt.h" /* june.15.2005 - ss - added*/ 39 40 41 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 48 49 50 #define PI 3.14159265358979 51 52 typedef char *Units; 53 typedef struct Configuration Configuration; 54 typedef struct Calibration Calibration; 55 typedef struct Transform Transform; 56 57 // note: tool transforms only supported for 6-axis F/T transducers 58 struct Transform { 59 float TT[6]; // displacement/rotation vector dx, dy, dz, rx, ry, rz 60 Units DistUnits; // units of dx, dy, dz 61 Units AngleUnits; // units of rx, ry, rz 62 }; 63 // settings that can be changed by the user 64 struct Configuration { 65 Units ForceUnits; // force units of output 66 Units TorqueUnits; // torque units of output 67 Transform UserTransform; // coordinate system transform set by user 68 BOOL TempCompEnabled; // is temperature compensation enabled? 69 }; 70 71 // transducer properties read from calibration file 72 struct Calibration { 73 float BasicMatrix[MAX_AXES][MAX_GAUGES]; // non-usable matrix; use rt.working_matrix for calculations 74 Units ForceUnits; // force units of basic matrix, as read from file; constant 75 Units TorqueUnits; // torque units of basic matrix, as read from file; constant 76 BOOL TempCompAvailable; // does this calibration have optional temperature compensation? 77 Transform BasicTransform; // built-in coordinate transform; for internal use 78 float MaxLoads[MAX_AXES]; // maximum loads of each axis, in units above 79 char *AxisNames[MAX_AXES]; // names of each axis 80 char *Serial; // serial number of transducer (such as "FT4566") 81 char *BodyStyle; // transducer's body style (such as "Delta") 82 char *PartNumber; // calibration part number (such as "US-600-3600") 83 char *Family; // family of transducer (typ. "DAQ") 84 char *CalDate; // date of calibration 85 Configuration cfg; // struct containing configurable parameters 86 RTCoefs rt; // struct containing coefficients used in realtime calculations 87 88 }; 89 90 91 Calibration *createCalibration(char *CalFilePath, unsigned short index); 92 // Loads calibration info for a transducer into a new Calibration struct 93 // Parameters: 94 // CalFilePath: the name and path of the calibration file 95 // index: the number of the calibration within the file (usually 1) 96 // Return Values: 97 // NULL: Could not load the desired calibration. 98 // Notes: For each Calibration object initialized by this function, 99 // destroyCalibration must be called for cleanup. 100 101 void destroyCalibration(Calibration *cal); 102 // Frees memory allocated for Calibration struct by a successful 103 // call to createCalibration. Must be called when Calibration 104 // struct is no longer needed. 105 // Parameters: 106 // cal: initialized Calibration struct 107 108 short SetToolTransform(Calibration *cal, float Vector[6],char *DistUnits,char *AngleUnits); 109 // Performs a 6-axis translation/rotation on the transducer's coordinate system. 110 // Parameters: 111 // cal: initialized Calibration struct 112 // Vector: displacements and rotations in the order Dx, Dy, Dz, Rx, Ry, Rz 113 // DistUnits: units of Dx, Dy, Dz 114 // AngleUnits: units of Rx, Ry, Rz 115 // Return Values: 116 // 0: Successful completion 117 // 1: Invalid Calibration struct 118 // 2: Invalid distance units 119 // 3: Invalid angle units 120 121 short SetForceUnits(Calibration *cal, char *NewUnits); 122 // Sets the units of force output 123 // Parameters: 124 // cal: initialized Calibration struct 125 // NewUnits: units for force output 126 // ("lb","klb","N","kN","g","kg") 127 // Return Values: 128 // 0: Successful completion 129 // 1: Invalid Calibration struct 130 // 2: Invalid force units 131 132 short SetTorqueUnits(Calibration *cal, char *NewUnits); 133 // Sets the units of torque output 134 // Parameters: 135 // cal: initialized Calibration struct 136 // NewUnits: units for torque output 137 // ("in-lb","ft-lb","N-m","N-mm","kg-cm") 138 // Return Values: 139 // 0: Successful completion 140 // 1: Invalid Calibration struct 141 // 2: Invalid torque units 142 143 short SetTempComp(Calibration *cal, int TCEnabled); 144 // Enables or disables temperature compensation, if available 145 // Parameters: 146 // cal: initialized Calibration struct 147 // TCEnabled: 0 = temperature compensation off 148 // 1 = temperature compensation on 149 // Return Values: 150 // 0: Successful completion 151 // 1: Invalid Calibration struct 152 // 2: Not available on this transducer system 153 154 void Bias(Calibration *cal, float voltages[]); 155 // Stores a voltage reading to be subtracted from subsequent readings, 156 // effectively "zeroing" the transducer output to remove tooling weight, etc. 157 // Parameters: 158 // cal: initialized Calibration struct 159 // voltages: array of voltages acuired by DAQ system 160 161 void ConvertToFT(Calibration *cal, float voltages[],float result[]); 162 // Converts an array of voltages into forces and torques and 163 // returns them in result 164 // Parameters: 165 // cal: initialized Calibration struct 166 // voltages: array of voltages acuired by DAQ system 167 // result: array of force-torque values (typ. 6 elements) 168 169 170 void printCalInfo(Calibration *cal) ; 171 // print Calibration info on the console 172 173 174 175 176 /* GBB: moved to ftconfig.c 177 178 //------------------------------------------------- 179 // private functions 180 //------------------------------------------------- 181 void ResetDefaults(Calibration *cal); 182 short CalcMatrix(Calibration *cal); 183 short GetMatrix(Calibration *cal, float *result); 184 short TTM(Transform xform,float result[6][6],Units ForceUnits,Units TorqueUnits); 185 float ForceConv(char *Units); 186 float TorqueConv(char *Units); 187 float DistConv(char *Units); 188 float AngleConv(char *Units); 189 short ReadAttribute(const DOM_Element *elem, char **attValue, char *attName, BOOL required, char *defaultValue); 190 void Separate(char *ValueList,float results[],unsigned short numValues); 191 unsigned short FindText(char *str, unsigned short StartPos); 192 unsigned short FindSpace(char *str, unsigned short StartPos); 193 char *mid(char *instr,unsigned short startpos,unsigned short length); 194 195 */ 196 197 //---------------------------------------------- 198 // 199 200 #ifdef __cplusplus 201 } 202 #endif 203 204 #endif /*FTCONFIG_H*/ 205