Add intake, turret, and climber plotters
Change-Id: I2de2968219ad258bdce2799eaf7632c914cc3c84
Signed-off-by: Siddhant Kanwar <kanwarsiddhant@gmail.com>
diff --git a/y2022/control_loops/superstructure/BUILD b/y2022/control_loops/superstructure/BUILD
index ac91668..57b37f3 100644
--- a/y2022/control_loops/superstructure/BUILD
+++ b/y2022/control_loops/superstructure/BUILD
@@ -177,3 +177,36 @@
"//aos/network/www:proxy",
],
)
+
+ts_library(
+ name = "intake_plotter",
+ srcs = ["intake_plotter.ts"],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ "//aos/network/www:aos_plotter",
+ "//aos/network/www:colors",
+ "//aos/network/www:proxy",
+ ],
+)
+
+ts_library(
+ name = "turret_plotter",
+ srcs = ["turret_plotter.ts"],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ "//aos/network/www:aos_plotter",
+ "//aos/network/www:colors",
+ "//aos/network/www:proxy",
+ ],
+)
+
+ts_library(
+ name = "climber_plotter",
+ srcs = ["climber_plotter.ts"],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ "//aos/network/www:aos_plotter",
+ "//aos/network/www:colors",
+ "//aos/network/www:proxy",
+ ],
+)
diff --git a/y2022/control_loops/superstructure/climber_plotter.ts b/y2022/control_loops/superstructure/climber_plotter.ts
new file mode 100644
index 0000000..e24a993
--- /dev/null
+++ b/y2022/control_loops/superstructure/climber_plotter.ts
@@ -0,0 +1,46 @@
+// Provides a plot for debugging robot state-related issues.
+import {AosPlotter} from 'org_frc971/aos/network/www/aos_plotter';
+import * as proxy from 'org_frc971/aos/network/www/proxy';
+import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE, ORANGE} from 'org_frc971/aos/network/www/colors';
+
+import Connection = proxy.Connection;
+
+const TIME = AosPlotter.TIME;
+const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH * 5 / 2;
+const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
+
+export function plotClimber(conn: Connection, element: Element) : void {
+ const aosPlotter = new AosPlotter(conn);
+ const goal = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Goal');
+ const output = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Output');
+ const status = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Status');
+ const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
+
+ // Robot Enabled/Disabled and Mode
+ const positionPlot =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ positionPlot.plot.getAxisLabels().setTitle('Position');
+ positionPlot.plot.getAxisLabels().setXLabel(TIME);
+ positionPlot.plot.getAxisLabels().setYLabel('rad');
+ positionPlot.plot.setDefaultYRange([-1.0, 2.0]);
+
+ positionPlot.addMessageLine(status, ['climber', 'position']).setColor(GREEN).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['climber', 'velocity']).setColor(PINK).setPointSize(1.0);
+ positionPlot.addMessageLine(status, ['climber', 'goal_position']).setColor(RED).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['climber', 'goal_velocity']).setColor(ORANGE).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['climber', 'estimator_state', 'position']).setColor(CYAN).setPointSize(1.0);
+
+ const voltagePlot =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ voltagePlot.plot.getAxisLabels().setTitle('Voltage');
+ voltagePlot.plot.getAxisLabels().setXLabel(TIME);
+ voltagePlot.plot.getAxisLabels().setYLabel('Volts');
+ voltagePlot.plot.setDefaultYRange([-4.0, 14.0]);
+
+ voltagePlot.addMessageLine(output, ['climber_voltage']).setColor(BLUE).setPointSize(4.0);
+ voltagePlot.addMessageLine(status, ['climber', 'voltage_error']).setColor(RED).setPointSize(1.0);
+ voltagePlot.addMessageLine(status, ['climber', 'position_power']).setColor(BROWN).setPointSize(1.0);
+ voltagePlot.addMessageLine(status, ['climber', 'velocity_power']).setColor(CYAN).setPointSize(1.0);
+ voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(1.0);
+
+}
diff --git a/y2022/control_loops/superstructure/intake_plotter.ts b/y2022/control_loops/superstructure/intake_plotter.ts
new file mode 100644
index 0000000..8667473
--- /dev/null
+++ b/y2022/control_loops/superstructure/intake_plotter.ts
@@ -0,0 +1,72 @@
+// Provides a plot for debugging robot state-related issues.
+import {AosPlotter} from 'org_frc971/aos/network/www/aos_plotter';
+import * as proxy from 'org_frc971/aos/network/www/proxy';
+import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE, ORANGE} from 'org_frc971/aos/network/www/colors';
+
+import Connection = proxy.Connection;
+
+const TIME = AosPlotter.TIME;
+const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH * 5 / 2;
+const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
+
+export function plotIntake(conn: Connection, element: Element) : void {
+ const aosPlotter = new AosPlotter(conn);
+ const goal = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Goal');
+ const output = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Output');
+ const status = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Status');
+ const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
+
+ // Robot Enabled/Disabled and Mode
+ const positionPlotFront =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ positionPlotFront.plot.getAxisLabels().setTitle('Position');
+ positionPlotFront.plot.getAxisLabels().setXLabel(TIME);
+ positionPlotFront.plot.getAxisLabels().setYLabel('rad');
+ positionPlotFront.plot.setDefaultYRange([-1.0, 2.0]);
+
+ positionPlotFront.addMessageLine(status, ['intake_front', 'position']).setColor(GREEN).setPointSize(4.0);
+ positionPlotFront.addMessageLine(status, ['intake_front', 'velocity']).setColor(PINK).setPointSize(1.0);
+ positionPlotFront.addMessageLine(status, ['intake_front', 'goal_position']).setColor(RED).setPointSize(4.0);
+ positionPlotFront.addMessageLine(status, ['intake_front', 'goal_velocity']).setColor(ORANGE).setPointSize(4.0);
+ positionPlotFront.addMessageLine(status, ['intake_front', 'estimator_state', 'position']).setColor(CYAN).setPointSize(1.0);
+
+ const positionPlotBack =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ positionPlotBack.plot.getAxisLabels().setTitle('Position');
+ positionPlotBack.plot.getAxisLabels().setXLabel(TIME);
+ positionPlotBack.plot.getAxisLabels().setYLabel('rad');
+ positionPlotBack.plot.setDefaultYRange([-1.0, 2.0]);
+
+ positionPlotBack.addMessageLine(status, ['intake_back', 'position']).setColor(GREEN).setPointSize(4.0);
+ positionPlotBack.addMessageLine(status, ['intake_back', 'velocity']).setColor(PINK).setPointSize(1.0);
+ positionPlotBack.addMessageLine(status, ['intake_back', 'goal_position']).setColor(RED).setPointSize(4.0);
+ positionPlotBack.addMessageLine(status, ['intake_back', 'goal_velocity']).setColor(ORANGE).setPointSize(4.0);
+ positionPlotBack.addMessageLine(status, ['intake_back', 'estimator_state', 'position']).setColor(CYAN).setPointSize(1.0);
+
+ const voltagePlotFront =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ voltagePlotFront.plot.getAxisLabels().setTitle('Voltage');
+ voltagePlotFront.plot.getAxisLabels().setXLabel(TIME);
+ voltagePlotFront.plot.getAxisLabels().setYLabel('Volts');
+ voltagePlotFront.plot.setDefaultYRange([-4.0, 14.0]);
+
+ voltagePlotFront.addMessageLine(output, ['intake_front_voltage']).setColor(BLUE).setPointSize(4.0);
+ voltagePlotFront.addMessageLine(status, ['intake_front', 'voltage_error']).setColor(RED).setPointSize(1.0);
+ voltagePlotFront.addMessageLine(status, ['intake_front', 'position_power']).setColor(BROWN).setPointSize(1.0);
+ voltagePlotFront.addMessageLine(status, ['intake_front', 'velocity_power']).setColor(CYAN).setPointSize(1.0);
+ voltagePlotFront.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(1.0);
+
+
+ const voltagePlotBack =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ voltagePlotBack.plot.getAxisLabels().setTitle('Voltage');
+ voltagePlotBack.plot.getAxisLabels().setXLabel(TIME);
+ voltagePlotBack.plot.getAxisLabels().setYLabel('Volts');
+ voltagePlotBack.plot.setDefaultYRange([-4.0, 14.0]);
+
+ voltagePlotBack.addMessageLine(output, ['intake_back_voltage']).setColor(BLUE).setPointSize(4.0);
+ voltagePlotBack.addMessageLine(status, ['intake_back', 'voltage_error']).setColor(RED).setPointSize(1.0);
+ voltagePlotBack.addMessageLine(status, ['intake_back', 'position_power']).setColor(BROWN).setPointSize(1.0);
+ voltagePlotBack.addMessageLine(status, ['intake_back', 'velocity_power']).setColor(CYAN).setPointSize(1.0);
+ voltagePlotBack.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(1.0);
+}
diff --git a/y2022/control_loops/superstructure/turret_plotter.ts b/y2022/control_loops/superstructure/turret_plotter.ts
new file mode 100644
index 0000000..10fc10e
--- /dev/null
+++ b/y2022/control_loops/superstructure/turret_plotter.ts
@@ -0,0 +1,46 @@
+// Provides a plot for debugging robot state-related issues.
+import {AosPlotter} from 'org_frc971/aos/network/www/aos_plotter';
+import * as proxy from 'org_frc971/aos/network/www/proxy';
+import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE, ORANGE} from 'org_frc971/aos/network/www/colors';
+
+import Connection = proxy.Connection;
+
+const TIME = AosPlotter.TIME;
+const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH * 5 / 2;
+const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
+
+export function plotTurret(conn: Connection, element: Element) : void {
+ const aosPlotter = new AosPlotter(conn);
+ const goal = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Goal');
+ const output = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Output');
+ const status = aosPlotter.addMessageSource('/superstructure', 'y2022.control_loops.superstructure.Status');
+ const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
+
+ // Robot Enabled/Disabled and Mode
+ const positionPlot =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ positionPlot.plot.getAxisLabels().setTitle('Position');
+ positionPlot.plot.getAxisLabels().setXLabel(TIME);
+ positionPlot.plot.getAxisLabels().setYLabel('rad');
+ positionPlot.plot.setDefaultYRange([-1.0, 2.0]);
+
+ positionPlot.addMessageLine(status, ['turret', 'position']).setColor(GREEN).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['turret', 'velocity']).setColor(PINK).setPointSize(1.0);
+ positionPlot.addMessageLine(status, ['turret', 'goal_position']).setColor(RED).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['turret', 'goal_velocity']).setColor(ORANGE).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['turret', 'estimator_state', 'position']).setColor(CYAN).setPointSize(1.0);
+
+ const voltagePlot =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ voltagePlot.plot.getAxisLabels().setTitle('Voltage');
+ voltagePlot.plot.getAxisLabels().setXLabel(TIME);
+ voltagePlot.plot.getAxisLabels().setYLabel('Volts');
+ voltagePlot.plot.setDefaultYRange([-4.0, 14.0]);
+
+ voltagePlot.addMessageLine(output, ['turret_voltage']).setColor(BLUE).setPointSize(4.0);
+ voltagePlot.addMessageLine(status, ['turret', 'voltage_error']).setColor(RED).setPointSize(1.0);
+ voltagePlot.addMessageLine(status, ['turret', 'position_power']).setColor(BROWN).setPointSize(1.0);
+ voltagePlot.addMessageLine(status, ['turret', 'velocity_power']).setColor(CYAN).setPointSize(1.0);
+ voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(1.0);
+
+}