simxReadForceSensor stop simulation

Report crashes, strange behaviour, or apparent bugs
Post Reply
realgalois
Posts: 3
Joined: 19 Aug 2016, 05:23

simxReadForceSensor stop simulation

Post by realgalois »

I used V-Rep Pro version.

Here is my code that I write:

Code: Select all

check=0
PI=math.pi  #pi=3.14

vrep.simxFinish(-1) # Close all opened connections

clientID=vrep.simxStart('127.0.0.1',19999,True,True,5000,5)

if clientID!=-1:  #check if client connection successful
    print 'Connected to remote API server'
    
else:
    print 'Connection not successful'
    sys.exit('Could not connect with Vrep')

#retrieve motor  handles
errorCode,leftMotorHandle=vrep.simxGetObjectHandle(clientID,'dr12_leftJoint_',vrep.simx_opmode_oneshot_wait)
errorCode,rightMotorHandle=vrep.simxGetObjectHandle(clientID,'dr12_rightJoint_',vrep.simx_opmode_oneshot_wait)
errorCode,bumperSensorHandle=vrep.simxGetObjectHandle(clientID,'dr12_bumperForceSensor_',vrep.simx_opmode_blocking)

result,state,f,t=vrep.simxReadForceSensor(clientID,bumperSensorHandle,vrep.simx_opmode_streaming) #result =-1 (sensor fail), t:torque, f:force
if (result>0):
    if (math.abs(f[2])>1) or (math.abs(f[3])>1):
            check =1
            print('check',check)    
if (check==1):
        vrep.simxSetJointTargetVelocity(leftMotorHandle, 0)
        vrep.simxSetJointTargetVelocity(rightMotorHandle,0)
else:
        vrep.simSetJointTargetVelocity(leftMotorHandle,10)
        vrep.simSetJointTargetVelocity(rightMotorHandle,10)
        print('without collision',leftJointHandle)


I get the TypeError: ord() expected string of length 1, but int found in line
for the following line:

Code: Select all

result,state,f,t=vrep.simxReadForceSensor(clientID,bumperSensorHandle,vrep.simx_opmode_streaming) #result =-1 (sensor fail), t:torque, f:force
How can I fix it? I have search for a similar problem here:
viewtopic.php?f=5&t=5475

Thanks in advance.

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

Re: simxReadForceSensor stop simulation

Post by coppelia »

Hello,

what V-REP version are you using? I not V-REP 3.3.1, then use V-REP 3.3.1 (V-REP and remote API client from the same version). Does the problem persist?

Cheers

Post Reply