blob: 26f28669aa1c04509b3980d5377d73da4dcad908 [file] [log] [blame]
Austin Schuh3634fa12013-03-03 15:09:06 -08001#include "stdio.h"
2
Austin Schuh3634fa12013-03-03 15:09:06 -08003#include "aos/common/control_loop/Timing.h"
4#include "aos/common/time.h"
5#include "frc971/control_loops/shooter/shooter_motor.q.h"
6
7using ::frc971::control_loops::shooter;
8using ::aos::time::Time;
9
10int main(int argc, char * argv[]) {
11 FILE *data_file = NULL;
12 FILE *output_file = NULL;
Austin Schuh3634fa12013-03-03 15:09:06 -080013
Austin Schuhf3d96b82013-03-06 18:46:11 -080014 if (argc == 2) {
Austin Schuh3634fa12013-03-03 15:09:06 -080015 data_file = fopen(argv[1], "w");
Austin Schuh3634fa12013-03-03 15:09:06 -080016 output_file = data_file;
17 } else {
Austin Schuhf3d96b82013-03-06 18:46:11 -080018 printf("Logging to stdout instead\n");
Austin Schuh3634fa12013-03-03 15:09:06 -080019 output_file = stdout;
20 }
21
Austin Schuhf3d96b82013-03-06 18:46:11 -080022 fprintf(data_file, "time, power, position");
23
Austin Schuh3634fa12013-03-03 15:09:06 -080024 ::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",
Austin Schuhf3d96b82013-03-06 18:46:11 -080037 (shooter.position->sent_time - start_time).ToSeconds(),
Austin Schuh3634fa12013-03-03 15:09:06 -080038 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