Add turret plotting webpage
Change-Id: I76260ce740e468e750a9858b041e8271b14ec6ae
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/frc971/analysis/BUILD b/frc971/analysis/BUILD
index 7cb0b4d..2a945bf 100644
--- a/frc971/analysis/BUILD
+++ b/frc971/analysis/BUILD
@@ -50,6 +50,7 @@
"//y2020/control_loops/superstructure:accelerator_plotter",
"//y2020/control_loops/superstructure:finisher_plotter",
"//y2020/control_loops/superstructure:hood_plotter",
+ "//y2020/control_loops/superstructure:turret_plotter",
],
)
diff --git a/frc971/analysis/plot_index.ts b/frc971/analysis/plot_index.ts
index 56c99fa..8b8c951 100644
--- a/frc971/analysis/plot_index.ts
+++ b/frc971/analysis/plot_index.ts
@@ -30,6 +30,8 @@
'org_frc971/frc971/control_loops/drivetrain/robot_state_plotter'
import {plotFinisher} from
'org_frc971/y2020/control_loops/superstructure/finisher_plotter'
+import {plotTurret} from
+ 'org_frc971/y2020/control_loops/superstructure/turret_plotter'
import {plotAccelerator} from
'org_frc971/y2020/control_loops/superstructure/accelerator_plotter'
import {plotHood} from
@@ -97,6 +99,7 @@
['Finisher', new PlotState(plotDiv, plotFinisher)],
['Accelerator', new PlotState(plotDiv, plotAccelerator)],
['Hood', new PlotState(plotDiv, plotHood)],
+ ['Turret', new PlotState(plotDiv, plotTurret)],
['C++ Plotter', new PlotState(plotDiv, plotData)],
]);
diff --git a/y2020/control_loops/superstructure/BUILD b/y2020/control_loops/superstructure/BUILD
index 5ea681c..2d47cf4 100644
--- a/y2020/control_loops/superstructure/BUILD
+++ b/y2020/control_loops/superstructure/BUILD
@@ -150,6 +150,17 @@
)
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 = "finisher_plotter",
srcs = ["finisher_plotter.ts"],
target_compatible_with = ["@platforms//os:linux"],
diff --git a/y2020/control_loops/superstructure/turret_plotter.ts b/y2020/control_loops/superstructure/turret_plotter.ts
new file mode 100644
index 0000000..3d975d8
--- /dev/null
+++ b/y2020/control_loops/superstructure/turret_plotter.ts
@@ -0,0 +1,86 @@
+// 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} from 'org_frc971/aos/network/www/colors';
+
+import Connection = proxy.Connection;
+
+const TIME = AosPlotter.TIME;
+const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH;
+const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT;
+
+export function plotTurret(conn: Connection, element: Element) : void {
+ const aosPlotter = new AosPlotter(conn);
+ const goal = aosPlotter.addMessageSource('/superstructure', 'y2020.control_loops.superstructure.Goal');
+ const output = aosPlotter.addMessageSource('/superstructure', 'y2020.control_loops.superstructure.Output');
+ const status = aosPlotter.addMessageSource(
+ '/superstructure', 'y2020.control_loops.superstructure.Status');
+ const pdpValues =
+ aosPlotter.addMessageSource('/roborio/aos', 'frc971.PDPValues');
+
+ var currentTop = 0;
+
+ const turretPosPlot = aosPlotter.addPlot(
+ element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT]);
+ currentTop += DEFAULT_HEIGHT;
+ turretPosPlot.plot.getAxisLabels().setTitle('Turret Goal Position');
+ turretPosPlot.plot.getAxisLabels().setXLabel(TIME);
+ turretPosPlot.plot.getAxisLabels().setYLabel('rad');
+
+ turretPosPlot.addMessageLine(status, ['aimer', 'turret_position'])
+ .setColor(RED)
+ .setPointSize(0.0);
+ turretPosPlot.addMessageLine(status, ['turret', 'position'])
+ .setColor(GREEN)
+ .setPointSize(0.0);
+ turretPosPlot.addMessageLine(status, ['turret', 'unprofiled_goal_position'])
+ .setColor(BLUE)
+ .setPointSize(0.0);
+
+ const turretVoltagePlot = aosPlotter.addPlot(
+ element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT]);
+ currentTop += DEFAULT_HEIGHT;
+ turretVoltagePlot.plot.getAxisLabels().setTitle('Turret Voltage');
+ turretVoltagePlot.plot.getAxisLabels().setXLabel(TIME);
+ turretVoltagePlot.plot.getAxisLabels().setYLabel('V');
+
+ turretVoltagePlot.addMessageLine(output, ['turret_voltage'])
+ .setColor(RED)
+ .setPointSize(0.0);
+
+ const currentPlot = aosPlotter.addPlot(
+ element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT]);
+ currentTop += DEFAULT_HEIGHT;
+ currentPlot.plot.getAxisLabels().setTitle('Current');
+ currentPlot.plot.getAxisLabels().setXLabel(TIME);
+ currentPlot.plot.getAxisLabels().setYLabel('Amps');
+ currentPlot.plot.setDefaultYRange([0.0, 80.0]);
+
+ currentPlot.addMessageLine(pdpValues, ['currents[6]'])
+ .setColor(GREEN)
+ .setPointSize(0.0);
+
+
+ const targetDistancePlot = aosPlotter.addPlot(
+ element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT]);
+ currentTop += DEFAULT_HEIGHT;
+ targetDistancePlot.plot.getAxisLabels().setTitle('Target distance');
+ targetDistancePlot.plot.getAxisLabels().setXLabel(TIME);
+ targetDistancePlot.plot.getAxisLabels().setYLabel('m');
+
+ targetDistancePlot.addMessageLine(status, ['aimer', 'target_distance'])
+ .setColor(RED)
+ .setPointSize(0.0);
+
+ const targetChoicePlot = aosPlotter.addPlot(
+ element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT]);
+ currentTop += DEFAULT_HEIGHT;
+ targetChoicePlot.plot.getAxisLabels().setTitle('Target choice');
+ targetChoicePlot.plot.getAxisLabels().setXLabel(TIME);
+ targetChoicePlot.plot.getAxisLabels().setYLabel('[bool]');
+ targetChoicePlot.plot.setDefaultYRange([-0.05, 1.05]);
+
+ targetChoicePlot.addMessageLine(status, ['aimer', 'aiming_for_inner_port'])
+ .setColor(RED)
+ .setPointSize(0.0);
+}