Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import vrep
  4.  
  5. vrep.simxFinish(-1) # just in case, close all opened connections
  6. clientID=vrep.simxStart('127.0.0.1',19997,True,True,5000,5) # Connect to V-REP
  7.  
  8. if clientID!=-1:
  9.  
  10.     print ('Connected to remote API server')
  11.  
  12.     returnCode, handle = vrep.simxGetObjectHandle(clientID, 'turtlebot2i', vrep.simx_opmode_streaming)
  13.     returnCode, obj_pose = vrep.simxGetObjectPosition(clientID, handle, -1, vrep.simx_opmode_streaming)
  14.  
  15.     while(True):
  16.  
  17.         returnCode, handle = vrep.simxGetObjectHandle(clientID,'turtlebot2i',vrep.simx_opmode_buffer)
  18.         returnCode, obj_pose = vrep.simxGetObjectPosition(clientID, handle, -1, vrep.simx_opmode_buffer)
  19.        
  20.         if (returnCode == vrep.simx_return_ok):
  21.            print('ok', obj_pose)
  22.            quit()
  23.         else:
  24.            print('nok')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement