CoppeliaRobotics / simOMPL

OMPL (Open Motion Planning Library) plugin for CoppeliaSim
Other
16 stars 4 forks source link

"This method can only be used inside callbacks." when calling simExtOMPL_isStateValid #2

Closed fferri closed 7 years ago

fferri commented 7 years ago

From @SiyuanQi on August 19, 2017 2:23

Hi, I tried to run the API function simExtOMPL_isStateValid(number taskHandle, table state) from the embedded scripts and met some problems.

My final goal is to load a model during simulation, and set a valid goal state for that model. I use a associated child script for that model, and defined a function setTarget that calls simExtOMPL_isStateValid when executed. Task handle and state space are created in the initialization part.

Here are several scenarios:

Here is the error message shown in V-REP:

Lua runtime error: [string "SCRIPT Bill"]:35: This method can only be used inside callbacks. (simExtOMPL_isStateValid @ 'OMPL' plugin)
stack traceback:
    [C]: in function 'simExtOMPL_isStateValid'
    [string "SCRIPT Bill"]:35: in function <[string "SCRIPT Bill"]:23>
Lua runtime error: [string -unknown location]:?: Failed calling script function. (simCallScriptFunction)
stack traceback:
    [C]: in function 'simCallScriptFunction'
    [string "SCRIPT engine"]:88: in main chunk

What would possibly be the reason for this? Thank you!

_Copied from original issue: fferri/vrepExtOMPL#2

fferri commented 7 years ago

From @aidyk on September 8, 2017 5:52

Hi, could you provide me a minimal sample code to reproduce it? I'm not a repository owner, but I'd like to investigate the issue.

fferri commented 7 years ago

From @SiyuanQi on September 8, 2017 17:33

Hi, I eventually solved the problem by adjusting the execution priority of the dummy object script to "last". So I guess it has something to do with the workflow inside vrep, e.g. when the initialization of an object is called if it is created during simulation.

fferri commented 7 years ago

From @aidyk on September 9, 2017 2:14

It's good anyway, and thank you for sharing your experience!