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