Clean up the realtime priorities of all the robots etc
Change-Id: Ie19ea31ec7b19d9660230477e5f77de9edc5eb59
diff --git a/y2014/BUILD b/y2014/BUILD
index 5a5011e..6561047 100644
--- a/y2014/BUILD
+++ b/y2014/BUILD
@@ -51,9 +51,9 @@
'//y2014/control_loops/claw:claw',
'//y2014/control_loops/shooter:shooter',
'//y2014/autonomous:auto',
- '//y2014/wpilib:wpilib_interface',
'//y2014/actors:binaries',
'//aos:prime_start_binaries',
+ '//y2014/wpilib:wpilib_interface',
],
srcs = [
'//aos:prime_binaries',
diff --git a/y2014/actors/drivetrain_actor_main.cc b/y2014/actors/drivetrain_actor_main.cc
index ef65d5b..4cc0070 100644
--- a/y2014/actors/drivetrain_actor_main.cc
+++ b/y2014/actors/drivetrain_actor_main.cc
@@ -7,7 +7,7 @@
using ::aos::time::Time;
int main(int /*argc*/, char * /*argv*/[]) {
- ::aos::Init();
+ ::aos::Init(-1);
::y2014::actors::DrivetrainActor drivetrain(
&::y2014::actors::drivetrain_action);
diff --git a/y2014/actors/shoot_actor_main.cc b/y2014/actors/shoot_actor_main.cc
index fb27f93..1d33404 100644
--- a/y2014/actors/shoot_actor_main.cc
+++ b/y2014/actors/shoot_actor_main.cc
@@ -7,7 +7,7 @@
using ::aos::time::Time;
int main(int /*argc*/, char * /*argv*/[]) {
- ::aos::Init();
+ ::aos::Init(-1);
::y2014::actors::ShootActor shoot(&::y2014::actors::shoot_action);
shoot.Run();
diff --git a/y2014/autonomous/auto_main.cc b/y2014/autonomous/auto_main.cc
index 253b237..bf3acf8 100644
--- a/y2014/autonomous/auto_main.cc
+++ b/y2014/autonomous/auto_main.cc
@@ -9,7 +9,7 @@
using ::aos::time::Time;
int main(int /*argc*/, char * /*argv*/[]) {
- ::aos::Init();
+ ::aos::Init(-1);
LOG(INFO, "Auto main started\n");
::frc971::autonomous::autonomous.FetchLatest();
diff --git a/y2014/joystick_reader.cc b/y2014/joystick_reader.cc
index a0f2320..87dc3f1 100644
--- a/y2014/joystick_reader.cc
+++ b/y2014/joystick_reader.cc
@@ -522,7 +522,7 @@
} // namespace y2014
int main() {
- ::aos::Init();
+ ::aos::Init(-1);
::y2014::input::joysticks::Reader reader;
reader.Run();
::aos::Cleanup();
diff --git a/y2014/wpilib/wpilib_interface.cc b/y2014/wpilib/wpilib_interface.cc
index a399601..cc634d9 100644
--- a/y2014/wpilib/wpilib_interface.cc
+++ b/y2014/wpilib/wpilib_interface.cc
@@ -264,7 +264,7 @@
::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
::aos::time::Time::InMS(4));
- ::aos::SetCurrentThreadRealtimePriority(kPriority);
+ ::aos::SetCurrentThreadRealtimePriority(40);
while (run_) {
{
const int iterations = phased_loop.SleepUntilNext();
@@ -410,7 +410,7 @@
multiplier * claw_translate(counter->last_negative_encoder_value());
}
- ::frc971::wpilib::InterruptSynchronizer synchronizer_{kInterruptPriority};
+ ::frc971::wpilib::InterruptSynchronizer synchronizer_{55};
::std::unique_ptr<::frc971::wpilib::EdgeCounter> front_counter_;
::std::unique_ptr<::frc971::wpilib::EdgeCounter> calibration_counter_;
@@ -426,9 +426,6 @@
const bool reversed_;
};
- static const int kPriority = 30;
- static const int kInterruptPriority = 55;
-
void CopyShooterPosedgeCounts(
const ::frc971::wpilib::DMAEdgeCounter *counter,
::frc971::PosedgeOnlyCountedHallEffectStruct *output) {
@@ -507,10 +504,18 @@
void operator()() {
::aos::SetCurrentThreadName("Solenoids");
- ::aos::SetCurrentThreadRealtimePriority(30);
+ ::aos::SetCurrentThreadRealtimePriority(27);
+
+ ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(20),
+ ::aos::time::Time::InMS(1));
while (run_) {
- ::aos::time::PhasedLoopXMS(20, 1000);
+ {
+ const int iterations = phased_loop.SleepUntilNext();
+ if (iterations != 1) {
+ LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
+ }
+ }
{
shooter_.FetchLatest();
@@ -771,7 +776,14 @@
::std::thread solenoid_thread(::std::ref(solenoid_writer));
// Wait forever. Not much else to do...
- PCHECK(select(0, nullptr, nullptr, nullptr, nullptr));
+ while (true) {
+ const int r = select(0, nullptr, nullptr, nullptr, nullptr);
+ if (r != 0) {
+ PLOG(WARNING, "infinite select failed");
+ } else {
+ PLOG(WARNING, "infinite select succeeded??\n");
+ }
+ }
LOG(ERROR, "Exiting WPILibRobot\n");