예제 #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)
예제 #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)
예제 #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)
예제 #4
0
    def execute_motion(self, vel_sets):
        #vrep.simxPauseSimulation(self.CLIENT_ID,0)
        vrep.simxSynchronous(self.CLIENT_ID, True)
        vrep.simxStartSimulation(self.CLIENT_ID, vrep.simx_opmode_oneshot)
        for dur, vels in vel_sets:
            vrep.simxPauseCommunication(self.CLIENT_ID, 1)
            for key in range(1, 19):
                vrep.simxSetJointTargetVelocity(self.CLIENT_ID,
                                                self.MOTOR_HANDLES[key],
                                                vels[key],
                                                vrep.simx_opmode_oneshot)

            vrep.simxPauseCommunication(self.CLIENT_ID, 0)
            time.sleep(dur)
            vrep.simxSynchronousTrigger(self.CLIENT_ID)

        vrep.simxPauseCommunication(self.CLIENT_ID, 1)
        for key in range(1, 19):
            vrep.simxSetJointTargetVelocity(self.CLIENT_ID,
                                            self.MOTOR_HANDLES[key], 0,
                                            vrep.simx_opmode_oneshot)
        vrep.simxPauseCommunication(self.CLIENT_ID, 0)
        vrep.simxSynchronousTrigger(self.CLIENT_ID)