Library » History » Version 1
cristobal hernandez, 12/12/2024 08:35 PM
1 | 1 | cristobal hernandez | h1. Library |
---|---|---|---|
2 | 1 | cristobal hernandez | <pre><code class="python"> |
3 | 1 | cristobal hernandez | from ev3dev2.motor import LargeMotor, MediumMotor, |
4 | 1 | cristobal hernandez | OUTPUT_A, OUTPUT_B, OUTPUT_C |
5 | 1 | cristobal hernandez | import time |
6 | 1 | cristobal hernandez | |
7 | 1 | cristobal hernandez | |
8 | 1 | cristobal hernandez | ma = MediumMotor(OUTPUT_A) |
9 | 1 | cristobal hernandez | mb = LargeMotor(OUTPUT_B) |
10 | 1 | cristobal hernandez | mc = LargeMotor(OUTPUT_C) |
11 | 1 | cristobal hernandez | md = LargeMotor(OUTPUT_D) |
12 | 1 | cristobal hernandez | |
13 | 1 | cristobal hernandez | tankmoves = MoveTank(OUTPUT_C, OUTPUT_D) |
14 | 1 | cristobal hernandez | |
15 | 1 | cristobal hernandez | # Mover Robot hacia adelante |
16 | 1 | cristobal hernandez | def mover_arriba(): |
17 | 1 | cristobal hernandez | tankmoves.on(-100,- 100) |
18 | 1 | cristobal hernandez | |
19 | 1 | cristobal hernandez | # Mover Robot hacia atrás |
20 | 1 | cristobal hernandez | def mover_atras(): |
21 | 1 | cristobal hernandez | tankmoves.on(100, 100) |
22 | 1 | cristobal hernandez | |
23 | 1 | cristobal hernandez | # Mover Robot hacia derecha |
24 | 1 | cristobal hernandez | def mover_derecha(): |
25 | 1 | cristobal hernandez | tankmoves.on(100, 1) |
26 | 1 | cristobal hernandez | |
27 | 1 | cristobal hernandez | # Mover Robot hacia izquierda |
28 | 1 | cristobal hernandez | def mover_izquierda(): |
29 | 1 | cristobal hernandez | tankmoves.on(1, 100) |
30 | 1 | cristobal hernandez | |
31 | 1 | cristobal hernandez | # Subir Garra hacia adelante |
32 | 1 | cristobal hernandez | def base_subir(): |
33 | 1 | cristobal hernandez | mb.run_to_rel_pos(position_sp=135,speed_sp=200) |
34 | 1 | cristobal hernandez | time.sleep(1) |
35 | 1 | cristobal hernandez | mb.off() |
36 | 1 | cristobal hernandez | |
37 | 1 | cristobal hernandez | |
38 | 1 | cristobal hernandez | # Bajar Garra hacia adelante |
39 | 1 | cristobal hernandez | def base_soltar(): |
40 | 1 | cristobal hernandez | mb.run_to_rel_pos(position_sp=-135, speed_sp=200) |
41 | 1 | cristobal hernandez | time.sleep(1) |
42 | 1 | cristobal hernandez | mb.off() |
43 | 1 | cristobal hernandez | |
44 | 1 | cristobal hernandez | # Movimiento Garra atrapar |
45 | 1 | cristobal hernandez | def atrapar(): |
46 | 1 | cristobal hernandez | ma.run_to_rel_pos(position_sp=-1080, speed_sp=1000) |
47 | 1 | cristobal hernandez | time.sleep(1) |
48 | 1 | cristobal hernandez | md.off() |
49 | 1 | cristobal hernandez | |
50 | 1 | cristobal hernandez | # Movimiento Garra soltar |
51 | 1 | cristobal hernandez | def soltar(): |
52 | 1 | cristobal hernandez | ma.run_to_rel_pos(position_sp=1080, speed_sp=1000) |
53 | 1 | cristobal hernandez | time.sleep(1) |
54 | 1 | cristobal hernandez | md.off() |
55 | 1 | cristobal hernandez | |
56 | 1 | cristobal hernandez | # Detener Robot |
57 | 1 | cristobal hernandez | def stop(): |
58 | 1 | cristobal hernandez | tankmoves.off() |
59 | 1 | cristobal hernandez | </code></pre> |