示例#1
0
def run():
    # 연결할 server의 host와 연결 port설정
    HOST = '141.223.140.22'
    PORT = 8001

    # socket create for camera
    server_socket = server_connect.Connect(HOST, PORT)
    time.sleep(1)

    # create raspberrypi object
    serial = rasp_serial.Serial()
    print("serial")

    # if connected to server..start thread and send camera frame
    camera = Camera.Camera(server_socket.Get_Socket())
    camera_thread = threading.Thread(target=camera.run, args=())  # target은 thread를 사용할 함수
    camera_thread.start()
    print("camera")

    print('start')

    while True:
        # server로부터 데이터를 받아옴
        data = server_socket.Get_Data()

        print("data:", data)
        if data == 'q':
            break
        serial.steer(data)  # 받아온 데이터 신호에 따라 steering
示例#2
0
文件: main.py 项目: ashcattle/Auto-RC
def run():
    HOST = '141.223.140.22'
    PORT = 8002

    #socket create for camera
    server_socket = server_connect.Connect(HOST, PORT)
    time.sleep(1)

    #socket create for ultrasonic sensor
    #    us_socket = server_connect.Connect(HOST, PORT+1)
    #    time.sleep(1)

    #socket create for mic
    #    mic_socket = server_connect.Connect(HOST, PORT+2)

    #create raspberrypi object
    serial = rasp_serial.Serial()
    print("serial")
    #if connected to server..start thread and send camera frame
    camera = Camera.Camera(server_socket.Get_Socket())
    camera_thread = threading.Thread(target=camera.run, args=())
    camera_thread.start()
    print("camera")
    #   us = ultrasonic.UltraSonic()
    #    us_thread = threading.Thread(target=us.run, args=(us_socket,))
    #    us_thread.start()

    #   microphone = mic.MicrophoneStream()
    #    microphone_thread = threading.Thread(target=microphone.run, args=(mic_socket,))
    #    microphone_thread.start()

    print('start')

    while True:
        print(1)
        data = server_socket.Get_Data()
        print(2)

        print("data:", data)
        if data == 'q':
            break
        serial.steer(data)
示例#3
0
def run():
    HOST = '192.168.0.23'
    PORT = 1971
    
    # socket create for camera
    main_socket = server_connect.Connect(HOST, PORT)
    time.sleep(1)

    # socket create for ultrasonic sensor
    us_socket = server_connect.Connect(HOST, PORT+1)
    time.sleep(1)

    # socket create for mic
    mic_socket = server_connect.Connect(HOST, PORT+2)
    
    # socket create for manual steer
    # manual_socket = server_connect.Connect(HOST, PORT+3)

    # create raspberrypi object
    serial = rasp_serial.Serial()

    # if connected to server..start thread and send camera frame
    camera = Camera.Camera(main_socket.Get_Socket())
    camera_thread = threading.Thread(target=camera.run, args=())
    camera_thread.start()

    us = ultrasonic.UltraSonic()
    us_thread = threading.Thread(target=us.run, args=(us_socket,))
    us_thread.start()

    microphone = mic.MicrophoneStream()    
    microphone_thread = threading.Thread(target=microphone.run, args=(mic_socket,))
    microphone_thread.start()

    print('start')

    while True:
        data = main_socket.Get_Data()
        if data == 'q':
            break
        serial.steer(data)