blob: c9420ae77a5b5ede9cf60f085087564ffa397275 [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
milind-u7baf7342021-08-25 18:31:26 -070037 const ballsShotPlot =
38 aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
39 currentTop += DEFAULT_HEIGHT / 2;
40 ballsShotPlot.plot.getAxisLabels().setTitle('Balls Shot');
41 ballsShotPlot.plot.getAxisLabels().setXLabel(TIME);
42 ballsShotPlot.plot.getAxisLabels().setYLabel('Balls');
43 ballsShotPlot.plot.setDefaultYRange([0.0, 20.0]);
44 ballsShotPlot.addMessageLine(status, ['shooter', 'balls_shot']).setColor(BLUE).setPointSize(0.0);
45
46
Austin Schuh7d63eab2021-03-06 20:15:02 -080047 const voltagePlot =
48 aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
49 currentTop += DEFAULT_HEIGHT / 2;
50 voltagePlot.plot.getAxisLabels().setTitle('Voltage');
51 voltagePlot.plot.getAxisLabels().setXLabel(TIME);
52 voltagePlot.plot.getAxisLabels().setYLabel('Volts');
53 voltagePlot.plot.setDefaultYRange([-4.0, 16.0]);
54
55 voltagePlot.addMessageLine(output, ['finisher_voltage']).setColor(BLUE).setPointSize(0.0);
56 voltagePlot.addMessageLine(status, ['shooter', 'finisher', 'voltage_error']).setColor(RED).setPointSize(0.0);
57 voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(0.0);
58
59
60 const currentPlot =
61 aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
62 currentTop += DEFAULT_HEIGHT / 2;
63 currentPlot.plot.getAxisLabels().setTitle('Current');
64 currentPlot.plot.getAxisLabels().setXLabel(TIME);
65 currentPlot.plot.getAxisLabels().setYLabel('Amps');
66 currentPlot.plot.setDefaultYRange([0.0, 80.0]);
67
68 currentPlot.addMessageLine(pdpValues, ['currents[12]']).setColor(GREEN).setPointSize(0.0);
69 currentPlot.addMessageLine(pdpValues, ['currents[13]']).setColor(BLUE).setPointSize(0.0);
70 currentPlot.addMessageLine(status, ['shooter', 'finisher', 'commanded_current']).setColor(RED).setPointSize(0.0);
71}