blob: f2127f54df3483cc176b90ec520c56512c5ca602 [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
Austin Schuh7d63eab2021-03-06 20:15:02 -080020 // Robot Enabled/Disabled and Mode
21 const velocityPlot =
Austin Schuhc2e9c502021-11-25 21:23:24 -080022 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
Austin Schuh7d63eab2021-03-06 20:15:02 -080023 velocityPlot.plot.getAxisLabels().setTitle('Velocity');
24 velocityPlot.plot.getAxisLabels().setXLabel(TIME);
25 velocityPlot.plot.getAxisLabels().setYLabel('rad/s');
Austin Schuh5c40ea42021-09-26 13:28:03 -070026 velocityPlot.plot.setDefaultYRange([0.0, 600.0]);
Austin Schuh7d63eab2021-03-06 20:15:02 -080027
28 velocityPlot.addMessageLine(goal, ['shooter', 'velocity_finisher']).setColor(BLUE).setPointSize(0.0);
29 velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'avg_angular_velocity']).setColor(RED).setPointSize(0.0);
30 velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'angular_velocity']).setColor(GREEN).setPointSize(0.0);
Austin Schuh5c40ea42021-09-26 13:28:03 -070031 velocityPlot.addMessageLine(status, ['shooter', 'ready']).setColor(BLACK).setPointSize(0.0);
Austin Schuh7d63eab2021-03-06 20:15:02 -080032 velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'dt_angular_velocity']).setColor(PINK).setPointSize(0.0);
33
milind-u7baf7342021-08-25 18:31:26 -070034 const ballsShotPlot =
Austin Schuhc2e9c502021-11-25 21:23:24 -080035 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
milind-u7baf7342021-08-25 18:31:26 -070036 ballsShotPlot.plot.getAxisLabels().setTitle('Balls Shot');
37 ballsShotPlot.plot.getAxisLabels().setXLabel(TIME);
38 ballsShotPlot.plot.getAxisLabels().setYLabel('Balls');
39 ballsShotPlot.plot.setDefaultYRange([0.0, 20.0]);
40 ballsShotPlot.addMessageLine(status, ['shooter', 'balls_shot']).setColor(BLUE).setPointSize(0.0);
41
Austin Schuh7d63eab2021-03-06 20:15:02 -080042 const voltagePlot =
Austin Schuhc2e9c502021-11-25 21:23:24 -080043 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
Austin Schuh7d63eab2021-03-06 20:15:02 -080044 voltagePlot.plot.getAxisLabels().setTitle('Voltage');
45 voltagePlot.plot.getAxisLabels().setXLabel(TIME);
46 voltagePlot.plot.getAxisLabels().setYLabel('Volts');
47 voltagePlot.plot.setDefaultYRange([-4.0, 16.0]);
48
49 voltagePlot.addMessageLine(output, ['finisher_voltage']).setColor(BLUE).setPointSize(0.0);
50 voltagePlot.addMessageLine(status, ['shooter', 'finisher', 'voltage_error']).setColor(RED).setPointSize(0.0);
51 voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(0.0);
52
Austin Schuh7d63eab2021-03-06 20:15:02 -080053 const currentPlot =
Austin Schuhc2e9c502021-11-25 21:23:24 -080054 aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
Austin Schuh7d63eab2021-03-06 20:15:02 -080055 currentPlot.plot.getAxisLabels().setTitle('Current');
56 currentPlot.plot.getAxisLabels().setXLabel(TIME);
57 currentPlot.plot.getAxisLabels().setYLabel('Amps');
58 currentPlot.plot.setDefaultYRange([0.0, 80.0]);
59
60 currentPlot.addMessageLine(pdpValues, ['currents[12]']).setColor(GREEN).setPointSize(0.0);
61 currentPlot.addMessageLine(pdpValues, ['currents[13]']).setColor(BLUE).setPointSize(0.0);
62 currentPlot.addMessageLine(status, ['shooter', 'finisher', 'commanded_current']).setColor(RED).setPointSize(0.0);
63}