Extending the Remote APIInstead of extending the functions that the remote API offers, one can use the generic remote API function simxCallScriptFunction: this will call a V-REP script function, which can then execute any type of operation locally, then return data. The called script function should always have following input/output form: myFunctionName=function(inInts,inFloats,inStrings,inBuffer) -- inInts, inFloats and inStrings are tables -- inBuffer is a string -- Perform any type of operation here. -- Always return 3 tables and a string, e.g.: return {},{},{},'' end The remote API client application would then call above script function in following manner (e.g. via a Python script): inputInts=[1,2,3] inputFloats=[53.21,17.39] inputStrings=['Hello','world!'] inputBuffer=bytearray() inputBuffer.append(78) inputBuffer.append(42) res,retInts,retFloats,retStrings,retBuffer=vrep.simxCallScriptFunction(clientID,'objectName',vrep.sim_scripttype_childscript, 'myFunctionName',inputInts,inputFloats,inputStrings,inputBuffer,vrep.simx_opmode_blocking) if res==vrep.simx_return_ok: print (retInts) print (retFloats) print (retStrings) print (retBuffer) For other usage examples, refer to the various files named complexCommandTest.* in folder programming/remoteApiBindings. Recommended topics |