Page 1 of 1

Issue with Python client during initialization

Posted: 23 Dec 2024, 17:22
by gregor_ws
Hi. I'm currently trying to get the python client working with the latest coppeliasim. I can successfully run the coppeliasim.py example from here https://github.com/CoppeliaRobotics/cop ... eliaSim.py . However, I'm running into an issue with the various.py example from here https://github.com/CoppeliaRobotics/cop ... various.py . I get the following error:

Code: Select all

[CoppeliaSim:error]   External call to simCallScriptFunction failed ('sim.getApiInfo@lua'): script does not exist.
Traceback (most recent call last):
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_8_0_rev0_Ubuntu24_04/various.py", line 44, in simThreadFunc
    coppeliasim.bridge.load()
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_8_0_rev0_Ubuntu24_04/coppeliasim/bridge.py", line 22, in load
    call('require', ('scriptClientBridge',))
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_8_0_rev0_Ubuntu24_04/coppeliasim/bridge.py", line 44, in call
    typeHints = getTypeHints(func)
                ^^^^^^^^^^^^^^^^^^
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_8_0_rev0_Ubuntu24_04/coppeliasim/bridge.py", line 28, in getTypeHints
    c = call('sim.getApiInfo', [-1, func], (('int', 'string'), ('string')))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_8_0_rev0_Ubuntu24_04/coppeliasim/bridge.py", line 62, in call
    raise Exception(f'{what} returned -1')
Exception: simCallScriptFunctionEx returned -1
I'm running into a similar issue when using the updated version of PyRep from here https://github.com/stepjam/PyRep/tree/4.6.0.beta . I run into a similar issue when the bridge tries loading. I'm working on getting the latest version of pyrep to work with the latest version of coppeliasim, I would appreciate any help you could give me.

Thanks in advance.
Wilbert.

Re: Issue with Python client during initialization

Posted: 06 Jan 2025, 17:28
by coppelia
Please excuse the late reply.

That file/scene wasn't updated for CoppeliaSim V4.8
You can adjust 2-3 things to adapt for that:

in lib.py, add:

Code: Select all

coppeliaSimLib.simGetScriptHandleEx.argtypes = [c_int, c_int, c_char_p]
coppeliaSimLib.simGetScriptHandleEx.restype = c_int
In bridge.py import simGetScriptHandleEx from coppeliasim.ib and around line 53 - 55 of that same file:

Code: Select all

    s = simGetScriptHandleEx(sim_scripttype_sandbox, -1, None);
    f = ctypes.c_char_p(f'{func}@lua'.encode('ascii'))
    r = simCallScriptFunctionEx(s, f, stackHandle)
Then remove the associated script in various.ttt, and attach following script to the joint:

Code: Select all

sim = require'sim'

function sysCall_init()
    h = sim.getObject('..')
    motionEnabled = true
end

function sysCall_actuation()
    if motionEnabled then
        local t = sim.getSimulationTime()
        sim.setJointPosition(h, 90 * math.pi * math.sin(0.25 * t) / 180)
    end
end

function stopJointMotion()
    motionEnabled = false
end
Then you'll have to adapt a few items in various.py too, e.g. around line 73:

Code: Select all

        cameraJointScript = sim.getObject('/cameraJoint/script')
        funcs = sim.getScriptFunctions(cameraJointScript)
And a few similar situations probably. We are trying to release V4.9 in the next few days...

Cheers

Re: Issue with Python client during initialization

Posted: 08 Jan 2025, 23:30
by gregor_ws
Thanks for the reply, it solved my issue.