blob: 6ec4be430b7da1b853f7cc5e374b9bd5caae0a48 [file] [log] [blame]
Austin Schuh7d63eab2021-03-06 20:15:02 -08001// Provides a plot for debugging robot state-related issues.
2import {AosPlotter} from 'org_frc971/aos/network/www/aos_plotter';
3import * as proxy from 'org_frc971/aos/network/www/proxy';
Austin Schuh5c40ea42021-09-26 13:28:03 -07004import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE, BLACK} from 'org_frc971/aos/network/www/colors';
Austin Schuh7d63eab2021-03-06 20:15:02 -08005
6import Connection = proxy.Connection;
7
8const TIME = AosPlotter.TIME;
9const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH;
10const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
Austin Schuh7d63eab2021-03-06 20:15:02 -080011
12export function plotFinisher(conn: Connection, element: Element) : void {
13 const aosPlotter = new AosPlotter(conn);
14 const goal = aosPlotter.addMessageSource('/superstructure', 'y2020.control_loops.superstructure.Goal');
15 const output = aosPlotter.addMessageSource('/superstructure', 'y2020.control_loops.superstructure.Output');
16 const status = aosPlotter.addMessageSource('/superstructure', 'y2020.control_loops.superstructure.Status');
17 const pdpValues = aosPlotter.addMessageSource('/roborio/aos', 'frc971.PDPValues');
18 const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
19
20 var currentTop = 0;
21
22 // Robot Enabled/Disabled and Mode
23 const velocityPlot =
24 aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
25 currentTop += DEFAULT_HEIGHT / 2;
26 velocityPlot.plot.getAxisLabels().setTitle('Velocity');
27 velocityPlot.plot.getAxisLabels().setXLabel(TIME);
28 velocityPlot.plot.getAxisLabels().setYLabel('rad/s');
Austin Schuh5c40ea42021-09-26 13:28:03 -070029 velocityPlot.plot.setDefaultYRange([0.0, 600.0]);
Austin Schuh7d63eab2021-03-06 20:15:02 -080030
31 velocityPlot.addMessageLine(goal, ['shooter', 'velocity_finisher']).setColor(BLUE).setPointSize(0.0);
32 velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'avg_angular_velocity']).setColor(RED).setPointSize(0.0);
33 velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'angular_velocity']).setColor(GREEN).setPointSize(0.0);
Austin Schuh5c40ea42021-09-26 13:28:03 -070034 velocityPlot.addMessageLine(status, ['shooter', 'ready']).setColor(BLACK).setPointSize(0.0);
Austin Schuh7d63eab2021-03-06 20:15:02 -080035 velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'dt_angular_velocity']).setColor(PINK).setPointSize(0.0);
36
37 const voltagePlot =
38 aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
39 currentTop += DEFAULT_HEIGHT / 2;
40 voltagePlot.plot.getAxisLabels().setTitle('Voltage');
41 voltagePlot.plot.getAxisLabels().setXLabel(TIME);
42 voltagePlot.plot.getAxisLabels().setYLabel('Volts');
43 voltagePlot.plot.setDefaultYRange([-4.0, 16.0]);
44
45 voltagePlot.addMessageLine(output, ['finisher_voltage']).setColor(BLUE).setPointSize(0.0);
46 voltagePlot.addMessageLine(status, ['shooter', 'finisher', 'voltage_error']).setColor(RED).setPointSize(0.0);
47 voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(0.0);
48
49
50 const currentPlot =
51 aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
52 currentTop += DEFAULT_HEIGHT / 2;
53 currentPlot.plot.getAxisLabels().setTitle('Current');
54 currentPlot.plot.getAxisLabels().setXLabel(TIME);
55 currentPlot.plot.getAxisLabels().setYLabel('Amps');
56 currentPlot.plot.setDefaultYRange([0.0, 80.0]);
57
58 currentPlot.addMessageLine(pdpValues, ['currents[12]']).setColor(GREEN).setPointSize(0.0);
59 currentPlot.addMessageLine(pdpValues, ['currents[13]']).setColor(BLUE).setPointSize(0.0);
60 currentPlot.addMessageLine(status, ['shooter', 'finisher', 'commanded_current']).setColor(RED).setPointSize(0.0);
61}