Added the operator to frc971 SensorReader.
Took the operator fuction out of the year specific SensorReader, needed
to make a empty RunInteration in order for it to work.
Change-Id: I0ec02ab293c1f8eba56d6365383105e860f69cdd
diff --git a/y2019/wpilib_interface.cc b/y2019/wpilib_interface.cc
index dcdf00b..9395489 100644
--- a/y2019/wpilib_interface.cc
+++ b/y2019/wpilib_interface.cc
@@ -116,53 +116,7 @@
hall_filter_.SetPeriodNanoSeconds(100000);
}
- void operator()() {
- ::aos::SetCurrentThreadName("SensorReader");
-
- my_pid_ = getpid();
-
- dma_synchronizer_->Start();
-
- ::aos::time::PhasedLoop phased_loop(last_period_,
- ::std::chrono::milliseconds(3));
- chrono::nanoseconds filtered_period = last_period_;
-
- ::std::thread pwm_detecter_thread(
- ::std::bind(&SensorReader::RunPWMDetecter, this));
-
- ::aos::SetCurrentThreadRealtimePriority(40);
- while (run_) {
- {
- const int iterations = phased_loop.SleepUntilNext();
- if (iterations != 1) {
- LOG(WARNING, "SensorReader skipped %d iterations\n", iterations - 1);
- }
- }
- RunIteration();
-
- monotonic_clock::time_point last_tick_timepoint;
- chrono::nanoseconds period;
- {
- ::std::unique_lock<::aos::stl_mutex> locker(tick_time_mutex_);
- last_tick_timepoint = last_tick_time_monotonic_timepoint_;
- period = last_period_;
- }
-
- if (last_tick_timepoint == monotonic_clock::min_time) {
- continue;
- }
- chrono::nanoseconds new_offset = phased_loop.OffsetFromIntervalAndTime(
- period, last_tick_timepoint + chrono::microseconds(2050));
-
- // TODO(austin): If this is the first edge in a while, skip to it (plus
- // an offset). Otherwise, slowly drift time to line up.
-
- phased_loop.set_interval_and_offset(period, new_offset);
- }
- pwm_detecter_thread.join();
- }
-
- void RunIteration() {
+ void RunIteration() override {
::frc971::wpilib::SendRobotState(my_pid_);
{
@@ -182,13 +136,6 @@
dma_synchronizer_->RunIteration();
}
-
-
- private:
- int32_t my_pid_;
-
- ::std::unique_ptr<frc::Encoder> drivetrain_left_encoder_,
- drivetrain_right_encoder_;
};
class DrivetrainWriter : public ::frc971::wpilib::LoopOutputHandler {