def get_vison_sensor_handle(client_ID, vision_tag): return_code, handle = vrep.simxGetObjectHandle(client_ID, vision_tag, vrep.simx_opmode_oneshot_wait) if check_return_code(return_code, "get_object_handle"): return handle sys.exit()
def get_object_handle(client_ID, component_tag): return_code, handle = vrep.simxGetObjectHandle(client_ID, component_tag, vrep.simx_opmode_blocking) if check_return_code(return_code, "get_object_handle"): return handle sys.exit()
def get_orientation(client_ID, handle): return_code, orientation = vrep.simxGetObjectOrientation(client_ID, handle, -1, simx_opmode_blocking) if check_return_code(return_code, "get_orientation"): return orientation sys.exit()
def retrive_img_from_vision_senzor(vision_sensor_name, client_ID): return_code, vision_sensor_handle = vrep.simxGetObjectHandle( client_ID, vision_sensor_name, vrep.simx_opmode_oneshot_wait) if not check_return_code(return_code, "get_object_handle"): sys.exit() return_code, resolution, sensor_img = vrep.simxGetVisionSensorImage( client_ID, vision_sensor_handle, 0, vrep.simx_opmode_streaming) time.sleep(1) #mandatory sleep, WON'T WORK without it return_code, resolution, sensor_img = vrep.simxGetVisionSensorImage( client_ID, vision_sensor_handle, 0, vrep.simx_opmode_buffer) image_byte_array = array.array('b', sensor_img) img = pil_image.frombuffer("RGB", (resolution[0], resolution[1]), image_byte_array, "raw", "RGB", 0, 1) return img
def stop_simulation(client_ID): return_code = vrep.simxStopSimulation(client_ID, simx_opmode_blocking) if not check_return_code(return_code, "simxStartSimulation"): sys.exit()