Extending the B0-based remote APIBlueZero is deprecated. We highly recommend using the ZeroMQ remote API instead. You basically have two options, if you wish to use API commands that are not exposed by the B0-based remote API: Using the generic function simxCallScriptFunction: instead of extending the functions that the B0-based remote API offers, one can use the generic B0-based remote API function simxCallScriptFunction: this will call a CoppeliaSim script function, which can then execute any type of operation locally, then return data. For instance: --lua
function myFunctionName(args)
for i=1,#args,1 do
print('Argument '..i..' is :')
print(args[i])
print('')
end
return 'Hello to you too!',42 -- return a string and a number
end
The B0-based remote API client application would then call above script function in following manner (e.g. via a Python script): import b0RemoteApi
with b0RemoteApi.RemoteApiClient('b0RemoteApi_pythonClient','b0RemoteApi') as client:
args=['Hello World!',[1,2,3],59]
ret=client.simxCallScriptFunction('myFunctionName@objectPath','sim.scripttype_childscript',args,client.simxServiceCall())
print(ret)
Make sure that the script, where you are trying to call a function, is initialized: trying to call a function in a simulation script, while simulation is not running will not work. Extending the B0-based remote API: there are 4 simple steps involved: |