def main():
    encoder.RF_flag = 0
    #encoder.encoder_print_flag = 0
    encoder.start_encoder()
    #motor.test_motor()
    #speed_con()
    speedcontrol_test()
def speed_con():
    try:
        encoder.start_encoder()

        ##使用线程
        thread_test_motor = threading.Thread(target=motor.test_motor, args=())
        thread_keep_speed = threading.Thread(target=keep_speed, args=())
        thread_standstill = threading.Thread(target=standstill, args=())

        #启动进程
        encoder.process_cout_thread.start()

        #启动线程
        #encoder.thread_cout_thread.start()
        thread_test_motor.start()
        motor.MODE = 4
        #thread_keep_speed.start()
        thread_standstill.start()
        encoder.timer.start()

    except KeyboardInterrupt:
        motor.PWM = 0
        motor.DIR = 0
Ejemplo n.º 3
0
camera.framerate = FPS
camera.brightness = BRIGHTNESS
camera.shutter_speed = 800
camera.exposure_compensation = 25
camera.ISO = 1300
camera.exposure_mode = 'sports'

##camera.awb_mode = 'fluorescent'

stream = io.BytesIO()
##camera.close()

#*********initial motor and encoder*************
motor.init_motor(500)
motor.stop()
encoder.start_encoder()

motor.car_run_flag = 1
try:
    fp = 0
    #motor.set_car_run(1,0,150)
    #time.sleep(5)
    s = time.time()
    for foo in camera.capture_continuous(stream, 'jpeg', use_video_port=True):
        ##        s = time.time()
        data = np.fromstring(stream.getvalue(), dtype=np.uint8)
        c_img = cv2.imdecode(data, cv2.CV_LOAD_IMAGE_UNCHANGED)
        ##        cv2.imwrite('/home/pi/final/final_test/capture'+str(fp)+'.jpg',c_img)

        fp += 1
        ##        cv2.imshow('c_img',c_img)