Report crashes, strange behaviour, or apparent bugs
jak_a
Posts: 3
Joined: 02 Feb 2021, 16:35

Hello everyone,

I am experiencing a rather strange behavior when using a customization script (Ubuntu 20.04, 4.1.0). My overall goal is to import an SDF file programatically from python. I am using Pyrep as an API for that. In order to be able to call the import function, I have written a small customization script. The following is a minimal example:

Code: Select all

function test()
simExtSDF_import("/datasets/models/ycb/006_mustard_bottle/mustard_bottle.sdf")
end

this works perfectly well when calling the script via the LUA console with sim.callScriptFunction. However, when I save the file, close the editor and reload the scene, suddently my script changed to the following:

Code: Select all

function test()
simSDF.import("/datasets/models/ycb/006_mustard_bottle/mustard_bottle.sdf")
end

Which is in itself already a strange behavior, but even worse, the simSDF command does not work for me. I always get the following error:

Code: Select all

attempt to index global 'simSDF' (a boolean value)
Could someone explain this behavior to me? How can I get around this? Alternatively, is there maybe a better way to call the simExtSDF_import function from python, without creating this script? I could also use a different API.

Cheers and many thanks,

Jakob

coppelia
Posts: 8531
Joined: 14 Dec 2012, 00:25

Hello Jakob,

thanks for reporting this. This is what is actually happening: simExtSDF_import used to be the name of the API function that eventually got renamed to simSDF.import (i.e. plugins now group their API functions under a common namespace, e.g. simSDF). When loading a scene or model, CoppeliaSim will try to automatically update the code to use the newer notation.

But obviously, there is a problem in version V4.1.0 with the SDF plugin, and the simSDF namespace is not available. As a workaround, you can place the test function inside of the sandbox script (or inside of an add-on), and call it there: those are not parsed and updated for newer API notations.

Cheers

jak_a
Posts: 3
Joined: 02 Feb 2021, 16:35