This function sends trajectory point(Without limitation) that will be added in the robotical arm's FIFO.
#include <iostream>
#include <dlfcn.h>
#include <vector>
#include "KinovaTypes.h"
using namespace std;
int main()
{
int result;
cout << "SendBasicTrajectory function example" << endl;
void * commandLayer_handle;
int (*MyInitAPI)();
int (*MyCloseAPI)();
int (*MySendBasicTrajectory)(TrajectoryPoint command);
int (*MyStartControlAPI)();
commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);
MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
MySendBasicTrajectory = (int (*)(TrajectoryPoint)) dlsym(commandLayer_handle,"SendBasicTrajectory");
MyStartControlAPI = (int (*)()) dlsym(commandLayer_handle,"StartControlAPI");
if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MySendBasicTrajectory == NULL) || (MyStartControlAPI == 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;
cout << "We take control of the robotic arm." << endl;
result = (*MyStartControlAPI)();
TrajectoryPoint trajectoryPoint;
trajectoryPoint.InitStruct();
trajectoryPoint.Position.HandMode = HAND_NOMOVEMENT;
trajectoryPoint.Position.Type = CARTESIAN_POSITION;
trajectoryPoint.Position.CartesianPosition.X = 0.214f;
trajectoryPoint.Position.CartesianPosition.Y = -0.465f;
trajectoryPoint.Position.CartesianPosition.Z = 0.497f;
trajectoryPoint.Position.CartesianPosition.ThetaX = 1.56f;
trajectoryPoint.Position.CartesianPosition.ThetaY = 0.81f;
trajectoryPoint.Position.CartesianPosition.ThetaZ = 0.04f;
(*MySendBasicTrajectory)(trajectoryPoint);
cout << endl << "Calling the method CloseAPI()" << endl;
result = (*MyCloseAPI)();
cout << "result of CloseAPI() = " << result << endl;
}
return 0;
}