simExtSDF_import changes to simSDF.import when reloading the scene

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

simExtSDF_import changes to simSDF.import when reloading the scene

Post by jak_a »

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
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: simExtSDF_import changes to simSDF.import when reloading the scene

Post by coppelia »

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

Re: simExtSDF_import changes to simSDF.import when reloading the scene

Post by jak_a »

Thanks a lot for the explanation and the provided workaround. By creating an add-on script, I was able to use the legacy simExtSDF_import and import my models.

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: simExtSDF_import changes to simSDF.import when reloading the scene

Post by coppelia »

Another way would be to simply remove the lua/simExtSDF.lua file, since it is empty. Then the new namespace simSDF.* should work.

Cheers

Post Reply