This function set the PID of a specific actuator.
#include <iostream>
#include <dlfcn.h>
#include <vector>
#include "KinovaTypes.h"
using namespace std;
int main()
{
int result;
cout << "SetActuatorPID function example" << endl;
void * commandLayer_handle;
int (*MyInitAPI)();
int (*MyCloseAPI)();
int (*MySetActuatorPID)(unsigned int address, int P, int I, int D);
commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);
MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
MySetActuatorPID = (int (*)(unsigned int, int, int, int )) dlsym(commandLayer_handle,"SetActuatorPID");
if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MySetActuatorPID == NULL) || (MySetActuatorPID == 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 << endl;
unsigned int ActuatorAddress = 16;
int P = 0.5;
int I = 0;
int D = 0;
cout << "Getting the client configurations the robotic arm." << endl;
(*MySetActuatorPID)(ActuatorAddress, P, I, D);
cout << endl << "Calling the method CloseAPI()" << endl;
result = (*MyCloseAPI)();
cout << "result of CloseAPI() = " << result << endl;
}
return 0;
}