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
viewtopic.php?f=5&t=5475
Thanks in advance.