-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathladybug.ino
More file actions
149 lines (118 loc) · 3.79 KB
/
ladybug.ino
File metadata and controls
149 lines (118 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "PAMI_interface.h"
#include "pinout.h"
bool inYellowTeam = true;
int pamiId = 1;
long MATicks = 0;
long MBTicks = 0;
long timeOutBeforeStart = 90000;
int timeOutAfterStart = 10000;
PAMI_Interface monPAMI;
Timeout timeout(&totalStop, timeOutAfterStart, false);
void setup() {
Serial.begin(115200);
initialize_encoders();
monPAMI.PAMIsetup();
inYellowTeam = monPAMI.getSwitchState(4);
if(monPAMI.getSwitchState(1)) {
pamiId = 1;
}else if(monPAMI.getSwitchState(2)) {
pamiId = 2;
}else if(monPAMI.getSwitchState(3)) {
pamiId = 3;
}
Serial.println(pamiId);
monPAMI.raiseArm();
for (int i = 0; i < pamiId; i++)
{
monPAMI.setLedState(true);
delay(200);
monPAMI.setLedState(false);
delay(200);
}
monPAMI.stopMotors();
Serial.print("PAMI n°" + String(pamiId) + " in ");
Serial.print(inYellowTeam ? "Yellow" : "Blue");
Serial.println(" team");
while(digitalRead(limitSwitchPin)) // Attente tirette
{
Serial.println("Waiting for start signal! Switch input = " + String(digitalRead(limitSwitchPin)));
delay(100);
}
Serial.println("Countdown started!");
// delay(timeOutBeforeStart);
Serial.println("Launch !");
// timeout.start();
// monPAMI.driveStraight(800, true, false);
if (pamiId == 1) {
monPAMI.correctCW = 1.0;
monPAMI.correctCCW = 0.97;
monPAMI.ticksPerTurn_motA = 969;
monPAMI.ticksPerTurn_motB = 983;
monPAMI.wheelDiameter_motA = 66.2;
monPAMI.wheelDiameter_motB = 66.0;
monPAMI.halfVehicleTrack = 59.5;
monPAMI.extraDist = 0; // Doit etre calibré!
// Strategie de match
monPAMI.driveStraight(400, true, false);
monPAMI.drivePivot(90, !inYellowTeam);
monPAMI.driveStraight(80, true, false);
// Mouvements de test
// monPAMI.drivePivot(180, false);
// monPAMI.driveStraight(500, true, false);
}else if (pamiId == 2) {
monPAMI.correctCW = 1.0; // Doit etre calibré!
monPAMI.correctCCW = 1.5; // Doit etre calibré!
monPAMI.ticksPerTurn_motA = 959;
monPAMI.ticksPerTurn_motB = 970;
monPAMI.wheelDiameter_motA = 51.0;
monPAMI.wheelDiameter_motB = 81.0;
monPAMI.halfVehicleTrack = 59.5;
monPAMI.extraDist = 0; // Doit etre calibré!
// Strategie de match
monPAMI.driveStraight(430, true, false);
monPAMI.drivePivot(70, !inYellowTeam);
monPAMI.driveStraight(1260, true, false);
// Mouvements de test
// monPAMI.driveStraight(1000, true, false);
// monPAMI.drivePivot(90, 0);
// monPAMI.drivePivot(90, 1);
}else if (pamiId == 3) {
monPAMI.correctCW = 1.00; // Doit etre calibré!
monPAMI.correctCCW = 1.00; // Doit etre calibré!
monPAMI.ticksPerTurn_motA = 970; // Doit etre calibré!
monPAMI.ticksPerTurn_motB = 970; // Doit etre calibré!
monPAMI.wheelDiameter_motA = 54.0;
monPAMI.wheelDiameter_motB = 76.0;
monPAMI.halfVehicleTrack = 60.0; // Doit etre calibré!
monPAMI.extraDist = 0; // Doit etre calibré!
// Strategie de match
// monPAMI.driveStraight(1250, true, false);
// monPAMI.drivePivot(90, inYellowTeam);
// monPAMI.driveStraight(1550, true, false);
// Mouvements de test
monPAMI.driveStraight(1000, true, false);
// monPAMI.drivePivot(90, 0);
// monPAMI.drivePivot(90, 1);
}
monPAMI.lowerArm();
while (true) {
monPAMI.setLedState(true);
delay(200);
monPAMI.setLedState(false);
delay(200);
}
}
void loop() {
timeout.loop();
// monPAMI.drivePivot(90, false);
// delay(1000);
}
void totalStop() {
digitalWrite(STBY, LOW);
while (true) {
monPAMI.setLedState(true);
delay(200);
monPAMI.setLedState(false);
delay(200);
}
}