python remote api broken simxReadForceSensor

Report crashes, strange behaviour, or apparent bugs
Post Reply
markfink
Posts: 2
Joined: 14 May 2016, 07:29

python remote api broken simxReadForceSensor

Post by markfink » 15 May 2016, 16:07

I am using: V-REP version 3.03.00 (rev 1) (V-REP PRO EDU license)
on Ubuntu 16.04

I am trying to read from an accelerometer sensor. Obviously this is broken for my platform:

Connected to remote API server
Traceback (most recent call last):
File "bubbleRob_cont.py", line 107, in <module>
print read_forcesensor(accel)
File "bubbleRob_cont.py", line 64, in read_forcesensor
_, force, torque = vrep.simxReadForceSensor(handle[0], handle[1], vrep.simx_opmode_blocking)
File "/home/mark/PROJECTS/COPTER/simulator/workspace/vrep.py", line 246, in simxReadForceSensor
state=ord(state.value)
TypeError: ord() expected string of length 1, but int found

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

Re: python remote api broken simxReadForceSensor

Post by coppelia » 16 May 2016, 06:43

Hello Mark,

we broke something in release 3.3.0. In file vrep.py, it should rather be something like:

Code: Select all

def simxReadForceSensor(clientID, forceSensorHandle, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''
    state = ct.c_ubyte()
    forceVector  = (ct.c_float*3)()
    torqueVector = (ct.c_float*3)()
    ret = c_ReadForceSensor(clientID, forceSensorHandle, ct.byref(state), forceVector, torqueVector, operationMode)
    arr1 = []
    for i in range(3):
        arr1.append(forceVector[i])
    arr2 = []
    for i in range(3):
        arr2.append(torqueVector[i])
#    if sys.version_info[0] == 3:
#        state=state.value
#   else:
#        state=ord(state.value)
    return ret, state.value, arr1, arr2 
But you should also call the function in following way:

Code: Select all

returnCode, state, force, torque = vrep.simxReadForceSensor(handle[0], handle[1], vrep.simx_opmode_blocking)
Cheers

Post Reply