blob: 8590d7bdb9e829fd5842826f88464b2b11f85f7f [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 Upadhyay5c406782022-09-26 21:28:35 -070053 const goalPlot =
54 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
55 goalPlot.plot.getAxisLabels().setTitle('Goal');
56 goalPlot.plot.getAxisLabels().setXLabel(TIME);
57 goalPlot.plot.getAxisLabels().setYLabel('value');
58 goalPlot.plot.setDefaultYRange([-1.0, 2.0]);
59 goalPlot.addMessageLine(goal, ['fire']).setColor(RED).setPointSize(1.0);
60 goalPlot.addMessageLine(goal, ['auto_aim']).setColor(BLUE).setPointSize(1.0);
61
62
Milind Upadhyay9d68b132022-04-01 10:58:18 -070063 const shotCountPlot =
64 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
65 shotCountPlot.plot.getAxisLabels().setTitle('Shot Count');
66 shotCountPlot.plot.getAxisLabels().setXLabel(TIME);
67 shotCountPlot.plot.getAxisLabels().setYLabel('balls');
68 shotCountPlot.plot.setDefaultYRange([-1.0, 2.0]);
69 shotCountPlot.addMessageLine(status, ['shot_count'])
70 .setColor(RED)
71 .setPointSize(1.0);
Ravago Jones71e434b2022-03-06 14:09:40 -080072
73 const intakePlot =
74 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
75 intakePlot.plot.getAxisLabels().setTitle('Intake');
76 intakePlot.plot.getAxisLabels().setXLabel(TIME);
77 intakePlot.plot.getAxisLabels().setYLabel('wonky state units');
78 intakePlot.plot.setDefaultYRange([-1.0, 2.0]);
79 intakePlot.addMessageLine(status, ['intake_state'])
80 .setColor(RED)
81 .setPointSize(1.0);
82 intakePlot.addMessageLine(position, ['intake_beambreak_front'])
83 .setColor(GREEN)
84 .setPointSize(4.0);
85 intakePlot.addMessageLine(position, ['intake_beambreak_back'])
86 .setColor(PINK)
87 .setPointSize(1.0);
milind-uc63d0942022-04-15 12:07:42 -070088 intakePlot.addMessageLine(output, ['transfer_roller_voltage'])
89 .setColor(BROWN)
90 .setPointSize(3.0);
Ravago Jones71e434b2022-03-06 14:09:40 -080091
92
93 const otherPlot =
94 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
95 otherPlot.plot.getAxisLabels().setTitle('Position');
96 otherPlot.plot.getAxisLabels().setXLabel(TIME);
97 otherPlot.plot.getAxisLabels().setYLabel('rad');
98 otherPlot.plot.setDefaultYRange([-1.0, 2.0]);
99
100 otherPlot.addMessageLine(status, ['catapult', 'position'])
101 .setColor(PINK)
102 .setPointSize(4.0);
milind-uc63d0942022-04-15 12:07:42 -0700103 otherPlot.addMessageLine(status, ['turret', 'position'])
104 .setColor(WHITE)
105 .setPointSize(4.0);
Ravago Jones71e434b2022-03-06 14:09:40 -0800106 otherPlot.addMessageLine(position, ['flipper_arm_left', 'encoder'])
107 .setColor(BLUE)
108 .setPointSize(4.0);
109 otherPlot.addMessageLine(position, ['flipper_arm_right', 'encoder'])
110 .setColor(CYAN)
111 .setPointSize(4.0);
James Kuszmaulccc566f2022-03-12 14:10:00 -0800112 otherPlot.addMessageLine(output, ['flipper_arms_voltage'])
113 .setColor(BROWN)
114 .setPointSize(4.0);
milind-u086d7262022-01-19 20:44:18 -0800115}