Python Remote API: simxCallScriptFunction / ctypes Arg Error

Report crashes, strange behaviour, or apparent bugs
Post Reply
dgm
Posts: 5
Joined: 18 Jul 2016, 23:36

Python Remote API: simxCallScriptFunction / ctypes Arg Error

Post by dgm »

Hello,

I am trying to call a script function using simxCallScriptFunction.

Code: Select all

clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)  # Connect to V-REP

res, retInts, retFloats, retStrings, retBuffer = vrep.simxCallScriptFunction(clientID, "scriptHan", sim_scripttype_childscript, "moveOnPath", [], [], [], [], simx_opmode_blocking)
I am getting the error:
Traceback (most recent call last):
File "C:\Users\dmoon04\javaclipseworkspace\sonicFinal.py", line 688, in <module>
res, retInts, retFloats, retStrings, retBuffer = vrep.simxCallScriptFunction(clientID, "scriptHan", sim_scripttype_childscript, "moveOnPath", [], [], [], [], simx_opmode_blocking)
File "C:\Users\dmoon04\javaclipseworkspace\vrep.py", line 1359, in simxCallScriptFunction
inputBufferV=ct.cast(inputBufferV,ct.POINTER(ct.c_ubyte)) # IronPython needs this
File "C:\Python27\lib\ctypes\__init__.py", line 502, in cast
return _cast(obj, obj, typ)
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: wrong type


I can connect to the server side, and print clientID (which is 0). The solutions I've seen with this concerns strings where you would need to import ctypes and add b but I these solutions account for strings types. I saw this solution, https://stackoverflow.com/questions/312 ... in-python3 but I do not understand exactly what should be done.

I hope I've given enough information. All help is greatly appreciated. Thanks.

Some of the things I've tried:

Code: Select all

n = ctypes.c_ubyte(clientID)
n = c_uint(clientID)
Last edited by dgm on 19 Jul 2016, 15:19, edited 1 time in total.

dgm
Posts: 5
Joined: 18 Jul 2016, 23:36

Re: Python Remote API: simxCallScriptFunction / ctypes Arg E

Post by dgm »

So, I've tried changing clientID with:

Code: Select all

n = ctypes.c_ubyte(clientID)
n = c_uint(clientID)
but no luck.

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

Re: Python Remote API: simxCallScriptFunction / ctypes Arg E

Post by coppelia »

Hello,

so you are running on Windows with Python 2.7, do you have the last V-REP version?
Before going further into details, what happens with the demo script in programming/remoteApiBindings/python/python/complexCommandTest.py? (make sure you load the demo scene remoteApiCommandServerExample.ttt in V-REP, then start the simulation, then run the python script). That script also uses the simxCallScriptFunction API command.

Cheers

dgm
Posts: 5
Joined: 18 Jul 2016, 23:36

Re: Python Remote API: simxCallScriptFunction / ctypes Arg E

Post by dgm »

Thanks for the reply. Yes, windows 7 and python 2.7. I have the latest version but I just realized its the 32bit and the system is a 64. Not sure if that could contribute to the problem.

But the example worked! I made some changes to my function call and I received no errors!

Note to self: Examples are your friend. :)

Thanks!

Post Reply