Advertisement
guadatech

Thymio procesador para el Tecnocampus

Jun 19th, 2015
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.57 KB | None | 0 0
  1. # Este programa realiza la ruta para hacer la prueba del procesado del Tecnocampus ( http://www.tecno-campus.com )
  2.  
  3. # Esta hecho para el Robot Thymio ( https://www.thymio.org/en:thymio ) , en el lenguaje Aseba
  4.  
  5. # Aqui está nuestra historia ( http://guadatech.blogspot.com.es/2015/06/equipo-ar-ii-tecnocampus-provincial.html )
  6.  
  7.  
  8. # ESTADOS
  9. var estado = 0 #0 parado
  10.  
  11. # VARIABLES DE CALIBRACION
  12. var velAvanceIzq = 245
  13. var velAvanceDer = 245
  14. var velgiro = 100
  15.  
  16. var tiempoParaGirar90grados = 2250
  17. var tiempoParaMoverse10cm = 1480
  18.  
  19. var sentirNegro = 150
  20. var tiempoPausa = 100
  21.  
  22. # TEMPORIZADORES
  23.  
  24. timer.period[0] = 0
  25. timer.period[1] = 0
  26.  
  27.  
  28. # SUBRUTINAS
  29. sub avance
  30.     motor.left.target = velAvanceIzq
  31.     motor.right.target = velAvanceDer
  32.     return
  33.    
  34. sub retroceso
  35.     motor.left.target = -1* velAvanceIzq
  36.     motor.right.target = -1* velAvanceDer
  37.     return
  38.    
  39. sub giroDerecha
  40.     motor.left.target = velgiro
  41.     motor.right.target = -1* velgiro
  42.     return
  43.    
  44. sub giroIzquierda
  45.     motor.left.target = -1*velgiro
  46.     motor.right.target =  velgiro
  47.     return
  48.    
  49. sub parada
  50.     motor.left.target = 0
  51.     motor.right.target = 0
  52.     return
  53.  
  54.  
  55.  
  56. # EVENTOS
  57.    
  58. onevent buttons
  59.     #Boton central para  pausar el robot
  60.     if button.center==1 then   
  61.         timer.period[0] = 0
  62.         timer.period[1] = 0
  63.         callsub parada
  64.         estado = 0    
  65.     end
  66.    
  67.     #Boton adelante para iniciar el programa
  68.     if button.forward == 1 then
  69.         #Avanza 20cm
  70.         timer.period[0] =  tiempoParaMoverse10cm * 2
  71.         callsub avance  
  72.         estado = 1 
  73.     end
  74.    
  75.    
  76. onevent timer0      # Temporizador para los estados impares
  77.      
  78.     if estado == 1   then  
  79.         estado = 2
  80.         callsub retroceso
  81.         timer.period[1] = tiempoParaMoverse10cm * 2
  82.         timer.period[0] = 0  
  83.     end
  84.    
  85.     if estado == 3   then  
  86.         estado = 4
  87.         callsub avance
  88.         timer.period[1] = tiempoParaMoverse10cm * 3
  89.         timer.period[0] = 0    
  90.     end
  91.    
  92.     if estado == 5   then  
  93.         estado = 6
  94.         callsub avance
  95.         timer.period[1] = tiempoParaMoverse10cm * 2
  96.         timer.period[0] = 0
  97.        
  98.     end
  99.  
  100.     if  estado == 7 then
  101.         estado = 8
  102.         callsub avance
  103.         timer.period[1] = tiempoParaMoverse10cm * 2
  104.         timer.period[0] = 0
  105.        
  106.     end
  107.    
  108.     if  estado == 9 then
  109.         estado = 10
  110.         callsub avance
  111.         timer.period[1] =tiempoParaMoverse10cm * 3
  112.         timer.period[0] = 0
  113.     end
  114.    
  115.     if   estado == 11 then
  116.          estado = 12
  117.          callsub parada
  118.          timer.period[1] =tiempoPausa
  119.          timer.period[0] = 0
  120.     end
  121.    
  122. onevent timer1      # Temporizador para los estados pares
  123.    
  124.     if estado == 2  then  
  125.        estado = 3
  126.        callsub giroDerecha  
  127.        timer.period[0] = tiempoParaGirar90grados
  128.        timer.period[1] = 0
  129.     end
  130.    
  131.     if estado == 4  then  
  132.        estado = 5
  133.        callsub giroIzquierda
  134.        timer.period[0] = tiempoParaGirar90grados
  135.        timer.period[1] = 0
  136.     end
  137.    
  138.   if  estado == 6 then
  139.       estado = 7
  140.       callsub giroDerecha
  141.       timer.period[0] = tiempoParaGirar90grados * 2
  142.       timer.period[1] = 0
  143.       end
  144.  
  145.   if  estado == 8 then
  146.      estado = 9
  147.      callsub giroDerecha
  148.      timer.period[0] = tiempoParaGirar90grados
  149.      timer.period[1] = 0
  150.   end
  151.  
  152.   if  estado == 10 then
  153.       estado = 11
  154.       callsub giroDerecha
  155.       timer.period[0] =tiempoParaGirar90grados
  156.       timer.period[1] = 0
  157.   end
  158.  
  159.   if  estado == 12 then
  160.       estado = 1
  161.       callsub avance
  162.       timer.period[0] =tiempoParaMoverse10cm * 2
  163.       timer.period[1] = 0
  164.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement