24     #pragma comment(lib, "Shlwapi.lib")    27 #if defined (__linux) || defined (__APPLE__)    30     #define _stricmp(x,y) strcasecmp(x,y)    33 #define PLUGIN_VERSION 1    38 #define CONCAT(x,y,z) x y z    39 #define strConCat(x,y,z)    CONCAT(x,y,z)    40 #define LUA_GET_SENSOR_DATA_COMMAND "simExtSkeleton_getSensorData"    41 #define LUA_KUKA_LBR_IIWA_START_COMMAND "simExtKukaLBRiiwaStart"    67 std::string 
LUA_KUKA_LBR_IIWA_START_CALL_TIP(
"number result=simExtKukaLBRiiwaStart(string_table JointHandles , string RobotTipHandle, string RobotFlangeTipHandle, string RobotTargetHandle, string RobotTargetBaseHandle, string RobotModel, string LocalUDPAddress, string LocalUDPPort, string RemoteUDPAddress, string LocalHostKukaKoniUDPAddress, string LocalHostKukaKoniUDPPort, string RemoteHostKukaKoniUDPAddress, string RemoteHostKukaKoniUDPPort, string KukaCommandMode, string KukaMonitorMode, string IKGroupName) -- KukaCommandMode options are JAVA and FRI");
    75         BOOST_LOG_TRIVIAL(info) << 
"Starting KUKA LBR iiwa plugin connection to Kuka iiwa\n";
    82             std::vector<CLuaFunctionDataItem>* inData=data.
getInDataPtr();
    83             std::vector<std::string> JointHandles;
    84             for (
size_t i=0;i<inData->at(0).stringData.size();i++)
    86               JointHandles.push_back(std::string(inData->at(0).stringData[i].c_str()));
    88             std::string RobotFlangeTipHandle                (inData->at(1 ).stringData[0]);
    89             std::string RobotTipHandle                      (inData->at(2 ).stringData[0]);
    90             std::string RobotTargetHandle                   (inData->at(3 ).stringData[0]);
    91             std::string RobotTargetBaseHandle               (inData->at(4 ).stringData[0]);
    92             std::string RobotModel                          (inData->at(5 ).stringData[0]);
    93             std::string LocalUDPAddress                     (inData->at(6 ).stringData[0]);
    94             std::string LocalUDPPort                        (inData->at(7 ).stringData[0]);
    95             std::string RemoteUDPAddress                    (inData->at(8 ).stringData[0]);
    96             std::string LocalHostKukaKoniUDPAddress         (inData->at(9 ).stringData[0]);
    97             std::string LocalHostKukaKoniUDPPort            (inData->at(10).stringData[0]);
    98             std::string RemoteHostKukaKoniUDPAddress        (inData->at(11).stringData[0]);
    99             std::string RemoteHostKukaKoniUDPPort           (inData->at(12).stringData[0]);
   100             std::string KukaCommandMode                     (inData->at(13).stringData[0]);
   101             std::string KukaMonitorMode                     (inData->at(14).stringData[0]);
   102             std::string IKGroupName                         (inData->at(15).stringData[0]);
   105             kukaPluginPG=std::make_shared<grl::vrep::KukaVrepPlugin>(
   108                     RobotFlangeTipHandle          ,
   111                     RobotTargetBaseHandle         ,
   116                     LocalHostKukaKoniUDPAddress   ,
   117                     LocalHostKukaKoniUDPPort      ,
   118                     RemoteHostKukaKoniUDPAddress  ,
   119                     RemoteHostKukaKoniUDPPort     ,
   125             kukaPluginPG->construct();
   129             kukaPluginPG=std::make_shared<grl::vrep::KukaVrepPlugin>();
   138   } 
catch (
const boost::exception& e){
   140       std::string initerr(
"v_repExtKukaLBRiiwa plugin encountered the following error and will disable itself:\n" + boost::diagnostic_information(e));
   142       BOOST_LOG_TRIVIAL(error) <<  initerr;
   144   } 
catch (
const std::exception& e){
   146       std::string initerr(
"v_repExtKukaLBRiiwa plugin encountered the following error and will disable itself:\n" + boost::diagnostic_information(e));
   148       BOOST_LOG_TRIVIAL(error) <<  initerr;
   152       std::string initerr(
"v_repExtKukaLBRiiwa plugin encountered an unknown error and will disable itself. Please debug this issue! file and line:" + std::string(__FILE__) + 
" " + boost::lexical_cast<std::string>(__LINE__) + 
"\n");
   154       BOOST_LOG_TRIVIAL(error) <<  initerr;
   161 VREP_DLLEXPORT 
unsigned char v_repStart(
void* reservedPointer,
int reservedInt)
   166     char curDirAndFile[1024];
   168     GetModuleFileName(NULL,curDirAndFile,1023);
   169     PathRemoveFileSpec(curDirAndFile);
   170 #elif defined (__linux) || defined (__APPLE__)   171     getcwd(curDirAndFile, 
sizeof(curDirAndFile));
   173     std::string currentDirAndPath(curDirAndFile);
   175     std::string temp(currentDirAndPath);
   178 #elif defined (__linux)   179     temp+=
"/libv_rep.so";
   180 #elif defined (__APPLE__)   181     temp+=
"/libv_rep.dylib";
   187         BOOST_LOG_TRIVIAL(error) << 
"Error, could not find or correctly load the V-REP library. Cannot start 'v_repExtKukaLBRiiwa' plugin.\n";
   192         BOOST_LOG_TRIVIAL(error) << 
"Error, could not find all required functions in the V-REP library. Cannot start 'v_repExtKukaLBRiiwa' plugin.\n";
   204         BOOST_LOG_TRIVIAL(error) << 
"Sorry, your V-REP copy is somewhat old. Cannot start 'v_repExtKukaLBRiiwa' plugin.\n";
   214     std::vector<int> inArgs;
   234     BOOST_LOG_TRIVIAL(info) << 
"KUKA LBR iiwa plugin initialized. Build date/time: " << __DATE__ << 
" " << __TIME__ <<
"\n";
   255 VREP_DLLEXPORT 
void* 
v_repMessage(
int message,
int* auxiliaryData,
void* customData,
int* replyData)
   258     static bool refreshDlgFlag=
true;
   281         int flags=auxiliaryData[0];
   282         bool sceneContentChanged=((flags&(1+2+4+8+16+32+64+256))!=0); 
   283         bool instanceSwitched=((flags&64)!=0);
   285         if (instanceSwitched)
   290         if (sceneContentChanged)
   321               } 
catch (
const boost::exception& e){
   323                   std::string initerr(
"v_repExtKukaLBRiiwa plugin encountered the following error and will disable itself:\n" + boost::diagnostic_information(e));
   325                   BOOST_LOG_TRIVIAL(error) <<  initerr;
   327               } 
catch (
const std::exception& e){
   329                   std::string initerr(
"v_repExtKukaLBRiiwa plugin encountered the following error and will disable itself:\n" + boost::diagnostic_information(e));
   331                   BOOST_LOG_TRIVIAL(error) <<  initerr;
   335                   std::string initerr(
"v_repExtKukaLBRiiwa plugin encountered an unknown error and will disable itself. Please debug this issue! file and line:" + std::string(__FILE__) + 
" " + boost::lexical_cast<std::string>(__LINE__) + 
"\n");
   337                   BOOST_LOG_TRIVIAL(error) <<  initerr;
   380         BOOST_LOG_TRIVIAL(info) << 
"Ending KUKA LBR iiwa plugin connection to Kuka iiwa\n";
   387         if ( (customData==NULL)||(_stricmp(
"PluginSkeleton",(
char*)customData)==0) ) 
   395         if ( (customData==NULL)||(_stricmp(
"PluginSkeleton",(
char*)customData)==0) ) 
   403         if ( (customData==NULL)||(_stricmp(
"PluginSkeleton",(
char*)customData)==0) ) 
   432         refreshDlgFlag=
false;
 
int getVrepProcAddresses(LIBRARY lib)
 
LIBRARY loadVrepLibrary(const char *pathAndFilename)
 
bool readDataFromLua(const SLuaCallBack *p, const int *expectedArguments, int requiredArgumentCount, const char *functionName)
 
VREP_DLLEXPORT unsigned char v_repStart(void *reservedPointer, int reservedInt)
 
std::shared_ptr< grl::vrep::KukaVrepPlugin > kukaPluginPG
 
ptrSimSetIntegerParameter simSetIntegerParameter
 
void LUA_SIM_EXT_KUKA_LBR_IIWA_START(SLuaCallBack *p)
 
ptrSimGetIntegerParameter simGetIntegerParameter
 
void unloadVrepLibrary(LIBRARY lib)
 
VREP_DLLEXPORT void * v_repMessage(int message, int *auxiliaryData, void *customData, int *replyData)
 
const int inArgs_KUKA_LBR_IIWA_START[]
 
VREP_DLLEXPORT void v_repEnd()
 
static void getInputDataForFunctionRegistration(const int *dat, std::vector< int > &outDat)
 
ptrSimRegisterCustomLuaFunction simRegisterCustomLuaFunction
 
#define LUA_KUKA_LBR_IIWA_START_COMMAND
 
std::string LUA_KUKA_LBR_IIWA_START_CALL_TIP("number result=simExtKukaLBRiiwaStart(string_table JointHandles , string RobotTipHandle, string RobotFlangeTipHandle, string RobotTargetHandle, string RobotTargetBaseHandle, string RobotModel, string LocalUDPAddress, string LocalUDPPort, string RemoteUDPAddress, string LocalHostKukaKoniUDPAddress, string LocalHostKukaKoniUDPPort, string RemoteHostKukaKoniUDPAddress, string RemoteHostKukaKoniUDPPort, string KukaCommandMode, string KukaMonitorMode, string IKGroupName) -- KukaCommandMode options are JAVA and FRI")
 
ptrSimGetSimulationState simGetSimulationState
 
std::vector< CLuaFunctionDataItem > * getInDataPtr()
 
ptrSimAddStatusbarMessage simAddStatusbarMessage