This function get the cartesian command of the end effector. The orientation is defined by Euler angles(Convention XYZ).
#include <iostream>
#include <dlfcn.h>
#include <vector>
#include "KinovaTypes.h"
using namespace std;
int main()
{
int result;
CartesianPosition data;
cout << "GetCartesianCommand function example" << endl;
void * commandLayer_handle;
int (*MyInitAPI)();
int (*MyCloseAPI)();
int (*MyGetCartesianCommand)(CartesianPosition &);
commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);
MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
MyGetCartesianCommand = (int (*)(CartesianPosition &)) dlsym(commandLayer_handle,"GetCartesianCommand");
if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MyGetCartesianCommand == 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 = (*MyGetCartesianCommand)(data);
cout << " Command X : " << data.Coordinates.X << endl;
cout << " Command Y : " << data.Coordinates.Y << endl;
cout << " Command Z : " << data.Coordinates.Z << endl;
cout << " Command ThetaX : " << data.Coordinates.ThetaX << endl;
cout << " Command ThetaY : " << data.Coordinates.ThetaY << endl;
cout << " Command ThetaZ : " << data.Coordinates.ThetaZ << endl;
cout << "Command Finger 1 : " << data.Fingers.Finger1 << endl;
cout << "Command Finger 2 : " << data.Fingers.Finger2 << endl;
cout << "Command Finger 3 : " << data.Fingers.Finger3 << endl;
cout << endl << "Calling the method CloseAPI()" << endl;
result = (*MyCloseAPI)();
cout << "result of CloseAPI() = " << result << endl;
}
return 0;
}