Enable deploying code for the raspberry pis
Also, sets up a systemd service to start all the code.
Change-Id: If993426b36d0910497579ad86e330699f8a7d2e7
diff --git a/y2020/BUILD b/y2020/BUILD
index 05b9147..f3ea4d6 100644
--- a/y2020/BUILD
+++ b/y2020/BUILD
@@ -8,6 +8,7 @@
":config.json",
],
start_binaries = [
+ "//aos/events/logging:logger_main",
":joystick_reader",
":wpilib_interface",
"//aos/network:message_bridge_client",
@@ -18,6 +19,27 @@
],
)
+robot_downloader(
+ name = "pi_download",
+ data = [
+ ":config.json",
+ "//y2020/www:files",
+ "//y2020/www:flatbuffers",
+ "//y2020/www:main_bundle",
+ ],
+ dirs = [
+ "//y2020/www:www_files",
+ ],
+ restricted_to = ["//tools:armhf-debian"],
+ start_binaries = [
+ "//aos/network:message_bridge_client",
+ "//aos/network:message_bridge_server",
+ "//y2020/vision:camera_reader",
+ "//aos/network:web_proxy_main",
+ ],
+ target_type = "pi",
+)
+
cc_library(
name = "constants",
srcs = [
diff --git a/y2020/control_loops/drivetrain/drivetrain_main.cc b/y2020/control_loops/drivetrain/drivetrain_main.cc
index 7159118..7804814 100644
--- a/y2020/control_loops/drivetrain/drivetrain_main.cc
+++ b/y2020/control_loops/drivetrain/drivetrain_main.cc
@@ -6,7 +6,8 @@
using ::frc971::control_loops::drivetrain::DrivetrainLoop;
-int main() {
+int main(int argc, char *argv[]) {
+ ::aos::InitGoogle(&argc, &argv);
::aos::InitNRT();
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
diff --git a/y2020/control_loops/drivetrain/localizer.cc b/y2020/control_loops/drivetrain/localizer.cc
index 927eec0..4b164b5 100644
--- a/y2020/control_loops/drivetrain/localizer.cc
+++ b/y2020/control_loops/drivetrain/localizer.cc
@@ -115,6 +115,14 @@
aos::monotonic_clock::time_point capture_time(
std::chrono::nanoseconds(result.image_monotonic_timestamp_ns()) -
monotonic_offset);
+ VLOG(1) << "Got monotonic offset of "
+ << aos::time::DurationInSeconds(monotonic_offset)
+ << " when at time of " << event_loop_->monotonic_now()
+ << " and capture time estimate of " << capture_time;
+ if (capture_time > event_loop_->monotonic_now()) {
+ LOG(WARNING) << "Got camera frame from the future.";
+ return;
+ }
CHECK(result.has_camera_calibration());
// Per the ImageMatchResult specification, we can actually determine whether
// the camera is the turret camera just from the presence of the
diff --git a/y2020/vision/rootfs/frc971.service b/y2020/vision/rootfs/frc971.service
new file mode 100644
index 0000000..bf42652
--- /dev/null
+++ b/y2020/vision/rootfs/frc971.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Start up 971 robot code
+
+[Service]
+Type=oneshot
+ExecStart=su pi -c /home/pi/robot_code/starter.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/y2020/vision/rootfs/modify_rootfs.sh b/y2020/vision/rootfs/modify_rootfs.sh
index 239db0a..219590f 100755
--- a/y2020/vision/rootfs/modify_rootfs.sh
+++ b/y2020/vision/rootfs/modify_rootfs.sh
@@ -76,6 +76,7 @@
sudo cp target_configure.sh "${PARTITION}/tmp/"
sudo cp dhcpcd.conf "${PARTITION}/tmp/dhcpcd.conf"
sudo cp change_hostname.sh "${PARTITION}/tmp/change_hostname.sh"
+sudo cp frc971.service "${PARTITION}/etc/systemd/system/frc971.service"
target /bin/mkdir -p /home/pi/.ssh/
cat ~/.ssh/id_rsa.pub | target tee /home/pi/.ssh/authorized_keys
diff --git a/y2020/vision/rootfs/target_configure.sh b/y2020/vision/rootfs/target_configure.sh
index 38d29b9..032764a 100755
--- a/y2020/vision/rootfs/target_configure.sh
+++ b/y2020/vision/rootfs/target_configure.sh
@@ -68,6 +68,7 @@
rm -f /etc/profile.d/wifi-check.sh
systemctl enable ssh.service
+systemctl enable frc971.service
# Default us to pi-8971-1
/root/bin/change_hostname.sh pi-8971-1
diff --git a/y2020/www/BUILD b/y2020/www/BUILD
index c280e91..292618b 100644
--- a/y2020/www/BUILD
+++ b/y2020/www/BUILD
@@ -1,5 +1,6 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle")
+load("//frc971/downloader:downloader.bzl", "aos_downloader_dir")
ts_library(
name = "main",
@@ -44,3 +45,14 @@
cmd = "cp $(location @com_github_google_flatbuffers//:flatjs) $@",
visibility = ["//y2020:__subpackages__"],
)
+
+aos_downloader_dir(
+ name = "www_files",
+ srcs = [
+ ":files",
+ ":flatbuffers",
+ ":main_bundle",
+ ],
+ dir = "www",
+ visibility = ["//visibility:public"],
+)
diff --git a/y2020/y2020.json b/y2020/y2020.json
index 95ee582..0e1a6ba 100644
--- a/y2020/y2020.json
+++ b/y2020/y2020.json
@@ -60,7 +60,7 @@
"name": "/aos/roborio",
"type": "aos.message_bridge.ClientStatistics",
"source_node": "roborio",
- "frequency": 2,
+ "frequency": 10,
"num_senders": 2
},
{
@@ -114,7 +114,7 @@
"name": "/aos/pi1",
"type": "aos.message_bridge.ClientStatistics",
"source_node": "pi1",
- "frequency": 2,
+ "frequency": 10,
"num_senders": 2
},
{
@@ -158,7 +158,7 @@
"name": "/aos/pi2",
"type": "aos.message_bridge.ClientStatistics",
"source_node": "pi2",
- "frequency": 2,
+ "frequency": 10,
"num_senders": 2
},
{
@@ -202,7 +202,7 @@
"name": "/aos/pi3",
"type": "aos.message_bridge.ClientStatistics",
"source_node": "pi3",
- "frequency": 2,
+ "frequency": 10,
"num_senders": 2
},
{