Skip to content

General Functions

Mahyar Abdeetedal edited this page Aug 31, 2017 · 2 revisions

functions.h is the header file for communicating with KUKA, trajectory generations, and geometrical transformations. More...

Functions

float *  rot2angle (float *rot)
  This method obtains Euler angles from the transformation matrix. More...
 
float *  angle2rot (float *angle)
  This method constructs the transformation matrix using the Euler angles. More...
 
float  deg2rad (float deg)
  This method converts a float degree value to a float radian value. More...
 
float  rad2deg (float rad)
  This method converts a float radian value to a float degree value. More...
 
float  mm2m (float mm)
  This method converts a float millimeter value to a float meter value. More...
 
float  m2mm (float m)
  This method converts a float meter value to a float millimeter value. More...
 
void  saveToFile (System::String^ str, System::String ^ Addr)
  This method saves a string in a file. More...
 
System::String ^  readFromDataGridView (System::Windows::Forms::DataGridView ^ DataView)
  This method creates a savable line out of a Data Grid View. More...
 
System::String ^  loadFromFile (System::String ^ Addr, int &count)
  This method loads the string from a file. More...
 
void  writeToDataGridView (System::Windows::Forms::DataGridView ^ DataView, System::String^ str, System::String^ delimiter)
  This method writes elements in the System String in the System windows Froms Data Grid View. More...
 
void  compoundTrans (float *eeRot, float *toolRot, float *rot)
  This method compounds two matrices. rot = eeRot*toolRot;. More...
 
void  rot2angle (float *rot, float *angle)
  This method obtains Euler angles from the transformation matrix. More...
 
void  angle2rot (float *angle, float *rot)
  This method constructs the transformation matrix using the Euler angles. More...
 
void  inverseTrans (float *eeRot, float *toolRot, float *rot)
  This method constructs the KUKA rotation matrix considering the tool attached to the end-effector.
rToolRot = toolRot(1:3,1:3);
pToolRot = toolRot(1:3, 4);
invToolRot = [transpose(rToolRot), -transpose(rToolRot)*pToolRot;0, 0, 0, 1];
rot = eeRot*invToolRot;. More...
 
void  disp (float *rot, int row, int col)
  This method is an auxiliary function for displaying a matrix. More...
 
void  disp (float *rot, int row, int col, char *name)
  This method is an auxiliary function for displaying a matrix as well as its name. More...
 
void  rot2quat (float *rot, float *quat)
  This method obtains the quaternions from the transformation matrix. More...
 
void  quat2rot (float *quat, float *rot)
  This method constructs the transformation matrix using the quaternions. More...
 
void  startLogging (System::ComponentModel::BackgroundWorker^ workerLog, System::Windows::Forms::TextBox^ txtAdr, tFriMsrData &msr, int selection, unsigned int &j, niVec &recVec, phidgetsVec &phiVec, float *calibratedPhidgets, atiVec &atiVector, float *ee)
  This method selects desired variable using "selection" and logs their values. More...
 
void  rot2vec (float *rot, float *vec)
  This method rearranges the rotation matrix into a new float array to be fed into the trajectory generator. The new arrangement is meant for a better physical meaning of convergence. More...
 
void  vec2rot (float *vec, float *rot)
  This method arranges the new vector back to the transformation matrix. More...
 
void  startFri (System::ComponentModel::BackgroundWorker^ worker, tFriMsrData &msr, tFriCmdData &cmd, friRemote &friInst, bool &trajFlag, unsigned int &j, unsigned int &poseNum, char *kukaWriteCommand, float *tool, float *trg, float &speed, float *cartStiffVals, float *simulinkTrg)
  This is the main method responsible for starting the FRI communications and sending the commands to KUKA and receiving data from KUKA. More...
 

Detailed Description

Header file for communicating with KUKA, trajectory generations, and geometrical transformations.

The declarations here are for the functions.cpp

Date
July 2017
Version
0.1
Author
Mahyar Abdeetedal, mahyar.etedal@icloud.com
Copyright
Copyright (C) 2016 - 2017 Mahyar Abdeetedal

GNU General Public License

This file is part of the KUKA-UI.

The KUKA-UI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The KUKA-UI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the KUKA-UI. If not, see http://www.gnu.org/licenses/.

Function Documentation

◆ angle2rot() [1/2]

float* angle2rot ( float *  angle )

This method constructs the transformation matrix using the Euler angles.

Parameters
angle This is the pointer containing the Euler angles.
Returns
A float array of the transformation matrix.

◆ angle2rot() [2/2]

void angle2rot ( float *  angle,
float *  rot 
)

This method constructs the transformation matrix using the Euler angles.

Parameters
angle This is the pointer containing the Euler angles.
rot A float output array of the transformation matrix.
Returns
The output is a void.

◆ compoundTrans()

void compoundTrans ( float *  eeRot,
float *  toolRot,
float *  rot 
)

This method compounds two matrices. rot = eeRot*toolRot;.

Parameters
eeRot Float array of the left matrix operand.
toolRot Float array of the right matrix operand.
rot Float output array of the result.
Returns
The output is a void.

◆ deg2rad()

float deg2rad ( float  deg )

This method converts a float degree value to a float radian value.

Parameters
deg A float degree value.
Returns
A float radian value.

◆ disp() [1/2]

void disp ( float *  rot,
int  row,
int  col 
)

This method is an auxiliary function for displaying a matrix.

Parameters
rot A float array of the matrix to be displayed.
row An integer specifying the number of rows.
col An integer specifying the number of columns.
Returns
The output is a void.

◆ disp() [2/2]

void disp ( float *  rot,
int  row,
int  col,
char *  name 
)

This method is an auxiliary function for displaying a matrix as well as its name.

Parameters
rot A float array of the matrix to be displayed.
row An integer specifying the number of rows.
col An integer specifying the number of columns
name A character array of matrix's name.
Returns
The output is a void.

◆ inverseTrans()

void inverseTrans ( float *  eeRot,
float *  toolRot,
float *  rot 
)

This method constructs the KUKA rotation matrix considering the tool attached to the end-effector.
rToolRot = toolRot(1:3,1:3);
pToolRot = toolRot(1:3, 4);
invToolRot = [transpose(rToolRot), -transpose(rToolRot)*pToolRot;0, 0, 0, 1];
rot = eeRot*invToolRot;.

Parameters
eeRot Float array of the KUKA end-effector rotation matrix.
toolRot Float array of the Tool rotation matrix.
rot Float output array of the rotation matrix to be fed into KUKA.
Returns
The output is a void.

◆ loadFromFile()

System::String ^ loadFromFile ( System::String ^  Addr,
int &  count 
)

This method loads the string from a file.

Parameters
Addr System String of the location of the file.
count The integer number of lines loaded from the file.
Returns
System String that is loaded from the file.

◆ m2mm()

float m2mm ( float  m )

This method converts a float meter value to a float millimeter value.

Parameters
m A float meter value.
Returns
A float millimeter value.

◆ mm2m()

float mm2m ( float  mm )

This method converts a float millimeter value to a float meter value.

Parameters
mm A float millimeter value.
Returns
A float meter value.

◆ quat2rot()

void quat2rot ( float *  quat,
float *  rot 
)

This method constructs the transformation matrix using the quaternions.

Parameters
quat This is the pointer containing the quaternions.
rot A float output array of the transformation matrix.
Returns
The output is a void.

◆ rad2deg()

float rad2deg ( float  rad )

This method converts a float radian value to a float degree value.

Parameters
rad A float radian value.
Returns
A float degree value.

◆ readFromDataGridView()

System::String readFromDataGridView ( System::Windows::Forms::DataGridView ^  DataView )

This method creates a savable line out of a Data Grid View.

Parameters
DataView System Windows Forms Data Grid View element.
Returns
A String that can be saved into a file.

◆ rot2angle() [1/2]

float* rot2angle ( float *  rot )

This method obtains Euler angles from the transformation matrix.

Parameters
rot This is the pointer containing the rotation matrix.
Returns
A float array of the Euler angles.

◆ rot2angle() [2/2]

void rot2angle ( float *  rot,
float *  angle 
)

This method obtains Euler angles from the transformation matrix.

Parameters
rot This is the pointer containing the rotation matrix.
angle A float output array of the Euler angles.
Returns
The output is a void.

◆ rot2quat()

void rot2quat ( float *  rot,
float *  quat 
)

This method obtains the quaternions from the transformation matrix.

Parameters
rot A float array of the transformation matrix.
quat This is the output pointer containing the quaternions.
Returns
The output is a void.

◆ rot2vec()

void rot2vec ( float *  rot,
float *  vec 
)

This method rearranges the rotation matrix into a new float array to be fed into the trajectory generator. The new arrangement is meant for a better physical meaning of convergence.

Parameters
rot A float array of the transformation matrix.
vec A float output array of the new arrangement.
Returns
The output is a void.

◆ saveToFile()

void saveToFile ( System::String^  str,
System::String ^  Addr 
)

This method saves a string in a file.

Parameters
str A System String containing the line to be saved into the file.
Addr A System String containing the desired address for the file.
Returns
The output is a void.

◆ startFri()

void startFri ( System::ComponentModel::BackgroundWorker^  worker,
tFriMsrData &  msr,
tFriCmdData &  cmd,
friRemote &  friInst,
bool &  trajFlag,
unsigned int &  j,
unsigned int &  poseNum,
char *  kukaWriteCommand,
float *  tool,
float *  trg,
float &  speed,
float *  cartStiffVals,
float *  simulinkTrg 
)

This is the main method responsible for starting the FRI communications and sending the commands to KUKA and receiving data from KUKA.

Parameters
worker A seperate System Component Model Background Worker for FRI communications.
msr The msr variable containing KUKA parameters.
cmd The cmd variable containing KUKA commands.
friInst The friInst variable containing KUKA parameters.
trajFlag A flag for indicating if KUKA UI is in middle of trajectory planned for a specific pose. If trajFlag is true, it shows that KUKA UI is busy applying a trajectory for reaching to a particular pose.
j An index for the pose that currently is being done.
poseNum poseNum is the number of Cartesian poses set for KUKA to reach.
kukaWriteCommand A string of KUKA command for displaying purposes.
tool A float array of the attached tool Euler angles.
trg A float array of the attached the target pose Euler angles.
speed A float for setting the maximum velocity and acceleration for trajectory generation.
cartStiffVals A KUKA parameter for setting the robot stiffness for the Cartesian mode.
simulinkTrg A float array of the target joint variables sent from MATLAB Simulink.
Returns
The output is a void.

◆ startLogging()

void startLogging ( System::ComponentModel::BackgroundWorker^  workerLog,
System::Windows::Forms::TextBox^  txtAdr,
tFriMsrData &  msr,
int  selection,
unsigned int &  j,
niVec recVec,
phidgetsVec phiVec,
float *  calibratedPhidgets,
atiVec atiVector,
float *  ee 
)

This method selects desired variable using "selection" and logs their values.

Parameters
workerLog A seperate System Component Model Background Worker for logging.
txtAdr A String of address for saving the log file.
msr The msr variable containing all KUKA parameters.
selection An integer variable that is used to perform a bitwise logical AND operation. The bitwise operator performs a bitwise logical AND between this variable and the constant assigned to the desired variable for logging. It takes each corresponding bit for both expressions. The bits in the result are set to 1 if and only if both bits in the input expressions have a value of 1; otherwise, the bit in the result is set to 0. For example, the binary representation of 170 (selection) is 0000 0000 1010 1010. The binary representation of 2 (a constant assigned for representing a variable to be logged or B) is 0000 0000 0000 0010. Performing the bitwise AND operation on these two values produces the binary result 0000 0000 0000 0010, which is decimal 2.
(A & B)
0000 0000 1010 1010
0000 0000 0000 0010
----------------—
0000 0000 0000 0010
j An unsigned integer showing the current KUKA pose command number.
recVec A vector containing all variables read from NI DAQ.
phiVec A vector containing variables read from Phidgets.
calibratedPhidgets A float array containing calibrated values for Phidgets data.
atiVector A vector containing force/torque data read from ATI controller.
rot A float array of the transformation matrix.
ee A float array of the transformation matrix with the attached tool considered.
Returns
The output is a void.

◆ vec2rot()

void vec2rot ( float *  vec,
float *  rot 
)

This method arranges the new vector back to the transformation matrix.

Parameters
vec A float array of the new arrangement.
rot A float output array of the transformation matrix.
Returns
The output is a void.

◆ writeToDataGridView()

void writeToDataGridView ( System::Windows::Forms::DataGridView ^  DataView,
System::String^  str,
System::String^  delimiter 
)

This method writes elements in the System String in the System windows Froms Data Grid View.

Parameters
DataView The name of the System windows Forms Data Grid View.
str System string to be parsed and written in the Data Grid View.
delimiter System String for distinguishing each element in the string.
Returns
The output is a void.