Пример #1
0
class Controle_Remoto:
    try:
        while (True):
            clock.tick(30)
            key = pygame.key.get_pressed()
            motor.parar_movimento(controle_velocidade_direita,
                                  controle_velocidade_esquerda)

            if key[pygame.K_UP]:
                motor.movimento_frente(var.velocidade,
                                       controle_velocidade_direita,
                                       controle_velocidade_esquerda)
            if key[pygame.K_RIGHT]:
                motor.movimento_direita(var.velocidade,
                                        controle_velocidade_direita,
                                        controle_velocidade_esquerda)
            if key[pygame.K_LEFT]:
                motor.movimento_esquerda(var.velocidade,
                                         controle_velocidade_direita,
                                         controle_velocidade_esquerda)
            if key[pygame.K_DOWN]:
                motor.movimento_tras(var.velocidade,
                                     controle_velocidade_direita,
                                     controle_velocidade_esquerda)
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                elif event.type == KEYDOWN and event.key == K_ESCAPE:
                    sys.exit()
    finally:
        print("Cleaning up")
        GPIO.cleanup()
Пример #2
0
def semaforo_verde(ctr_vel_motor_dir, ctr_vel_motor_esq):
    print("Sinal verde!!!")
    if ((a3 <= var.CONST_A3) and (b3 <= var.CONST_B3)):
        SINAL_VERDE = True
        while (SINAL_VERDE is True):
            _, _, _, a3, _, _, _, b3 = sensor.fototransistores()
            print("Faixa de contenção \tA3:{:>5} B3:{:>5}".format(
                _, _, _, a3, _, _, _, b3))
            motor.parar_movimento(ctr_vel_motor_dir, ctr_vel_motor_esq)

            if (obstaculo is False):
                print("Sem obstaculo! Prosseguir...")
                gerencia.movimento_frente(var.velNormal, ctr_vel_motor_dir,
                                          ctr_vel_motor_esq)

            if ((a3 >= var.CONST_A3) and (b3 >= var.CONST_B3)):
                print("Saiu da faixa de contenção...")
                SINAL_VERDE = False
Пример #3
0
        # ------------------ Seguir em frente ou manter robô parado  --------------------
        if (MOVIMENTO_FRENTE is True):
            gerencia.movimento_frente(var.velNormal, ctr_vel_motor_dir,
                                      ctr_vel_motor_esq)
        # -------------------------------------------------------------------------------

        # ---------- Metodo para fazer correcao de extrema emergencia (DIREITA) -----------
        elif ((a3 <= var.CONST_A3) and (a0 >= var.CONST_A0)
              and (a1 >= var.CONST_A1) and (b3 >= var.CONST_B3)
              and (b0 >= var.CONST_B0) and (b1 >= var.CONST_B1)):
            A3_ATIVADO = True
            print("ALERTA MAXIMO!!! O robo esta saindo da faixa Direita... ")
            while (A3_ATIVADO is True):
                a0, a1, _, a3, _, _, _, _ = sensor.fototransistores()
                motor.movimento_tras(var.velEmergencia, ctr_vel_motor_dir,
                                     ctr_vel_motor_esq)
                if ((a3 >= var.CONST_A3) and (a1 <= var.CONST_A1)):
                    print("Correcao estabelecida!")
                    A3_ATIVADO = False
        # -------------------------------------------------------------------------------

        # ---------- Metodo para fazer correcao de extrema emergencia (ESQUERDA) -----------
        elif ((b3 <= var.CONST_B3) and (b0 >= var.CONST_B0)
              and (b1 >= var.CONST_B1) and (a0 >= var.CONST_A0)
              and (a1 >= var.CONST_A1) and (a3 >= var.CONST_A3)):
            B3_ATIVADO = True
            print("ALERTA MAXIMO!!! O robo esta saindo da faixa Esquerda... ")
            while (B3_ATIVADO is True):
                _, _, _, _, b0, b1, _, b3 = sensor.fototransistores()
                motor.movimento_tras(var.velEmergencia, ctr_vel_motor_dir,
                                     ctr_vel_motor_esq)
Пример #4
0
def interrupcao_movimento(ctr_vel_motor_dir, ctr_vel_motor_esq):
    motor.parar_movimento(ctr_vel_motor_dir, ctr_vel_motor_esq)
Пример #5
0
def correcao_motor_dir(velocidade, ctr_vel_motor_dir, ctr_vel_motor_esq):
    motor.movimento_esquerda(velocidade, ctr_vel_motor_dir, ctr_vel_motor_esq)
Пример #6
0
def correcao_motor_esq(velocidade, ctr_vel_motor_dir, ctr_vel_motor_esq):
    motor.movimento_direita(velocidade, ctr_vel_motor_dir, ctr_vel_motor_esq)
Пример #7
0
def movimento_frente(velocidade, ctr_vel_motor_dir, ctr_vel_motor_esq):
    motor.movimento_frente(velocidade, ctr_vel_motor_dir, ctr_vel_motor_esq)
Пример #8
0
GPIO.setmode(GPIO.BCM)

GPIO.setwarnings(False)

definir.configuracoes()

controle_velocidade_direita = GPIO.PWM(var.pin_ENA, 500)
controle_velocidade_direita.start(0)

controle_velocidade_esquerda = GPIO.PWM(var.pin_ENB, 500)
controle_velocidade_esquerda.start(0)

try:
    while (True):
        motor.movimento_frente(var.velNormal, controle_velocidade_direita,
                               controle_velocidade_esquerda)
        time.sleep(3)
        motor.parar_movimento(controle_velocidade_direita,
                              controle_velocidade_esquerda)
        time.sleep(0.8)
        '''
		motor.movimento_direita(var.velReacao, controle_velocidade_direita, controle_velocidade_esquerda)
		time.sleep(2)	
		motor.parar_movimento(controle_velocidade_direita, controle_velocidade_esquerda)
		time.sleep(0.8)


		motor.movimento_esquerda(var.velReacao, controle_velocidade_direita, controle_velocidade_esquerda)
		time.sleep(2)	
		motor.parar_movimento(controle_velocidade_direita, controle_velocidade_esquerda)
		time.sleep(0.8)
Пример #9
0
        interface.apresenta_tela("Imagem Original", imagem, 580, 10)
        interface.apresenta_tela("Sinalizacoes da Direita",
                                 imagem_sinalizacao_dir, 1080, 10)

        #interface.apresenta_tela("Imagem Faixa Esquerda", imagem_faixa_esq, 80, 355)
        #interface.apresenta_tela("Imagem Perspetiva Pista", imagem_perspectiva_pista, 580, 355)
        #interface.apresenta_tela("Imagem Faixa Direita", imagem_faixa_dir, 1080, 355)

        # -------------------------------------------------------------------------------

        #print(cont_frames)
        #cont_frames += 1
        #print(status_a0, status_a1, status_a2, status_a3, status_b0, status_b1, status_b2, status_b3, status_visao_faixa_dir, status_visao_faixa_esq, status_obstaculo_vl53x)
        #print("A0:{:>5} A1:{:>5} A2:{:>5} A3:{:>5} \tB0:{:>5} B1:{:>5} B2:{:>5} B3:{:>5}".format(a0, a1, a2, a3, b0, b1, b2, b3))
        #print(DETECCAO_OBSTACULOS_VISAO)
        #print(status_visao_faixa_dir, status_visao_faixa_esq, status_normalidade_faixa_dir, status_normalidade_faixa_esq, DETECCAO_OBSTACULOS_VISAO)
        #print("\nDetectou Obstaculo: {0} \tValor: {1}".format(status_obstaculo_visao, 0))
        #print(status_placa_pare, status_placa_pedestre, status_placa_desvio, status_placa_60, status_placa_proib_virar, status_semaforo_vermelho, status_semaforo_verde)

        capturaFrames.truncate(0)

        if cv2.waitKey(1) & 0xFF == 27:
            motor.parar_movimento(ctr_vel_motor_dir, ctr_vel_motor_esq)
            cv2.destroyAllWindows()
            GPIO.cleanup()
            break
finally:
    print("bye bye...")
    cv2.destroyAllWindows()
    GPIO.cleanup()