Merge changes Iaf5b2c03,I7f579129,I0572a214,Id496b032
* changes:
scouting: Allow the requests handler access to the database
Move scouting/db.go into its own directory
Handle webserver requests from the scouting web page
Create a library for serving static files
diff --git a/WORKSPACE b/WORKSPACE
index 9c4529b..acda914 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -657,8 +657,6 @@
path = "third_party/ceres",
)
-# TODO(austin): Update!
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/api-cpp/5.18.1/.
http_archive(
name = "ctre_phoenix_api_cpp_headers",
build_file_content = """
@@ -668,71 +666,36 @@
hdrs = glob(['ctre/phoenix/**/*.h']),
)
""",
- sha256 = "230ff927e36b2f75e746da0f0bf9852e5a049bb3e95c4617138ef0618b2e80d9",
+ sha256 = "ea4131d1809bc8ccbd72b15cc7a65bd6ebb89a65019afc6a336e2c92d91ec824",
urls = [
- "https://www.frc971.org/Build-Dependencies/api-cpp-5.18.1-headers.zip",
+ "http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/api-cpp/5.21.1/api-cpp-5.21.1-headers.zip",
],
)
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/api-cpp/5.18.1/.
http_archive(
name = "ctre_phoenix_api_cpp_athena",
build_file_content = """
+filegroup(
+ name = 'shared_libraries',
+ srcs = [
+ 'linux/athena/shared/libCTRE_Phoenix.so',
+ ],
+ visibility = ['//visibility:public'],
+)
+
cc_library(
name = 'api-cpp',
visibility = ['//visibility:public'],
- srcs = ['linux/athena/static/libCTRE_Phoenix.a'],
+ srcs = ['linux/athena/shared/libCTRE_Phoenix.so'],
target_compatible_with = ['@//tools/platforms/hardware:roborio'],
- deps = [
- '@ctre_phoenix_core_headers//:core',
- '@ctre_phoenix_core_athena//:core',
- ],
)
""",
- sha256 = "a4de1930e1e946e1c72c13ee272dae38c12c4b7b85b44477dbb67312724d96b1",
+ sha256 = "328130012a0fc1050c3ff09f30a2adf5106d15accc3d850b744fa60ec635a462",
urls = [
- "https://www.frc971.org/Build-Dependencies/api-cpp-5.18.1-linuxathenastatic.zip",
+ "http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/api-cpp/5.21.1/api-cpp-5.21.1-linuxathena.zip",
],
)
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/diagnostics/5.18.1/.
-http_archive(
- name = "ctre_phoenix_diagnostics_headers",
- build_file_content = """
-cc_library(
- name = 'diagnostics',
- visibility = ['//visibility:public'],
- hdrs = glob(['ctre/phoenix/**/*.h']),
-)
-""",
- sha256 = "a94bff6c241de8dc2396a1cece9e2822fe4a7e4980aedaaea682c3e8c5de008c",
- urls = [
- "https://www.frc971.org/Build-Dependencies/diagnostics-5.18.1-headers.zip",
- ],
-)
-
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/diagnostics/5.18.1/.
-http_archive(
- name = "ctre_phoenix_diagnostics_athena",
- build_file_content = """
-cc_library(
- name = 'diagnostics',
- visibility = ['//visibility:public'],
- srcs = ['linux/athena/static/libCTRE_PhoenixDiagnostics.a'],
- target_compatible_with = ['@//tools/platforms/hardware:roborio'],
- deps = [
- '@ctre_phoenix_core_headers//:core',
- '@ctre_phoenix_core_athena//:core',
- ],
-)
-""",
- sha256 = "638a4a4d7400942baa040619ea6cde2bdef0e7721300a9427424a577ce0f56db",
- urls = [
- "https://www.frc971.org/Build-Dependencies/diagnostics-5.18.1-linuxathenastatic.zip",
- ],
-)
-
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/cci/5.18.1/.
http_archive(
name = "ctre_phoenix_cci_headers",
build_file_content = """
@@ -742,59 +705,33 @@
hdrs = glob(['ctre/phoenix/**/*.h']),
)
""",
- sha256 = "31e4d8f7fd9612ba687661e19aabc3d89dc076f66756d4696aa7799f31bbc72f",
+ sha256 = "b3332885c6afe082f9f67c2335086e89f705b6ac6c5101188616f81c58d3e49a",
urls = [
- "https://www.frc971.org/Build-Dependencies/cci-5.18.1-headers.zip",
+ "http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/cci/5.21.1/cci-5.21.1-headers.zip",
],
)
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/cci/5.18.1/.
http_archive(
name = "ctre_phoenix_cci_athena",
build_file_content = """
+filegroup(
+ name = 'shared_libraries',
+ srcs = [
+ 'linux/athena/shared/libCTRE_PhoenixCCI.so',
+ ],
+ visibility = ['//visibility:public'],
+)
+
cc_library(
name = 'cci',
visibility = ['//visibility:public'],
- srcs = ['linux/athena/static/libCTRE_PhoenixCCI.a'],
+ srcs = ['linux/athena/shared/libCTRE_PhoenixCCI.so'],
target_compatible_with = ['@//tools/platforms/hardware:roborio'],
)
""",
- sha256 = "e5d9b58072002dbd2daa8cc8d42e047e5c90d26bd5a2b1d63dc1b89112ac3837",
+ sha256 = "94812541734d7905774d97e10a97e9c79b5c37cba60d9b6b2d6e4bf3bbabc2fb",
urls = [
- "https://www.frc971.org/Build-Dependencies/cci-5.18.1-linuxathenastatic.zip",
- ],
-)
-
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/core/5.18.1/.
-http_archive(
- name = "ctre_phoenix_core_headers",
- build_file_content = """
-cc_library(
- name = 'core',
- visibility = ['//visibility:public'],
- hdrs = glob(['ctre/phoenix/**/*.h']),
-)
-""",
- sha256 = "af2db0f9c3693cbb74216882ee140e4d6b722a416f2d384062378a8ae37f65ee",
- urls = [
- "https://www.frc971.org/Build-Dependencies/core-5.18.1-headers.zip",
- ],
-)
-
-# Downloaded from http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/core/5.18.1/.
-http_archive(
- name = "ctre_phoenix_core_athena",
- build_file_content = """
-cc_library(
- name = 'core',
- visibility = ['//visibility:public'],
- srcs = ['linux/athena/static/libCTRE_PhoenixCore.a'],
- target_compatible_with = ['@//tools/platforms/hardware:roborio'],
-)
-""",
- sha256 = "cd827bc68c0f4ef2fe6c363a7f9f5a08f7d944b574c65a2c7fb823686501f43f",
- urls = [
- "https://www.frc971.org/Build-Dependencies/core-5.18.1-linuxathenastatic.zip",
+ "http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/cci/5.21.1/cci-5.21.1-linuxathena.zip",
],
)
diff --git a/aos/starter/starter.sh b/aos/starter/starter.sh
index f18dfda..d5812c2 100755
--- a/aos/starter/starter.sh
+++ b/aos/starter/starter.sh
@@ -5,6 +5,12 @@
ROBOT_CODE="/home/admin/robot_code"
+ # Get the CTRE libraries in the shared library search path
+ for f in $(ls *.so);
+ do
+ ln -f -s /home/admin/robot_code/$f /usr/local/frc/third-party/lib/$f
+ done
+
ln -s /var/local/natinst/log/FRC_UserProgram.log /tmp/FRC_UserProgram.log
ln -s /var/local/natinst/log/FRC_UserProgram.log "${ROBOT_CODE}/FRC_UserProgram.log"
elif [[ "$(hostname)" == "pi-"* ]]; then
diff --git a/frc971/analysis/BUILD b/frc971/analysis/BUILD
index 82f397c..0c87ef4 100644
--- a/frc971/analysis/BUILD
+++ b/frc971/analysis/BUILD
@@ -53,6 +53,7 @@
"//y2020/control_loops/superstructure:turret_plotter",
"//y2021_bot3/control_loops/superstructure:superstructure_plotter",
"//y2022/control_loops/localizer:localizer_plotter",
+ "//y2022/control_loops/superstructure:catapult_plotter",
],
)
diff --git a/frc971/analysis/plot_index.ts b/frc971/analysis/plot_index.ts
index a5203b0..4235ba9 100644
--- a/frc971/analysis/plot_index.ts
+++ b/frc971/analysis/plot_index.ts
@@ -34,6 +34,8 @@
'org_frc971/y2020/control_loops/superstructure/turret_plotter'
import {plotLocalizer as plot2020Localizer} from
'org_frc971/y2020/control_loops/drivetrain/localizer_plotter'
+import {plotCatapult as plot2022Catapult} from
+ 'org_frc971/y2022/control_loops/superstructure/catapult_plotter'
import {plotLocalizer as plot2022Localizer} from
'org_frc971/y2022/control_loops/localizer/localizer_plotter'
import {plotAccelerator} from
@@ -108,6 +110,7 @@
['Turret', new PlotState(plotDiv, plotTurret)],
['2022 Localizer', new PlotState(plotDiv, plot2022Localizer)],
['2020 Localizer', new PlotState(plotDiv, plot2020Localizer)],
+ ['2022 Catapult', new PlotState(plotDiv, plot2022Catapult)],
['C++ Plotter', new PlotState(plotDiv, plotData)],
['Y2021 3rd Robot Superstructure', new PlotState(plotDiv, plotSuperstructure)],
]);
diff --git a/third_party/BUILD b/third_party/BUILD
index aff739f..cff81fd 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -31,8 +31,6 @@
"@ctre_phoenix_api_cpp_headers//:api-cpp",
"@ctre_phoenix_cci_athena//:cci",
"@ctre_phoenix_cci_headers//:cci",
- "@ctre_phoenix_diagnostics_athena//:diagnostics",
- "@ctre_phoenix_diagnostics_headers//:diagnostics",
],
)
diff --git a/tools/dependency_rewrite b/tools/dependency_rewrite
index d5190dd..9fbcd29 100644
--- a/tools/dependency_rewrite
+++ b/tools/dependency_rewrite
@@ -8,6 +8,7 @@
rewrite static.rust-lang.org/(.*) software.frc971.org/Build-Dependencies/static.rust-lang.org/$1
rewrite storage.googleapis.com/(.*) software.frc971.org/Build-Dependencies/storage.googleapis.com/$1
rewrite files.pythonhosted.org/(.*) software.frc971.org/Build-Dependencies/files.pythonhosted.org/$1
+rewrite devsite.ctr-electronics.com/(.*) software.frc971.org/Build-Dependencies/devsite.ctr-electronics.com/$1
allow golang.org
allow software.frc971.org
diff --git a/y2019/BUILD b/y2019/BUILD
index 8c250e0..7d4e233 100644
--- a/y2019/BUILD
+++ b/y2019/BUILD
@@ -6,6 +6,8 @@
robot_downloader(
data = [
":config",
+ "@ctre_phoenix_api_cpp_athena//:shared_libraries",
+ "@ctre_phoenix_cci_athena//:shared_libraries",
],
dirs = [
"//y2019/vision/server:www_files",
diff --git a/y2020/BUILD b/y2020/BUILD
index ee4e628..1e0e4d8 100644
--- a/y2020/BUILD
+++ b/y2020/BUILD
@@ -10,6 +10,8 @@
],
data = [
":config",
+ "@ctre_phoenix_api_cpp_athena//:shared_libraries",
+ "@ctre_phoenix_cci_athena//:shared_libraries",
],
dirs = [
"//y2020/actors:splines",
diff --git a/y2022/BUILD b/y2022/BUILD
index c20f18d..af57a74 100644
--- a/y2022/BUILD
+++ b/y2022/BUILD
@@ -8,6 +8,11 @@
],
data = [
":config",
+ "@ctre_phoenix_api_cpp_athena//:shared_libraries",
+ "@ctre_phoenix_cci_athena//:shared_libraries",
+ ],
+ dirs = [
+ "//y2022/www:www_files",
],
start_binaries = [
"//aos/events/logging:logger_main",
diff --git a/y2022/control_loops/superstructure/BUILD b/y2022/control_loops/superstructure/BUILD
index 9bae7c7..644b53b 100644
--- a/y2022/control_loops/superstructure/BUILD
+++ b/y2022/control_loops/superstructure/BUILD
@@ -1,4 +1,4 @@
-load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
load("@npm//@bazel/typescript:index.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
@@ -35,6 +35,18 @@
],
)
+flatbuffer_ts_library(
+ name = "superstructure_status_ts_fbs",
+ srcs = [
+ "superstructure_status.fbs",
+ ],
+ includes = [
+ "//frc971/control_loops:control_loops_fbs_includes",
+ "//frc971/control_loops:profiled_subsystem_fbs_includes",
+ ],
+ target_compatible_with = ["@platforms//os:linux"],
+)
+
flatbuffer_cc_library(
name = "superstructure_position_fbs",
srcs = [
@@ -115,3 +127,14 @@
"//aos/network/www:proxy",
],
)
+
+ts_library(
+ name = "catapult_plotter",
+ srcs = ["catapult_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/catapult_plotter.ts b/y2022/control_loops/superstructure/catapult_plotter.ts
new file mode 100644
index 0000000..cfa360d
--- /dev/null
+++ b/y2022/control_loops/superstructure/catapult_plotter.ts
@@ -0,0 +1,57 @@
+// 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 plotCatapult(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(goal, ['catapult', 'return_position', 'unsafe_goal']).setColor(BLUE).setPointSize(1.0);
+ positionPlot.addMessageLine(goal, ['catapult', 'fire']).setColor(WHITE).setPointSize(1.0);
+ positionPlot.addMessageLine(status, ['mpc_active']).setColor(WHITE).setPointSize(3.0);
+ positionPlot.addMessageLine(status, ['catapult', 'goal_position']).setColor(RED).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['catapult', 'goal_velocity']).setColor(ORANGE).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['catapult', 'position']).setColor(GREEN).setPointSize(4.0);
+ positionPlot.addMessageLine(status, ['catapult', 'velocity']).setColor(PINK).setPointSize(1.0);
+ positionPlot.addMessageLine(status, ['catapult', 'calculated_velocity']).setColor(BROWN).setPointSize(1.0);
+ positionPlot.addMessageLine(status, ['catapult', '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, ['catapult_voltage']).setColor(BLUE).setPointSize(4.0);
+ voltagePlot.addMessageLine(status, ['catapult', 'voltage_error']).setColor(RED).setPointSize(1.0);
+ voltagePlot.addMessageLine(status, ['catapult', 'position_power']).setColor(BROWN).setPointSize(1.0);
+ voltagePlot.addMessageLine(status, ['catapult', 'velocity_power']).setColor(CYAN).setPointSize(1.0);
+ voltagePlot.addMessageLine(robotState, ['voltage_battery']).setColor(GREEN).setPointSize(1.0);
+
+ const solvePlot =
+ aosPlotter.addPlot(element, [DEFAULT_WIDTH, DEFAULT_HEIGHT / 2]);
+ solvePlot.plot.getAxisLabels().setTitle('Solve Time');
+ solvePlot.plot.getAxisLabels().setXLabel(TIME);
+ solvePlot.plot.getAxisLabels().setYLabel('Seconds');
+ solvePlot.plot.setDefaultYRange([-0.0005, 0.001]);
+ solvePlot.addMessageLine(status, ['solve_time']).setColor(WHITE).setPointSize(4.0);
+}
diff --git a/y2022/www/BUILD b/y2022/www/BUILD
new file mode 100644
index 0000000..55cbde2
--- /dev/null
+++ b/y2022/www/BUILD
@@ -0,0 +1,21 @@
+load("//frc971/downloader:downloader.bzl", "aos_downloader_dir")
+
+filegroup(
+ name = "files",
+ srcs = glob([
+ "**/*.html",
+ "**/*.css",
+ ]),
+ visibility = ["//visibility:public"],
+)
+
+aos_downloader_dir(
+ name = "www_files",
+ srcs = [
+ ":files",
+ "//frc971/analysis:plot_index_bundle.min.js",
+ ],
+ dir = "www",
+ target_compatible_with = ["@platforms//os:linux"],
+ visibility = ["//visibility:public"],
+)
diff --git a/y2022/www/index.html b/y2022/www/index.html
new file mode 100644
index 0000000..70442f9
--- /dev/null
+++ b/y2022/www/index.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <a href="plotter.html">Plots</a>
+ </body>
+</html>
diff --git a/y2022/www/plotter.html b/y2022/www/plotter.html
new file mode 100644
index 0000000..629ceaa
--- /dev/null
+++ b/y2022/www/plotter.html
@@ -0,0 +1,7 @@
+<html>
+ <head>
+ <script src="plot_index_bundle.min.js" defer></script>
+ </head>
+ <body>
+ </body>
+</html>
diff --git a/y2022/www/styles.css b/y2022/www/styles.css
new file mode 100644
index 0000000..c486115
--- /dev/null
+++ b/y2022/www/styles.css
@@ -0,0 +1,81 @@
+.channel {
+ display: flex;
+ border-bottom: 1px solid;
+ font-size: 24px;
+}
+#field {
+ display: inline-block
+}
+
+#targets,
+#readouts,
+#vision_readouts {
+ display: inline-block;
+ vertical-align: top;
+ float: right;
+}
+
+#legend {
+ display: inline-block;
+}
+
+#outer_target {
+ border: 1px solid black;
+ width: 140px;
+ background-color: white;
+}
+
+#inner_target {
+ width: 60px;
+ height: 60px;
+ margin: 40px;
+ border: 1px solid black;
+ background-color: white;
+}
+
+#outer_target.targetted,
+#inner_target.targetted {
+ background-color: green;
+}
+
+table, th, td {
+ border: 1px solid black;
+ border-collapse: collapse;
+ padding: 5px;
+ margin: 10px;
+}
+
+th, td {
+ text-align: right;
+ width: 70px;
+}
+
+td:first-child {
+ width: 150px;
+}
+
+.near {
+ background-color: LightGreen;
+ border-radius: 10px;
+}
+
+.zeroing {
+ background-color: yellow;
+ border-radius: 10px;
+}
+
+.faulted {
+ background-color: red;
+ border-radius: 10px;
+}
+
+#vision_readouts > div {
+ display: table-row;
+ padding: 5px;
+}
+
+#vision_readouts > div > div {
+ display: table-cell;
+ padding: 5px;
+ text-align: right;
+}