blob: c929f7edb2baea901d1e8157262e94390a589699 [file] [log] [blame]
James Kuszmaulf7f5ec12013-11-01 17:58:58 -07001#include "stdio.h"
2
3#include "aos/common/control_loop/Timing.h"
4#include "aos/common/time.h"
5#include "bot3/control_loops/shooter/shooter_motor.q.h"
6
7using ::bot3::control_loops::shooter;
8using ::aos::time::Time;
9
10int main(int argc, char * argv[]) {
11 FILE *data_file = NULL;
12 FILE *output_file = NULL;
13
14 if (argc == 2) {
15 data_file = fopen(argv[1], "w");
16 output_file = data_file;
17 } else {
18 printf("Logging to stdout instead\n");
19 output_file = stdout;
20 }
21
22 fprintf(data_file, "time, power, position");
23
24 ::aos::Init();
25
26 Time start_time = Time::Now();
27
28 while (true) {
29 ::aos::time::PhasedLoop10MS(2000);
30 shooter.goal.FetchLatest();
31 shooter.status.FetchLatest();
32 shooter.position.FetchLatest();
33 shooter.output.FetchLatest();
34 if (shooter.output.get() &&
35 shooter.position.get()) {
36 fprintf(output_file, "\n%f, %f, %f",
37 (shooter.position->sent_time - start_time).ToSeconds(),
38 shooter.output->voltage,
39 shooter.position->position);
40 }
41 }
42
43 if (data_file) {
44 fclose(data_file);
45 }
46
47 ::aos::Cleanup();
48 return 0;
49}
50