コード例 #1
0
ファイル: train.py プロジェクト: spider-tronix/Adaptive-Bot
def conect_and_load(port, ip):
    sim.simxFinish(-1) # just in case, close all opened connections
    clientID = sim.simxStart(ip,port,True,True,5000,5) # Connect to CoppeliaSim
    scene_path = os.path.join('vrep_scene', 'hexapod_scene.ttt')
    print('-'*5, 'Scene path:', scene_path, '-'*5)
    sim.simxLoadScene(clientID, scene_path, 0xFF, sim.simx_opmode_blocking)
    return clientID
コード例 #2
0
def conect_and_load(port, ip):
    clientID = sim.simxStart(ip, port, True, True, 5000,
                             5)  # Connect to CoppeliaSim
    scene_path = os.path.join('vrep-scene', 'poppy_two_target_pos_z.ttt')
    print('-' * 5, 'Scene path:', scene_path, '-' * 5)
    sim.simxLoadScene(clientID, scene_path, 0xFF, sim.simx_opmode_blocking)
    return clientID
コード例 #3
0
ファイル: main_flask.py プロジェクト: mdecourse/airhockey
def startvrep():
    global clientID2
    sim.simxFinish(-1)  # just in case, close all opened connections
    clientID = sim.simxStart(flask_ip, vrep_port, True, True, 5000,
                             5)  # Get the client ID
    clientID2 = sim.simxStart(flask_ip, vrep_port2, True, True, 5000, 5)
    res = sim.simxLoadScene(clientID, scene_path, 0, sim.simx_opmode_blocking)
    x = sim.simxStartSimulation(clientID, sim.simx_opmode_oneshot_wait)

    if clientID != -1 or clientID2 != -1:  #check if client connection successful
        print('Connected to remote API server')
    else:
        print('Connection not successful')
        sys.exit('Could not connect')

    # Initialize car control object
    AirHockey = air_Hockey(clientID)

    #for i in range(150):
    while True:
        # Start time for image process
        err, img = AirHockey.get_image()
        ret, jpeg = cv2.imencode('.jpg', img)
        #jpeg.tobytes()
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + jpeg.tobytes() + b'\r\n')
    return "startvrep"
コード例 #4
0
 def load_scene(self, scene_path_and_filename):
     """
     remotely load the scene in client from file located at evo_master
     """
     ret = sim.simxLoadScene(self.clientID, scene_path_and_filename, 1,
                             mode2)
     return ret
コード例 #5
0
 def inputxmlfile(self):
     #number returnCode=simxLoadScene(number clientID,string scenePathAndName,number options,number operationMode)
     sim.simxLoadScene(
         self.clientID,
         "I:\fall2020_v2\data\home\Desktop\40723103\Coppeliasim model.ttt",
         0xFF, sim.simx_opmode_blocking)
     '''
     # relative to remote API client location, relative path:
     sim.simxLoadScene(clientID,'test/testScene.ttt',0xFF,vrep.simx_opmode_blocking)
     # relative to V-REP executable location, relative path:
     sim.simxLoadScene(clientID,'scenes/collisionDetectionDemo.ttt',0x00,vrep.simx_opmode_blocking)
     # relative to remote API client location, absolute path:
     sim.simxLoadScene(clientID,'c:/python27/test/testScene.ttt',0xFF,vrep.simx_opmode_blocking)
     # relative to V-REP executable location, absolute path:
     sim.simxLoadScene(clientID,'d:/v_rep/qrelease/release/scenes/collisionDetectionDemo.ttt',0x00,vrep.simx_opmode_blocking)
     '''
     print("successful input file")
コード例 #6
0
def loadScene():
    global client

    if client is None:
        return "-1"

    scene = request.args.get('scene')

    stop()
    response = sim.simxLoadScene(client, scene, 0xFF, sim.simx_opmode_blocking)
    while response == 1:
        verboseResp(response, "simxLoadScene " + scene)
        response = sim.simxLoadScene(client, scene, 0xFF,
                                     sim.simx_opmode_blocking)
        sleep(againIn)
    verboseResp(response, "simxLoadScene " + scene)
    if not response:
        while setCameraBuffer() == "-1":
            sleep(againIn)
        return play()

    return str(response)
コード例 #7
0
ファイル: project2.2.py プロジェクト: fmjohnson97/SCR_2021
            sim.sim_scripttype_childscript,  # scriptHandleOrType
            'step',  # functionName
            [],  # ints
            [],  # floats
            [],  # strings
            emptyBuff,  # buffer
            sim.simx_opmode_blocking,
        )

    ### Simulation  ###

    #set global variables
    HUMAN_FOLLOW_DIST=.3

    # load the scene
    res = sim.simxLoadScene(clientID, 'fivedoors.ttt', True, sim.simx_opmode_blocking)
    res = sim.simxStartSimulation(clientID, sim.simx_opmode_oneshot)

    # get handles
    robotHandle = getHandleFromName('lumibot')
    left_motor_handle = getHandleFromName('lumibot_leftMotor')
    right_motor_handle = getHandleFromName('lumibot_rightMotor')
    doors=[getHandleFromName('_doorJoint')]
    pathCtrlPoints = []
    for i in range(1,5):
        doors.append(getHandleFromName('_doorJoint#'+str(i)))
        pathCtrlPoints.append(getHandleFromName('CtrlPt'+str(i)))
    pathCtrlPoints.append(getHandleFromName('CtrlPt5'))
    humanHandle = getHandleFromName('Bill_base')

    doorInd=0
コード例 #8
0
ファイル: final.py プロジェクト: fmjohnson97/SCR_2021
            return None
        # get the obstacles to avoid
        restrictions = input('Ok. What would you like to avoid?')
        if response in ENDINGS:
            # if the human changes their mind then just plan the path
            print('Ok. Planning your path now.')
            return None
        # list obstacles that the user wants to avoid
        print('Great. Planning a path now that avoids', restrictions)
        restrictions = restrictions.split(',')
        return restrictions

    ### Simulation  ###

    # load the scene
    res = sim.simxLoadScene(clientID, 'maze2.ttt', True,
                            sim.simx_opmode_blocking)
    res = sim.simxStartSimulation(clientID, sim.simx_opmode_oneshot)

    # get handles
    robotHandle = getHandleFromName('lumibot')
    billHandle = getHandleFromName('Bill')
    dummy_list = {
        'plant': getHandleFromName('Plant'),
        'motorcycle': getHandleFromName('MotorCycle'),
        'r2d2': getHandleFromName('R2D2'),
        'bathroom': getHandleFromName('Bathroom'),
        'blue chair': getHandleFromName('Blue_Chair'),
        'yellow chair': getHandleFromName('Yellow_Chair'),
        'table': getHandleFromName('Table')
    }
    left_motor_handle = getHandleFromName('lumibot_leftMotor')
コード例 #9
0
 def inputxmlfile(self):
     #number returnCode=simxLoadScene(number clientID,string scenePathAndName,number options,number operationMode)
     file_input = sim.simxLoadScene(self.clientID,
                                    "Y:\home\Desktop\0126.ttt", 0x00,
                                    sim.simx_opmode_blocking)
     print("successful input file")