blob: 5a1537e495df74be5366a27a8be0e4a0c502b068 [file] [log] [blame]
milind-u086d7262022-01-19 20:44:18 -08001// Provides a plot for debugging robot state-related issues.
2import {AosPlotter} from 'org_frc971/aos/network/www/aos_plotter';
milind-u086d7262022-01-19 20:44:18 -08003import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE} from 'org_frc971/aos/network/www/colors';
Henry Speiser55aa3ba2022-02-21 23:21:12 -08004import * as proxy from 'org_frc971/aos/network/www/proxy';
milind-u086d7262022-01-19 20:44:18 -08005
6import Connection = proxy.Connection;
7
8const TIME = AosPlotter.TIME;
Austin Schuhc9b42db2022-03-12 12:03:29 -08009const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH * 2;
milind-u086d7262022-01-19 20:44:18 -080010const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
11
Henry Speiser55aa3ba2022-02-21 23:21:12 -080012export function plotSuperstructure(conn: Connection, element: Element): void {
milind-u086d7262022-01-19 20:44:18 -080013 const aosPlotter = new AosPlotter(conn);
Henry Speiser55aa3ba2022-02-21 23:21:12 -080014 const goal = aosPlotter.addMessageSource(
15 '/superstructure', 'y2022.control_loops.superstructure.Goal');
16 const output = aosPlotter.addMessageSource(
17 '/superstructure', 'y2022.control_loops.superstructure.Output');
18 const status = aosPlotter.addMessageSource(
19 '/superstructure', 'y2022.control_loops.superstructure.Status');
20 const position = aosPlotter.addMessageSource(
21 '/superstructure', 'y2022.control_loops.superstructure.Position');
milind-u086d7262022-01-19 20:44:18 -080022 const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
Ravago Jones71e434b2022-03-06 14:09:40 -080023
24 const positionPlot =
25 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
26 positionPlot.plot.getAxisLabels().setTitle('States');
27 positionPlot.plot.getAxisLabels().setXLabel(TIME);
28 positionPlot.plot.getAxisLabels().setYLabel('wonky state units');
29 positionPlot.plot.setDefaultYRange([-1.0, 2.0]);
30
31 positionPlot.addMessageLine(position, ['turret_beambreak'])
32 .setColor(RED)
33 .setPointSize(4.0);
34 positionPlot.addMessageLine(status, ['state'])
milind-uc63d0942022-04-15 12:07:42 -070035 .setColor(PINK)
36 .setPointSize(4.0);
Ravago Jones71e434b2022-03-06 14:09:40 -080037 positionPlot.addMessageLine(status, ['flippers_open'])
38 .setColor(WHITE)
39 .setPointSize(1.0);
40 positionPlot.addMessageLine(status, ['reseating_in_catapult'])
41 .setColor(BLUE)
42 .setPointSize(1.0);
43 positionPlot.addMessageLine(status, ['fire'])
Milind Upadhyay9d68b132022-04-01 10:58:18 -070044 .setColor(BROWN)
45 .setPointSize(1.0);
46 positionPlot.addMessageLine(status, ['ready_to_fire'])
47 .setColor(GREEN)
48 .setPointSize(1.0);
49 positionPlot.addMessageLine(status, ['collided'])
50 .setColor(PINK)
Ravago Jones71e434b2022-03-06 14:09:40 -080051 .setPointSize(1.0);
52
Milind Upadhyay9d68b132022-04-01 10:58:18 -070053 const shotCountPlot =
54 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
55 shotCountPlot.plot.getAxisLabels().setTitle('Shot Count');
56 shotCountPlot.plot.getAxisLabels().setXLabel(TIME);
57 shotCountPlot.plot.getAxisLabels().setYLabel('balls');
58 shotCountPlot.plot.setDefaultYRange([-1.0, 2.0]);
59 shotCountPlot.addMessageLine(status, ['shot_count'])
60 .setColor(RED)
61 .setPointSize(1.0);
Ravago Jones71e434b2022-03-06 14:09:40 -080062
63 const intakePlot =
64 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
65 intakePlot.plot.getAxisLabels().setTitle('Intake');
66 intakePlot.plot.getAxisLabels().setXLabel(TIME);
67 intakePlot.plot.getAxisLabels().setYLabel('wonky state units');
68 intakePlot.plot.setDefaultYRange([-1.0, 2.0]);
69 intakePlot.addMessageLine(status, ['intake_state'])
70 .setColor(RED)
71 .setPointSize(1.0);
72 intakePlot.addMessageLine(position, ['intake_beambreak_front'])
73 .setColor(GREEN)
74 .setPointSize(4.0);
75 intakePlot.addMessageLine(position, ['intake_beambreak_back'])
76 .setColor(PINK)
77 .setPointSize(1.0);
milind-uc63d0942022-04-15 12:07:42 -070078 intakePlot.addMessageLine(output, ['transfer_roller_voltage'])
79 .setColor(BROWN)
80 .setPointSize(3.0);
Ravago Jones71e434b2022-03-06 14:09:40 -080081
82
83 const otherPlot =
84 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
85 otherPlot.plot.getAxisLabels().setTitle('Position');
86 otherPlot.plot.getAxisLabels().setXLabel(TIME);
87 otherPlot.plot.getAxisLabels().setYLabel('rad');
88 otherPlot.plot.setDefaultYRange([-1.0, 2.0]);
89
90 otherPlot.addMessageLine(status, ['catapult', 'position'])
91 .setColor(PINK)
92 .setPointSize(4.0);
milind-uc63d0942022-04-15 12:07:42 -070093 otherPlot.addMessageLine(status, ['turret', 'position'])
94 .setColor(WHITE)
95 .setPointSize(4.0);
Ravago Jones71e434b2022-03-06 14:09:40 -080096 otherPlot.addMessageLine(position, ['flipper_arm_left', 'encoder'])
97 .setColor(BLUE)
98 .setPointSize(4.0);
99 otherPlot.addMessageLine(position, ['flipper_arm_right', 'encoder'])
100 .setColor(CYAN)
101 .setPointSize(4.0);
James Kuszmaulccc566f2022-03-12 14:10:00 -0800102 otherPlot.addMessageLine(output, ['flipper_arms_voltage'])
103 .setColor(BROWN)
104 .setPointSize(4.0);
milind-u086d7262022-01-19 20:44:18 -0800105}