Create camera_monitor to restart camera_reader when stuck
Apparently camera_reader can sometimes end up in a state where it stops
sending any images. Create a process that restarts camera_reader when we
stop observing new camera images.
Change-Id: Idd17e174c97776f97eca452e46fa9645645500b1
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2023/vision/camera_monitor_lib.h b/y2023/vision/camera_monitor_lib.h
new file mode 100644
index 0000000..ddb116e
--- /dev/null
+++ b/y2023/vision/camera_monitor_lib.h
@@ -0,0 +1,21 @@
+#ifndef Y2023_VISION_CAMERA_MONITOR_LIB_H_
+#define Y2023_VISION_CAMERA_MONITOR_LIB_H_
+#include "aos/events/event_loop.h"
+#include "aos/starter/starter_rpc_lib.h"
+#include "frc971/vision/vision_generated.h"
+namespace y2023::vision {
+// This class provides an application that will restart the camera_reader
+// process whenever images stop flowing for too long. This is to mitigate an
+// issue where sometimes we stop getting camera images.
+class CameraMonitor {
+ public:
+ CameraMonitor(aos::EventLoop *event_loop);
+
+ private:
+ void SetImageTimeout();
+ aos::EventLoop *event_loop_;
+ aos::starter::StarterClient starter_;
+ aos::TimerHandler *image_timeout_;
+};
+} // namespace y2023::vision
+#endif // Y2023_VISION_CAMERA_MONITOR_LIB_H_