Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -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 {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE} from '../../../aos/network/www/colors'; |
| 4 | import * as proxy from '../../../aos/network/www/proxy'; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 5 | |
| 6 | import Connection = proxy.Connection; |
| 7 | |
| 8 | const TIME = AosPlotter.TIME; |
| 9 | const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH * 2; |
| 10 | const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3; |
| 11 | |
| 12 | export function plotSuperstructure(conn: Connection, element: Element): void { |
| 13 | const aosPlotter = new AosPlotter(conn); |
James Kuszmaul | 81e7184 | 2023-09-29 15:25:13 -0700 | [diff] [blame] | 14 | //const goal = aosPlotter.addMessageSource( |
| 15 | // '/superstructure', 'y2023.control_loops.superstructure.Goal'); |
| 16 | //const output = aosPlotter.addMessageSource( |
| 17 | // '/superstructure', 'y2023.control_loops.superstructure.Output'); |
| 18 | //const status = aosPlotter.addMessageSource( |
| 19 | // '/superstructure', 'y2023.control_loops.superstructure.Status'); |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 20 | const position = aosPlotter.addMessageSource( |
| 21 | '/superstructure', 'y2023.control_loops.superstructure.Position'); |
James Kuszmaul | 81e7184 | 2023-09-29 15:25:13 -0700 | [diff] [blame] | 22 | //const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState'); |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 23 | |
| 24 | const positionPlot = |
| 25 | aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]); |
| 26 | positionPlot.plot.getAxisLabels().setTitle('States'); |
| 27 | positionPlot.plot.getAxisLabels().setXLabel(TIME); |
| 28 | positionPlot.plot.getAxisLabels().setYLabel('wonky state units'); |
| 29 | positionPlot.plot.setDefaultYRange([-1.0, 2.0]); |
| 30 | |
James Kuszmaul | 81e7184 | 2023-09-29 15:25:13 -0700 | [diff] [blame] | 31 | positionPlot.addMessageLine(position, ['arm', 'distal', 'pot']) |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 32 | .setColor(RED) |
| 33 | .setPointSize(4.0); |
James Kuszmaul | 81e7184 | 2023-09-29 15:25:13 -0700 | [diff] [blame] | 34 | positionPlot.addMessageLine(position, ['arm', 'distal', 'absolute_encoder']) |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 35 | .setColor(BLUE) |
| 36 | .setPointSize(4.0); |
James Kuszmaul | 81e7184 | 2023-09-29 15:25:13 -0700 | [diff] [blame] | 37 | positionPlot.addMessageLine(position, ['arm', 'distal', 'encoder']) |
| 38 | .setColor(GREEN) |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 39 | .setPointSize(4.0); |
| 40 | } |