This function get the angular command of all actuators.
#include <iostream>
#include <dlfcn.h>
#include <vector>
#include "KinovaTypes.h"
using namespace std;
int main()
{
int result;
AngularPosition data;
cout << "GetAngularCommand function example" << endl;
void * commandLayer_handle;
int (*MyInitAPI)();
int (*MyCloseAPI)();
int (*MyGetAngularPosition)(AngularPosition &);
commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);
MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
MyGetAngularPosition = (int (*)(AngularPosition &)) dlsym(commandLayer_handle,"GetAngularCommand");
if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MyGetAngularPosition == 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 = (*MyGetAngularPosition)(data);
cout << "Actuator 1 command : " << data.Actuators.Actuator1 << "°" << endl;
cout << "Actuator 2 command : " << data.Actuators.Actuator2 << "°" << endl;
cout << "Actuator 3 command : " << data.Actuators.Actuator3 << "°" << endl;
cout << "Actuator 4 command : " << data.Actuators.Actuator4 << "°" << endl;
cout << "Actuator 5 command : " << data.Actuators.Actuator5 << "°" << endl;
cout << "Actuator 6 command : " << data.Actuators.Actuator6 << "°" << endl;
cout << " Finger 1 command: " << data.Fingers.Finger1 << endl;
cout << " Finger 2 command: " << data.Fingers.Finger2 << endl;
cout << " Finger 3 command: " << data.Fingers.Finger3 << endl;
cout << endl << "Calling the method CloseAPI()" << endl;
result = (*MyCloseAPI)();
cout << "result of CloseAPI() = " << result << endl;
}
return 0;
}