| KINOVAAPIUSBCOMMANDLAYER_API int SetProtectionZone | ( | ZoneList | Command | ) |
This function sets a new list of protection zones.
| Command | A struct containing the list of protection zones. |
The image below tells how a protection zone must be built and in which order the points must be added to the zone. Note that the dZ is the Z value of a fifth point.
#include <iostream> #include <dlfcn.h> //Ubuntu #include <vector> #include "KinovaTypes.h" //Note that under windows, you may/will have to perform other #include using namespace std; int main() { int result; cout << "SetProtectionZone function example" << endl; //Handle for the library's command layer. void * commandLayer_handle; //Function pointers to the functions we need int (*MyInitAPI)(); int (*MyCloseAPI)(); int (*MySetProtectionZone)(ZoneList); //We load the library (Under Windows, use the function LoadLibrary) commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL); //We load the functions from the library (Under Windows, use GetProcAddress) MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI"); MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI"); MySetProtectionZone = (int (*)(ZoneList)) dlsym(commandLayer_handle,"SetProtectionZone"); //If the was loaded correctly if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MySetProtectionZone == 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; ZoneList zones; zones.NbZones = 1; zones.Zones[0].zoneShape.shapeType = PrismSquareBase_Z; zones.Zones[0].zoneShape.Points[0].X = 0.1f; zones.Zones[0].zoneShape.Points[0].Y = -0.52f; zones.Zones[0].zoneShape.Points[0].Z = 0.23f; zones.Zones[0].zoneShape.Points[0].ThetaX = 0.0f; zones.Zones[0].zoneShape.Points[0].ThetaY = 0.0f; zones.Zones[0].zoneShape.Points[0].ThetaZ = 0.0f; zones.Zones[0].zoneShape.Points[1].X = 0.1f; zones.Zones[0].zoneShape.Points[1].Y = -0.32f; zones.Zones[0].zoneShape.Points[1].Z = 0.23f; zones.Zones[0].zoneShape.Points[2].X = 0.3f; zones.Zones[0].zoneShape.Points[2].Y = -0.32f; zones.Zones[0].zoneShape.Points[2].Z = 0.23f; zones.Zones[0].zoneShape.Points[3].X = 0.3f; zones.Zones[0].zoneShape.Points[3].Y = -0.54f; zones.Zones[0].zoneShape.Points[3].Z = 0.23f; zones.Zones[0].zoneShape.Points[4].Z = 0.63f; result = (*MySetProtectionZone)(zones); cout << "Protection zone has been set with result = " << result << endl; cout << endl << "Calling the method CloseAPI()" << endl; result = (*MyCloseAPI)(); cout << "result of CloseAPI() = " << result << endl; } return 0; }