How to call functions in a script
Posted: 02 May 2025, 08:47
Hello, I recently encountered an issue. I added an RG2 gripper to a UR5 robotic arm and created a new Lua script file under this gripper. I tried using the function sim.callScriptFunction('rg2Close@UR5/RG2', sim.sim_scripttype_childscript, {}, {}, {}, '', sim.simx_opmode_blocking) in the console to call a function within this script, but it reported the following error:
"in sim.callScriptFunction: one of the function's argument type is not correct."
After fixing the error, it then reported:
"sim.callScriptFunction: script does not exist."
Another question: Could this be due to incorrect input parameters? I thought I might need to pass the script handle into the function. However, when I tried to retrieve the script handle using scriptHandle = sim.getObjectScript(objectHandle) in the console, it gave me the error:
[string "local scriptHandle = sim.getObjectScript(obje..."]:1: attempt to call a nil value (field 'getObjectScript')
This problem has been bothering me for a while. I would greatly appreciate your help when you have time. Thank you very much!
"in sim.callScriptFunction: one of the function's argument type is not correct."
After fixing the error, it then reported:
"sim.callScriptFunction: script does not exist."
Another question: Could this be due to incorrect input parameters? I thought I might need to pass the script handle into the function. However, when I tried to retrieve the script handle using scriptHandle = sim.getObjectScript(objectHandle) in the console, it gave me the error:
[string "local scriptHandle = sim.getObjectScript(obje..."]:1: attempt to call a nil value (field 'getObjectScript')
This problem has been bothering me for a while. I would greatly appreciate your help when you have time. Thank you very much!