Add plotters for the accelerator and finisher
These are what we used to tune them.
Change-Id: Ib492b717e38043a73c2d98e93c885d82df1513b6
diff --git a/aos/network/www/plotter.ts b/aos/network/www/plotter.ts
index 4c73a65..b4fc2eb 100644
--- a/aos/network/www/plotter.ts
+++ b/aos/network/www/plotter.ts
@@ -72,9 +72,10 @@
return this._color;
}
- setColor(newColor: number[]) {
+ setColor(newColor: number[]): Line {
this._color = newColor;
this._hasUpdate = true;
+ return this;
}
// Get/set the size of the markers to draw, in pixels (zero means no markers).
@@ -82,9 +83,10 @@
return this._pointSize;
}
- setPointSize(size: number) {
+ setPointSize(size: number): Line {
this._pointSize = size;
this._hasUpdate = true;
+ return this;
}
// Get/set whether we draw a line between the points (i.e., setting this to
diff --git a/frc971/analysis/BUILD b/frc971/analysis/BUILD
index b72634a..f040f5d 100644
--- a/frc971/analysis/BUILD
+++ b/frc971/analysis/BUILD
@@ -82,6 +82,8 @@
"//frc971/control_loops/drivetrain:drivetrain_plotter",
"//frc971/control_loops/drivetrain:robot_state_plotter",
"//frc971/wpilib:imu_plotter",
+ "//y2020/control_loops/superstructure:accelerator_plotter",
+ "//y2020/control_loops/superstructure:finisher_plotter",
],
)
diff --git a/frc971/analysis/plot_index.ts b/frc971/analysis/plot_index.ts
index 780f944..812c245 100644
--- a/frc971/analysis/plot_index.ts
+++ b/frc971/analysis/plot_index.ts
@@ -26,6 +26,10 @@
import {plotDrivetrain} from 'org_frc971/frc971/control_loops/drivetrain/drivetrain_plotter';
import {plotRobotState} from
'org_frc971/frc971/control_loops/drivetrain/robot_state_plotter'
+import {plotFinisher} from
+ 'org_frc971/y2020/control_loops/superstructure/finisher_plotter'
+import {plotAccelerator} from
+ 'org_frc971/y2020/control_loops/superstructure/accelerator_plotter'
import {plotDemo} from 'org_frc971/aos/network/www/demo_plot';
import {plotData} from 'org_frc971/frc971/analysis/plot_data_utils';
@@ -84,6 +88,8 @@
['IMU', new PlotState(plotDiv, plotImu)],
['Drivetrain', new PlotState(plotDiv, plotDrivetrain)],
['Robot State', new PlotState(plotDiv, plotRobotState)],
+ ['Finisher', new PlotState(plotDiv, plotFinisher)],
+ ['Accelerator', new PlotState(plotDiv, plotAccelerator)],
['C++ Plotter', new PlotState(plotDiv, plotData)],
]);
diff --git a/y2020/control_loops/superstructure/BUILD b/y2020/control_loops/superstructure/BUILD
index 3ea3dbf..885bf78 100644
--- a/y2020/control_loops/superstructure/BUILD
+++ b/y2020/control_loops/superstructure/BUILD
@@ -1,6 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+load("@npm_bazel_typescript//:defs.bzl", "ts_library")
flatbuffer_cc_library(
name = "superstructure_goal_fbs",
@@ -135,3 +136,23 @@
"//frc971/control_loops:profiled_subsystem_fbs",
],
)
+
+ts_library(
+ name = "finisher_plotter",
+ srcs = ["finisher_plotter.ts"],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ "//aos/network/www:aos_plotter",
+ "//aos/network/www:proxy",
+ ],
+)
+
+ts_library(
+ name = "accelerator_plotter",
+ srcs = ["accelerator_plotter.ts"],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ "//aos/network/www:aos_plotter",
+ "//aos/network/www:proxy",
+ ],
+)
diff --git a/y2020/control_loops/superstructure/accelerator_plotter.ts b/y2020/control_loops/superstructure/accelerator_plotter.ts
new file mode 100644
index 0000000..4949933
--- /dev/null
+++ b/y2020/control_loops/superstructure/accelerator_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 Connection = proxy.Connection;
+
+const TIME = AosPlotter.TIME;
+const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH;
+const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
+const RED = AosPlotter.RED;
+const GREEN = AosPlotter.GREEN;
+const BLUE = AosPlotter.BLUE;
+const BROWN = AosPlotter.BROWN;
+const PINK = AosPlotter.PINK;
+const CYAN = AosPlotter.CYAN;
+const WHITE = AosPlotter.WHITE;
+
+export function plotAccelerator(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');
+ const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
+
+ var currentTop = 0;
+
+ // Robot Enabled/Disabled and Mode
+ const velocityPlot =
+ aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ currentTop += DEFAULT_HEIGHT / 2;
+ velocityPlot.plot.getAxisLabels().setTitle('Velocity');
+ velocityPlot.plot.getAxisLabels().setXLabel(TIME);
+ velocityPlot.plot.getAxisLabels().setYLabel('rad/s');
+ velocityPlot.plot.setDefaultYRange([0.0, 450.0]);
+
+ velocityPlot.addMessageLine(goal, ['shooter', 'velocity_accelerator']).setColor(BLUE).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'accelerator_left', 'avg_angular_velocity']).setColor(RED).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'accelerator_right', 'avg_angular_velocity']).setColor(PINK).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'accelerator_left', 'angular_velocity']).setColor(GREEN).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'accelerator_right', 'angular_velocity']).setColor(CYAN).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'accelerator_left', 'dt_angular_velocity']).setColor(PINK).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'accelerator_right', 'dt_angular_velocity']).setColor(BLUE).setPointSize(0.0);
+
+ const voltagePlot =
+ aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ currentTop += DEFAULT_HEIGHT / 2;
+ voltagePlot.plot.getAxisLabels().setTitle('Voltage');
+ voltagePlot.plot.getAxisLabels().setXLabel(TIME);
+ voltagePlot.plot.getAxisLabels().setYLabel('Volts');
+ voltagePlot.plot.setDefaultYRange([-4.0, 16.0]);
+
+ voltagePlot.addMessageLine(output, ['accelerator_left_voltage']).setColor(BLUE).setPointSize(0.0);
+ voltagePlot.addMessageLine(output, ['accelerator_right_voltage']).setColor(BROWN).setPointSize(0.0);
+ voltagePlot.addMessageLine(status, ['shooter', 'accelerator_left', 'voltage_error']).setColor(RED).setPointSize(0.0);
+ voltagePlot.addMessageLine(status, ['shooter', 'accelerator_right', 'voltage_error']).setColor(PINK).setPointSize(0.0);
+ voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(0.0);
+
+
+ const currentPlot =
+ aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ currentTop += DEFAULT_HEIGHT / 2;
+ 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[14]']).setColor(GREEN).setPointSize(0.0);
+ currentPlot.addMessageLine(pdpValues, ['currents[15]']).setColor(BLUE).setPointSize(0.0);
+ currentPlot.addMessageLine(status, ['shooter', 'accelerator_left', 'commanded_current']).setColor(RED).setPointSize(0.0);
+ currentPlot.addMessageLine(status, ['shooter', 'accelerator_right', 'commanded_current']).setColor(PINK).setPointSize(0.0);
+}
diff --git a/y2020/control_loops/superstructure/finisher_plotter.ts b/y2020/control_loops/superstructure/finisher_plotter.ts
new file mode 100644
index 0000000..8948ac8
--- /dev/null
+++ b/y2020/control_loops/superstructure/finisher_plotter.ts
@@ -0,0 +1,66 @@
+// 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 Connection = proxy.Connection;
+
+const TIME = AosPlotter.TIME;
+const DEFAULT_WIDTH = AosPlotter.DEFAULT_WIDTH;
+const DEFAULT_HEIGHT = AosPlotter.DEFAULT_HEIGHT * 3;
+const RED = AosPlotter.RED;
+const GREEN = AosPlotter.GREEN;
+const BLUE = AosPlotter.BLUE;
+const BROWN = AosPlotter.BROWN;
+const PINK = AosPlotter.PINK;
+const CYAN = AosPlotter.CYAN;
+const WHITE = AosPlotter.WHITE;
+
+export function plotFinisher(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');
+ const robotState = aosPlotter.addMessageSource('/aos', 'aos.RobotState');
+
+ var currentTop = 0;
+
+ // Robot Enabled/Disabled and Mode
+ const velocityPlot =
+ aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ currentTop += DEFAULT_HEIGHT / 2;
+ velocityPlot.plot.getAxisLabels().setTitle('Velocity');
+ velocityPlot.plot.getAxisLabels().setXLabel(TIME);
+ velocityPlot.plot.getAxisLabels().setYLabel('rad/s');
+ velocityPlot.plot.setDefaultYRange([0.0, 450.0]);
+
+ velocityPlot.addMessageLine(goal, ['shooter', 'velocity_finisher']).setColor(BLUE).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'avg_angular_velocity']).setColor(RED).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'angular_velocity']).setColor(GREEN).setPointSize(0.0);
+ velocityPlot.addMessageLine(status, ['shooter', 'finisher', 'dt_angular_velocity']).setColor(PINK).setPointSize(0.0);
+
+ const voltagePlot =
+ aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ currentTop += DEFAULT_HEIGHT / 2;
+ voltagePlot.plot.getAxisLabels().setTitle('Voltage');
+ voltagePlot.plot.getAxisLabels().setXLabel(TIME);
+ voltagePlot.plot.getAxisLabels().setYLabel('Volts');
+ voltagePlot.plot.setDefaultYRange([-4.0, 16.0]);
+
+ voltagePlot.addMessageLine(output, ['finisher_voltage']).setColor(BLUE).setPointSize(0.0);
+ voltagePlot.addMessageLine(status, ['shooter', 'finisher', 'voltage_error']).setColor(RED).setPointSize(0.0);
+ voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(0.0);
+
+
+ const currentPlot =
+ aosPlotter.addPlot(element, [0, currentTop], [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ currentTop += DEFAULT_HEIGHT / 2;
+ 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[12]']).setColor(GREEN).setPointSize(0.0);
+ currentPlot.addMessageLine(pdpValues, ['currents[13]']).setColor(BLUE).setPointSize(0.0);
+ currentPlot.addMessageLine(status, ['shooter', 'finisher', 'commanded_current']).setColor(RED).setPointSize(0.0);
+}