Crash when using setBoolProperty with the python client

Report crashes, strange behaviour, or apparent bugs
Post Reply
gregor_ws
Posts: 11
Joined: 21 Nov 2023, 16:41

Crash when using setBoolProperty with the python client

Post by gregor_ws »

Hi,

I'm using the python client and wanted to set the realtimeSimulation property of the app without having to use the button in the editor. I can successfully run the various.py script from the client's tests. I added the following line to the script:

Code: Select all

sim.setBoolProperty(sim.handle_app, sim.boolparam_realtime_simulation, True)
The issue is that it crashes and returns the following error message:

Code: Select all

Traceback (most recent call last):
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_9_0_rev0_Ubuntu24_04/various.py", line 51, in simThreadFunc
    sim.setBoolProperty(sim.handle_app, sim.boolparam_realtime_simulation, True)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_9_0_rev0_Ubuntu24_04/coppeliasim/bridge.py", line 85, in <lambda>
    setattr(ret, k, lambda *a, func=f'{name}.{k}': call(func, a))
                                                   ~~~~^^^^^^^^^
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_9_0_rev0_Ubuntu24_04/coppeliasim/bridge.py", line 51, in call
    stack.write(stackHandle, args, typeHints[0])
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_9_0_rev0_Ubuntu24_04/coppeliasim/stack.py", line 311, in write
    write_value(stackHandle, value, typeHints[i])
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_9_0_rev0_Ubuntu24_04/coppeliasim/stack.py", line 284, in write_value
    return write_string(stackHandle, value, encoding='utf-8')
  File "/home/gregor/workspace/tools/CoppeliaSim_Edu_V4_9_0_rev0_Ubuntu24_04/coppeliasim/stack.py", line 243, in write_string
    value = value.encode(encoding)
            ^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'encode'
I tracked down the issue and it seems that the type hints being returned by the getTypeHints are not the correct ones, namely the type deduced is string, but it should be bool or int, as the value is actually an int. Is there a way to fix this issue with the client code?. Also, could you share the link where all the properties are defined? I'm using this link https://manual.coppeliarobotics.com/en/ ... erence.htm , but would like to know the name of the properties constants defined for the sim object.

Thanks in advance

gregor_ws
Posts: 11
Joined: 21 Nov 2023, 16:41

Re: Crash when using setBoolProperty with the python client

Post by gregor_ws »

Oh I think I was using the setBoolProperty method in the wrong way. I'm using this now:

Code: Select all

sim.setBoolProperty(sim.handle_scene, 'realtimeSimulation', True)
This does work as expected. Sorry for the inconvenience.

Post Reply