sim.importShape() sometimes crashes when using more than 1 remote API (legacy) server
Posted: 26 Jun 2019, 16:36
I am using one remote API client and 2 remote API servers, where I sometimes call sim.importShape() via custom remote API call. I don't call them at the same time for different servers. After a few times (order of 5-15), the call fails and I get this error message below in the console.
This issue might be related to using several remote API servers, because I don't have the problem if I only use one server. I can make thousands of calls without any problem. I am using V-REP 3.5.0 (I had issues with later versions too, I think with importShape() doesn't work at all. That is why I still use 3.5.0. I can try if I have the same issue with V-REP 3.6.1 rev3).
Here is the code of the custom remote API call:
It seems to fail in this line (this is line 132 mentioned in the error message):
When successul it prints this to ther V-REP console, see print statements:
However, when it fails, then it only print "importShape call" to the terminal, nothing to the V-REP console (only the error message). A workaround, where I try again to call doesn't work. I keep getting the error message.
Some advice about debugging would be helpful (e.g. how to debug the cause of the plugin error). Thanks
This issue might be related to using several remote API servers, because I don't have the problem if I only use one server. I can make thousands of calls without any problem. I am using V-REP 3.5.0 (I had issues with later versions too, I think with importShape() doesn't work at all. That is why I still use 3.5.0. I can try if I have the same issue with V-REP 3.6.1 rev3).
Code: Select all
Lua runtime error: [string "CHILD SCRIPT remoteApiCommandServer"]:132: Operation failed. (sim.importShape)
stack traceback:
[C]: in function 'importShape'
[string "CHILD SCRIPT remoteApiCommandServer"]:132: in function <[string "CHILD SCRIPT remoteApiCommandServer"]:113>
Error: [string -unknown location]:?: Call failed. (simCallScriptFunctionEx on importShape@remoteApiCommandServer)
Here is the code of the custom remote API call:
Code: Select all
importShape = function(inInts, inFloats, inStrings, inBuffer)
print("importShape call")
use_dummy_as_handle = inInts[1]
position = {inFloats[1], inFloats[2], inFloats[3]}
orientation = {inFloats[4], inFloats[5], inFloats[6]}
color = {inFloats[7], inFloats[8], inFloats[9]}
scale = inFloats[10]
name = inStrings[1]
mesh_file = inStrings[2]
frame_ref = inStrings[3] -- used as reference frame for position and orientation
collection = inStrings[4]
parent = inStrings[5]
-- import mesh
local file_format = 4 -- 4 for BINARY STL format
local options = 0 -- bit-encoded, 0=defaults
local identicalVerticeTolerance = 0.0
shapeHandle = sim.importShape(4, mesh_file, options, identicalVerticeTolerance, scale)
print("shapeHandle", shapeHandle)
print("name", name)
sim.setObjectName(shapeHandle, name)
if use_dummy_as_handle == 1 then -- add a dummy as parent to serve as the local reference frame (handle)
dummyHandle = sim.createDummy(0.01)
sim.setObjectName(dummyHandle, name .. '_handle') -- the handle has suffix "_handle"
sim.setObjectParent(shapeHandle, dummyHandle, true)
objectHandle = dummyHandle
else
objectHandle = shapeHandle -- objectHandle is the handle to use to modify the position/orientation of the object.
-- Or used to set parents or to add to collections.
end
print("objectHandle", objectHandle)
print("objectHandle name", name .. '_handle')
-- add parent (optional)
if parent ~= '' then
parentHandle = sim.getObjectHandle(parent)
sim.setObjectParent(objectHandle, parentHandle, true)
end
-- Set position and orientation
if frame_ref ~= '' then
refHandle = sim.getObjectHandle(frame_ref)
else
refHandle = '-1' -- use the world as reference
end
sim.setObjectPosition(objectHandle, refHandle, position)
sim.setObjectOrientation(objectHandle, refHandle, orientation)
--print(sim.getObjectOrientation(objectHandle,refHandle))
-- add to collection (optional)
if collection ~= '' then
collectionHandle = sim.getCollectionHandle(collection)
sim.addObjectToCollection(collectionHandle, objectHandle, sim.handle_single, 0)
if use_dummy_as_handle == 1 then -- also add the shape to collection
sim.addObjectToCollection(collection_handle, shapeHandle, sim.handle_single, 0)
end
end
sim.setShapeColor(shapeHandle, nil, sim.colorcomponent_ambient_diffuse, color)
sim.setObjectInt32Parameter(shapeHandle, sim.shapeintparam_static, 1)
sim.setObjectInt32Parameter(shapeHandle, sim.shapeintparam_respondable, 1)
sim.setObjectInt32Parameter(shapeHandle, sim.shapefloatparam_mass, 0.00001) -- make the object very light
sim.setObjectSpecialProperty(shapeHandle, sim.objectspecialproperty_renderable+sim.objectspecialproperty_collidable+sim.objectspecialproperty_measurable)
sim.resetDynamicObject(shapeHandle)
return {shapeHandle,objectHandle}, {}, {}, ''
end
Code: Select all
shapeHandle = sim.importShape(4, mesh_file, options, identicalVerticeTolerance, scale)
Code: Select all
importShape call
shapeHandle,150
name,plane_0
objectHandle,151
Some advice about debugging would be helpful (e.g. how to debug the cause of the plugin error). Thanks