John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 1 | #include "aos/controls/replay_control_loop.h" |
John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 2 | #include "aos/init.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 3 | |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 4 | #include "frc971/control_loops/drivetrain/drivetrain.q.h" |
Austin Schuh | d0e02df | 2015-11-26 12:48:51 -0800 | [diff] [blame] | 5 | #include "frc971/queues/gyro.q.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 6 | |
| 7 | // Reads one or more log files and sends out all the queue messages (in the |
| 8 | // correct order and at the correct time) to feed a "live" drivetrain process. |
| 9 | |
| 10 | int main(int argc, char **argv) { |
| 11 | if (argc <= 1) { |
| 12 | fprintf(stderr, "Need at least one file to replay!\n"); |
| 13 | return EXIT_FAILURE; |
| 14 | } |
| 15 | |
| 16 | ::aos::InitNRT(); |
| 17 | |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 18 | ::frc971::control_loops::DrivetrainQueue drivetrain_queue( |
| 19 | ".frc971.control_loops.drivetrain_queue", |
| 20 | ".frc971.control_loops.drivetrain_queue.goal", |
| 21 | ".frc971.control_loops.drivetrain_queue.position", |
| 22 | ".frc971.control_loops.drivetrain_queue.output", |
| 23 | ".frc971.control_loops.drivetrain_queue.status"); |
| 24 | |
Austin Schuh | 478dd4b | 2015-12-27 14:09:12 -0800 | [diff] [blame] | 25 | { |
| 26 | ::aos::controls::ControlLoopReplayer< |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 27 | ::frc971::control_loops::DrivetrainQueue> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 28 | replayer(&drivetrain_queue, "drivetrain"); |
Austin Schuh | d0e02df | 2015-11-26 12:48:51 -0800 | [diff] [blame] | 29 | |
Austin Schuh | df6cbb1 | 2019-02-02 13:46:52 -0800 | [diff] [blame] | 30 | replayer.AddDirectQueueSender<::frc971::sensors::GyroReading>( |
| 31 | "wpilib_interface.Gyro", "sending", ".frc971.sensors.gyro_reading"); |
Austin Schuh | 478dd4b | 2015-12-27 14:09:12 -0800 | [diff] [blame] | 32 | for (int i = 1; i < argc; ++i) { |
| 33 | replayer.ProcessFile(argv[i]); |
| 34 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 35 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 36 | |
| 37 | ::aos::Cleanup(); |
| 38 | } |