Merge "Add jitter analysis"
diff --git a/aos/ipc_lib/lockless_queue.cc b/aos/ipc_lib/lockless_queue.cc
index a26b564..9d14d8f 100644
--- a/aos/ipc_lib/lockless_queue.cc
+++ b/aos/ipc_lib/lockless_queue.cc
@@ -21,6 +21,7 @@
DEFINE_bool(dump_lockless_queue_data, false,
"If true, print the data out when dumping the queue.");
+DECLARE_bool(skip_realtime_scheduler);
namespace aos::ipc_lib {
namespace {
@@ -813,7 +814,19 @@
// Boost if we are RT and there is a higher priority sender out there.
// Otherwise we might run into priority inversions.
if (max_priority > current_priority && current_priority > 0) {
- SetCurrentThreadRealtimePriority(max_priority);
+ // Inline the setscheduler call rather than using aos/realtime.h. This is
+ // quite performance sensitive, and halves the time needed to send a
+ // message when pi boosting is in effect.
+ if (!FLAGS_skip_realtime_scheduler) {
+ // TODO(austin): Do we need to boost the soft limit here too like we
+ // were before?
+ struct sched_param param;
+ param.sched_priority = max_priority;
+ PCHECK(sched_setscheduler(0, SCHED_FIFO, ¶m) == 0)
+ << ": changing to SCHED_FIFO with " << max_priority
+ << ", if you want to bypass this check for testing, use "
+ "--skip_realtime_scheduler";
+ }
}
// Build up the siginfo to send.
@@ -842,7 +855,14 @@
// Drop back down if we were boosted.
if (max_priority > current_priority && current_priority > 0) {
- SetCurrentThreadRealtimePriority(current_priority);
+ if (!FLAGS_skip_realtime_scheduler) {
+ struct sched_param param;
+ param.sched_priority = current_priority;
+ PCHECK(sched_setscheduler(0, SCHED_FIFO, ¶m) == 0)
+ << ": changing to SCHED_FIFO with " << max_priority
+ << ", if you want to bypass this check for testing, use "
+ "--skip_realtime_scheduler";
+ }
}
}
diff --git a/aos/starter/starter.sh b/aos/starter/starter.sh
index 0215156..dc71cbd 100755
--- a/aos/starter/starter.sh
+++ b/aos/starter/starter.sh
@@ -10,10 +10,18 @@
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-"* || "$(hostname)" == "orin-"* ]]; then
+elif [[ "$(hostname)" == "pi-"* ]]; then
# We have systemd configured to handle restarting, so just exec.
export PATH="${PATH}:/home/pi/bin"
exec starterd --user=pi --purge_shm_base
+elif [[ "$(hostname)" == "orin-"* ]]; then
+ # We have systemd configured to handle restarting, so just exec.
+ export PATH="${PATH}:/home/pi/bin"
+
+ # Turn the fans up.
+ echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1
+
+ exec starterd --user=pi --purge_shm_base
else
ROBOT_CODE="${HOME}/bin"
fi
diff --git a/frc971/analysis/BUILD b/frc971/analysis/BUILD
index 9c236c8..b2d11f5 100644
--- a/frc971/analysis/BUILD
+++ b/frc971/analysis/BUILD
@@ -124,3 +124,18 @@
],
deps = ["@RangeHTTPServer"],
)
+
+cc_binary(
+ name = "pdp_values",
+ srcs = [
+ "pdp_values.cc",
+ ],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ "//aos:init",
+ "//aos/events:simulated_event_loop",
+ "//aos/events/logging:log_reader",
+ "//aos/util:simulation_logger",
+ "//frc971/wpilib:pdp_values_fbs",
+ ],
+)
diff --git a/frc971/analysis/pdp_values.cc b/frc971/analysis/pdp_values.cc
new file mode 100644
index 0000000..b314cc6
--- /dev/null
+++ b/frc971/analysis/pdp_values.cc
@@ -0,0 +1,57 @@
+#include <fstream>
+
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+
+#include "aos/events/logging/log_reader.h"
+#include "aos/events/simulated_event_loop.h"
+#include "aos/init.h"
+#include "frc971/wpilib/pdp_values_generated.h"
+
+DEFINE_string(output_path, "/tmp/pdp_values.csv", "");
+
+int main(int argc, char **argv) {
+ aos::InitGoogle(&argc, &argv);
+
+ aos::logger::LogReader reader(
+ aos::logger::SortParts(aos::logger::FindLogs(argc, argv)));
+
+ aos::SimulatedEventLoopFactory event_loop_factory(reader.configuration());
+
+ reader.RegisterWithoutStarting(&event_loop_factory);
+
+ const aos::Node *roborio =
+ aos::configuration::GetNode(reader.configuration(), "roborio");
+
+ std::unique_ptr<aos::EventLoop> event_loop =
+ event_loop_factory.MakeEventLoop("roborio", roborio);
+
+ std::ofstream file_stream;
+ file_stream.open(FLAGS_output_path);
+ file_stream << "timestamp,currents,voltage\n";
+
+ event_loop->SkipAosLog();
+ event_loop->MakeWatcher(
+ "/roborio/aos",
+ [&file_stream, &event_loop](const frc971::PDPValues &pdp_values) {
+ file_stream << event_loop->context().monotonic_event_time << ","
+ << "[";
+
+ for (uint i = 0; i < pdp_values.currents()->size(); i++) {
+ file_stream << pdp_values.currents()->Get(i);
+ if (i != pdp_values.currents()->size() - 1) {
+ file_stream << ", ";
+ }
+ }
+
+ file_stream << "]," << pdp_values.voltage() << "\n";
+ });
+
+ event_loop_factory.Run();
+
+ reader.Deregister();
+
+ file_stream.close();
+
+ return 0;
+}
diff --git a/frc971/imu_fdcan/can_translator_lib.cc b/frc971/imu_fdcan/can_translator_lib.cc
index 4336c82..bbf758d 100644
--- a/frc971/imu_fdcan/can_translator_lib.cc
+++ b/frc971/imu_fdcan/can_translator_lib.cc
@@ -14,7 +14,7 @@
"/imu")) {
packets_arrived_.fill(false);
// TODO(max): Update this with a proper priority
- event_loop->SetRuntimeRealtimePriority(15);
+ event_loop->SetRuntimeRealtimePriority(58);
event_loop->MakeWatcher(
canframe_channel, [this](const frc971::can_logger::CanFrame &can_frame) {
diff --git a/y2024/y2024_imu.json b/y2024/y2024_imu.json
index 32dadbf..5baae1c 100644
--- a/y2024/y2024_imu.json
+++ b/y2024/y2024_imu.json
@@ -400,7 +400,7 @@
"name": "imu_can_logger",
"executable_name": "can_logger",
"args": [
- "--priority=55",
+ "--priority=59",
"--affinity=5"
],
"nodes": [