blob: de2b4eeba814e6ce59a3125872d02840416978cc [file] [log] [blame]
Austin Schuh3634fa12013-03-03 15:09:06 -08001#include "stdio.h"
2
3#include "aos/aos_core.h"
4#include "aos/common/control_loop/Timing.h"
5#include "aos/common/time.h"
6#include "frc971/control_loops/shooter/shooter_motor.q.h"
7
8using ::frc971::control_loops::shooter;
9using ::aos::time::Time;
10
11int main(int argc, char * argv[]) {
12 FILE *data_file = NULL;
13 FILE *output_file = NULL;
Austin Schuh3634fa12013-03-03 15:09:06 -080014
Austin Schuhf3d96b82013-03-06 18:46:11 -080015 if (argc == 2) {
Austin Schuh3634fa12013-03-03 15:09:06 -080016 data_file = fopen(argv[1], "w");
Austin Schuh3634fa12013-03-03 15:09:06 -080017 output_file = data_file;
18 } else {
Austin Schuhf3d96b82013-03-06 18:46:11 -080019 printf("Logging to stdout instead\n");
Austin Schuh3634fa12013-03-03 15:09:06 -080020 output_file = stdout;
21 }
22
Austin Schuhf3d96b82013-03-06 18:46:11 -080023 fprintf(data_file, "time, power, position");
24
Austin Schuh3634fa12013-03-03 15:09:06 -080025 ::aos::Init();
26
27 Time start_time = Time::Now();
28
29 while (true) {
30 ::aos::time::PhasedLoop10MS(2000);
31 shooter.goal.FetchLatest();
32 shooter.status.FetchLatest();
33 shooter.position.FetchLatest();
34 shooter.output.FetchLatest();
35 if (shooter.output.get() &&
36 shooter.position.get()) {
37 fprintf(output_file, "\n%f, %f, %f",
Austin Schuhf3d96b82013-03-06 18:46:11 -080038 (shooter.position->sent_time - start_time).ToSeconds(),
Austin Schuh3634fa12013-03-03 15:09:06 -080039 shooter.output->voltage,
40 shooter.position->position);
41 }
42 }
43
44 if (data_file) {
45 fclose(data_file);
46 }
47
48 ::aos::Cleanup();
49 return 0;
50}
51