This function returns the cartesian force at the robotical arm's end effector. Translation unit is N and orientation unit is N * m .
#include <iostream>
#include <dlfcn.h>
#include <vector>
#include "KinovaTypes.h"
using namespace std;
int main()
{
int result;
CartesianPosition data;
cout << "GetCartesianForce function example" << endl;
void * commandLayer_handle;
int (*MyInitAPI)();
int (*MyCloseAPI)();
int (*MyGetCartesianForce)(CartesianPosition &);
commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);
MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
MyGetCartesianForce = (int (*)(CartesianPosition &)) dlsym(commandLayer_handle,"GetCartesianForce");
if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MyGetCartesianForce == NULL))
{
cout << "Unable to initialize the command layer." << endl;
}
else
{
cout << "The command has been initialized correctly." << endl << endl;
cout << "Calling the method InitAPI()" << endl;
result = (*MyInitAPI)();
cout << "result of InitAPI() = " << result << endl;
result = (*MyGetCartesianForce)(data);
cout << " Position X : " << data.Coordinates.X << " N" << endl;
cout << " Position Y : " << data.Coordinates.Y << " N" << endl;
cout << " Position Z : " << data.Coordinates.Z << " N" << endl;
cout << " Position ThetaX : " << data.Coordinates.ThetaX << " N*m" << endl;
cout << " Position ThetaY : " << data.Coordinates.ThetaY << " N*m" << endl;
cout << " Position ThetaZ : " << data.Coordinates.ThetaZ << " N*m" << endl;
cout << "Position Finger 1 : " << data.Fingers.Finger1 << endl;
cout << "Position Finger 2 : " << data.Fingers.Finger2 << endl;
cout << "Position Finger 3 : " << data.Fingers.Finger3 << endl;
cout << endl << "Calling the method CloseAPI()" << endl;
result = (*MyCloseAPI)();
cout << "result of CloseAPI() = " << result << endl;
}
return 0;
}