Austin Schuh | 2efe168 | 2021-03-06 22:47:15 -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} from '../../../aos/network/www/colors'; |
Austin Schuh | 2efe168 | 2021-03-06 22:47:15 -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 | 2efe168 | 2021-03-06 22:47:15 -0800 | [diff] [blame] | 11 | |
| 12 | export function plotHood(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 robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState'); |
| 18 | |
| 19 | var currentTop = 0; |
| 20 | |
| 21 | // Robot Enabled/Disabled and Mode |
| 22 | const positionPlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 23 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
Austin Schuh | 2efe168 | 2021-03-06 22:47:15 -0800 | [diff] [blame] | 24 | currentTop += DEFAULT_HEIGHT / 2; |
| 25 | positionPlot.plot.getAxisLabels().setTitle('Position'); |
| 26 | positionPlot.plot.getAxisLabels().setXLabel(TIME); |
| 27 | positionPlot.plot.getAxisLabels().setYLabel('rad'); |
| 28 | positionPlot.plot.setDefaultYRange([-0.1, 0.7]); |
| 29 | |
| 30 | positionPlot.addMessageLine(goal, ['hood', 'unsafe_goal']).setColor(BLUE).setPointSize(0.0); |
| 31 | positionPlot.addMessageLine(status, ['hood', 'goal_position']).setColor(RED).setPointSize(0.0); |
| 32 | positionPlot.addMessageLine(status, ['hood', 'position']).setColor(GREEN).setPointSize(0.0); |
| 33 | positionPlot.addMessageLine(status, ['hood', 'velocity']).setColor(PINK).setPointSize(0.0); |
| 34 | positionPlot.addMessageLine(status, ['hood', 'calculated_velocity']).setColor(BROWN).setPointSize(0.0); |
| 35 | positionPlot.addMessageLine(status, ['hood', 'estimator_state', 'position']).setColor(CYAN).setPointSize(0.0); |
| 36 | |
| 37 | const voltagePlot = |
Austin Schuh | c2e9c50 | 2021-11-25 21:23:24 -0800 | [diff] [blame] | 38 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
Austin Schuh | 2efe168 | 2021-03-06 22:47:15 -0800 | [diff] [blame] | 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, ['hood_voltage']).setColor(BLUE).setPointSize(0.0); |
| 46 | voltagePlot.addMessageLine(status, ['hood', 'voltage_error']).setColor(RED).setPointSize(0.0); |
| 47 | voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(0.0); |
| 48 | } |