def state(self, degrees=True): """Returns current state of the environment. Argument: degrees(keyword) -- flag that indicates if state's elements will be in degrees or radians """ _state = [] # Get motors' positions for motor in self.robot['uarm'].motor_handlers: err, joint_position = vrep.simxGetJointPosition( self.conn_handler, motor, vrep.simx_opmode_streaming) if err == vrep.simx_return_ok or err == vrep.simx_return_novalue_flag: joint_position *= 180.0 / np.pi if degrees else 1 _state.append(round(joint_position, 4)) else: print('Error getting joint positions, ERR:', err) return -1 # Get gripper state err, gripper_state = vrep.simxGetIntegerSignal( self.conn_handler, self.robot['uarm'].gripper_handler, vrep.simx_opmode_streaming) if err == vrep.simx_return_ok or err == vrep.simx_return_novalue_flag: _state.append(gripper_state) else: print('Error getting gripper state, ERR:', err) _state.append(-1) return _state
def get_joint_position_oneshot(clientID, handle): mode = vrep.simx_opmode_oneshot valid_response = False while not valid_response: response, position = vrep.simxGetJointPosition(clientID, handle, mode) assert response == 0, "Cannot get joint position" return position
def getPos(self): angles = {} for i in self.MOTOR_HANDLES.keys(): _, angle = vrep.simxGetJointPosition(self.CLIENT_ID, self.MOTOR_HANDLES[i], vrep.simx_opmode_oneshot_wait) angles[i] = math.degrees(angle) return angles
def getPos(): angles = [] for i in MOTOR_HANDLES.keys(): _, angle = vrep.simxGetJointPosition(CLIENT_ID, MOTOR_HANDLES[i], vrep.simx_opmode_oneshot_wait) angles.append(math.degrees(angle)) print angles return Motion(1, " ".join(map(str, angles)), 0)
def get_joint_position(clientID, handle): is_request_initial = handle not in STREAMING_HANDLES_JOINT_POSITION mode = vrep.simx_opmode_streaming if is_request_initial else vrep.simx_opmode_buffer valid_response = False while not valid_response: response, position = vrep.simxGetJointPosition(clientID, handle, mode) valid_response = response == 0 if is_request_initial: STREAMING_HANDLES_JOINT_POSITION.add(handle) return position
def getPos(): angles = [] for i in MOTOR_HANDLES.keys(): _,angle = vrep.simxGetJointPosition(CLIENT_ID,MOTOR_HANDLES[i],vrep.simx_opmode_oneshot_wait) angles.append(math.degrees(angle)) return angles