blob: c7d14fdb731cfd42a83108c82ab9d36d65daf55f [file] [log] [blame]
Maxwell Hendersonad312342023-01-10 12:07:47 -08001// Provides a plot for debugging robot state-related issues.
Philipp Schrader548aedf2023-02-17 20:09:13 -08002import {AosPlotter} from '../../../aos/network/www/aos_plotter';
3import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE} from '../../../aos/network/www/colors';
4import * as proxy from '../../../aos/network/www/proxy';
Maxwell Hendersonad312342023-01-10 12:07:47 -08005
6import Connection = proxy.Connection;
7
8const TIME = AosPlotter.TIME;
9const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH * 2;
10const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
11
12export function plotSuperstructure(conn: Connection, element: Element): void {
13 const aosPlotter = new AosPlotter(conn);
James Kuszmaul81e71842023-09-29 15:25:13 -070014 //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 Hendersonad312342023-01-10 12:07:47 -080020 const position = aosPlotter.addMessageSource(
21 '/superstructure', 'y2023.control_loops.superstructure.Position');
James Kuszmaul81e71842023-09-29 15:25:13 -070022 //const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
Maxwell Hendersonad312342023-01-10 12:07:47 -080023
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 Kuszmaul81e71842023-09-29 15:25:13 -070031 positionPlot.addMessageLine(position, ['arm', 'distal', 'pot'])
Maxwell Hendersonad312342023-01-10 12:07:47 -080032 .setColor(RED)
33 .setPointSize(4.0);
James Kuszmaul81e71842023-09-29 15:25:13 -070034 positionPlot.addMessageLine(position, ['arm', 'distal', 'absolute_encoder'])
Maxwell Hendersonad312342023-01-10 12:07:47 -080035 .setColor(BLUE)
36 .setPointSize(4.0);
James Kuszmaul81e71842023-09-29 15:25:13 -070037 positionPlot.addMessageLine(position, ['arm', 'distal', 'encoder'])
38 .setColor(GREEN)
Maxwell Hendersonad312342023-01-10 12:07:47 -080039 .setPointSize(4.0);
40}