Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 1 | // Provides a plot for debugging robot state-related issues. |
Philipp Schrader | 548aedf | 2023-02-17 20:09:13 -0800 | [diff] [blame^] | 2 | import {AosPlotter} from '../../../aos/network/www/aos_plotter'; |
| 3 | import * as proxy from '../../../aos/network/www/proxy'; |
| 4 | import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE, BLACK} from '../../../aos/network/www/colors'; |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 5 | |
| 6 | import Connection = proxy.Connection; |
| 7 | |
| 8 | const TIME = AosPlotter.TIME; |
| 9 | const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH; |
| 10 | const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3; |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 11 | |
| 12 | export 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 Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 20 | // Robot Enabled/Disabled and Mode |
| 21 | const velocityPlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 22 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 23 | velocityPlot.plot.getAxisLabels().setTitle('Velocity'); |
| 24 | velocityPlot.plot.getAxisLabels().setXLabel(TIME); |
| 25 | velocityPlot.plot.getAxisLabels().setYLabel('rad/s'); |
Austin Schuh | 5c40ea4 | 2021-09-26 13:28:03 -0700 | [diff] [blame] | 26 | velocityPlot.plot.setDefaultYRange([0.0, 600.0]); |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 27 | |
| 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 Schuh | 5c40ea4 | 2021-09-26 13:28:03 -0700 | [diff] [blame] | 31 | velocityPlot.addMessageLine(status, ['shooter', 'ready']).setColor(BLACK).setPointSize(0.0); |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 32 | velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'dt_angular_velocity']).setColor(PINK).setPointSize(0.0); |
| 33 | |
milind-u | 7baf734 | 2021-08-25 18:31:26 -0700 | [diff] [blame] | 34 | const ballsShotPlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 35 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
milind-u | 7baf734 | 2021-08-25 18:31:26 -0700 | [diff] [blame] | 36 | 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 Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 42 | const voltagePlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 43 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 44 | 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 Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 53 | const currentPlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 54 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame] | 55 | 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 | } |