Esempio n. 1
0
    def __init__(self):
        self._low_degrees_bound = 0
        self._low_radians_bound = 0
        self._high_degrees_bound = 180
        self._high_radians_bound = np.pi
        # Get client id from the V-REP server-side
        vrep.simxFinish(-1)
        self.conn_handler = vrep.simxStart('127.0.0.1', 19999, True, True,
                                           5000, 5)
        if self.conn_handler == -1:
            print('Failed connecting to the remote API server')
            return -1
        print('Succesfully connected to the remote API server...')

        # Get UARM entity
        # Implemented it in the dict style for future purposes
        # (if there're several robots in the env, call them like
        # env.robot['uarm'], env.robot['universal_robotics'], etc)
        uarm = UARM(self.conn_handler)
        self.robot = {'uarm': uarm}

        # Get cameras from V-REP
        # vs_0 - global view,
        # vs_1 - details basket,
        # vs_2 - destination basket,
        self.camera_handlers = []
        for i in range(3):
            err, handler = vrep.simxGetObjectHandle(
                self.conn_handler, 'vs_' + str(i),
                vrep.simx_opmode_oneshot_wait)
            if err == vrep.simx_return_ok:
                self.camera_handlers.append(handler)
            else:
                print('Error getting camera handlers, ERR:', err)
                return
Esempio n. 2
0
def connectVrep():
    global CLIENT_ID
    CLIENT_ID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
    if CLIENT_ID != -1:
        print "Connected to V-Rep Server"
    else:
        print "Connection Failed"
        sys.exit()
Esempio n. 3
0
def connect_to_vrep():
    vrep.simxFinish(-1) # just in case, close all opened connections
    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP
    if clientID == -1:
        print('Failed connecting to V-REP remote API server.')
        exit()
    else:
        vrep.simxSynchronous(clientID, True)
    return clientID
Esempio n. 4
0
def connect_to_vrep(port=19997):
    clientID = vrep.simxStart('127.0.0.1', port, True, True, 5000,
                              5)  # Connect to V-REP
    if clientID == -1:
        print('Failed connecting to V-REP remote API server.')
        exit()
    else:
        vrep.simxSynchronous(clientID, True)
    return clientID
Esempio n. 5
0
def connectVrep():
    global CLIENT_ID
    CLIENT_ID= vrep.simxStart('127.0.0.1',19999,True,True,5000,5)
    if CLIENT_ID!=-1:
        print "Connected to V-Rep Server"
        res,objs = vrep.simxGetObjects(CLIENT_ID,vrep.sim_handle_all,vrep.simx_opmode_oneshot_wait)
        if res == vrep.simx_return_ok:
            print "No. of Objects = ",len(objs)
    else:
        print "Connection Failed"
        sys.exit()
    def _start_communication(self,
                             ip,
                             port,
                             wait_until_start_communicationed=True,
                             do_not_reconnect_once_disconnected=False,
                             time_out_in_ms=15000,
                             comm_thread_cycle_in_ms=5):
        """Requests a communication pipe with the simulator."""

        clientID = vrep.simxStart(ip, port, wait_until_start_communicationed,
                                  do_not_reconnect_once_disconnected,
                                  time_out_in_ms, comm_thread_cycle_in_ms)
        return clientID if clientID != -1 else None
Esempio n. 7
0
    def start_sim(self):
        """
            Function to start the simulation. The scene must be running before running this code.
            Returns:
                clientID: This ID is used to start the objects on the scene.
        """
        vrep.simxFinish(-1)
        clientID = vrep.simxStart(self.SERVER_IP, self.SERVER_PORT, True, True, 2000, 5)
        if clientID != -1:
            print("Connected to remoteApi server.")
        else:
            vrep.simxFinish(clientID)
            sys.exit("\033[91m ERROR: Unable to connect to remoteApi server. Consider running scene before executing script.")

        return clientID
Esempio n. 8
0
    def __init__(self):
        self.jointNames = {
            1: 'j_shoulder_r',
            2: 'j_shoulder_l',
            3: 'j_high_arm_r',
            4: 'j_high_arm_l',
            5: 'j_low_arm_r',
            6: 'j_low_arm_l',
            7: 'j_pelvis_r',
            8: 'j_pelvis_l',
            9: 'j_thigh1_r',
            10: 'j_thigh1_l',
            11: 'j_thigh2_r',
            12: 'j_thigh2_l',
            13: 'j_tibia_r',
            14: 'j_tibia_l',
            15: 'j_ankle1_r',
            16: 'j_ankle1_l',
            17: 'j_ankle2_r',
            18: 'j_ankle2_l',
            19: 'j_pan',
            20: 'j_tilt'
        }

        self.objectnames = [
            'MP_BODY_respondable', 'MP_NECK_respondable', 'MP_HEAD_respondable'
        ]
        self.MOTOR_HANDLES = {}
        self.OBJECT_HANDLES = []
        self.CLIENT_ID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000,
                                        5)
        #vrep.simxPauseSimulation(self.CLIENT_ID,True)

        if CLIENT_ID != -1:
            print "Connected to V-Rep Server"
            self.get_handles()
        else:
            print "Connection Failed"
            sys.exit()