Beispiel #1
0
 def set_revolute_joints(self, desired_pos):
     assert len(desired_pos) == 3, "Invalid number of desired pos."
     vrep.simxPauseCommunication(self.client_id, 1)
     for j in range(len(desired_pos)):
         vrep.simxSetJointTargetPosition(self.client_id,
                                         self.handles_dict["joint"][3 + j],
                                         desired_pos[j],
                                         vrep.simx_opmode_oneshot)
     # unpause simulation
     vrep.simxPauseCommunication(self.client_id, 0)
Beispiel #2
0
 def set_all_joint_positions(self, desired_pos):
     assert len(desired_pos) == len(self.handles_dict["joint"])
     # pause simulation
     vrep.simxPauseCommunication(self.client_id, 1)
     for j in range(len(desired_pos)):
         vrep.simxSetJointTargetPosition(self.client_id,
                                         self.handles_dict["joint"][j],
                                         desired_pos[j],
                                         vrep.simx_opmode_oneshot)
     # unpause simulation
     vrep.simxPauseCommunication(self.client_id, 0)
Beispiel #3
0
    def set_motors(self, position, degrees=False):
        """ Set values of the UARM\'s motors.
        
		Arguments:  
			positions - list containing angular positions for all motors: 
						positions = [joint_val_1, ..., joint_val_4] 
			degrees -- if given positions are in degress (True) or radians (False)
		"""

        # Recalculate into radians if positions are in degrees
        if degrees:
            coeff = np.pi / 180
            position = [pos * coeff for pos in position]
        vrep.simxPauseCommunication(self.conn_handler, True)
        errors = []
        for i in range(0, self.motors_number):
            code = vrep.simxSetJointTargetPosition(self.conn_handler,
                                                   self.motor_handlers[i],
                                                   position[i],
                                                   vrep.simx_opmode_oneshot)
            errors.append(code)
        vrep.simxPauseCommunication(self.conn_handler, False)
Beispiel #4
0
 def setPos(self, writ):
     for key, val in writ.items():
         vrep.simxSetJointTargetPosition(CLIENT_ID, MOTOR_HANDLES[key],
                                         math.radians(val),
                                         vrep.simx_opmode_oneshot_wait)
Beispiel #5
0
def setPos(writ):
    for key, val in writ.items():
        vrep.simxSetJointTargetPosition(CLIENT_ID, MOTOR_HANDLES[key],
                                        math.radians(val),
                                        vrep.simx_opmode_streaming)