Add field for image channel in charuco lib

Allows us to easily send it to /camera/decimated for mapping, which is
what we're using until we start logging at full frequency.

Also, move some command line flags out of charuco lib to avoid manually setting flags.

Signed-off-by: Milind Upadhyay <milind.upadhyay@gmail.com>
Change-Id: Iae4d9ed06260154a0fb4d4c67ea03b06a28e4411
diff --git a/y2022/vision/target_mapping.cc b/y2022/vision/target_mapping.cc
index 2b10798..112696e 100644
--- a/y2022/vision/target_mapping.cc
+++ b/y2022/vision/target_mapping.cc
@@ -26,6 +26,8 @@
     "times of target detections. Currently does not work reliably on the box "
     "of pis.");
 
+DECLARE_string(image_channel);
+
 namespace y2022 {
 namespace vision {
 using frc971::vision::DataAdapter;
@@ -151,10 +153,13 @@
   const auto turret_extrinsics = CameraTurretExtrinsics(calibration);
   const auto fixed_extrinsics = CameraFixedExtrinsics(calibration);
 
+  // TODO(milind): change to /camera once we log at full frequency
+  static constexpr std::string_view kImageChannel = "/camera/decimated";
   charuco_extractors->emplace_back(std::make_unique<CharucoExtractor>(
       pi_event_loop,
       "pi-" + std::to_string(FLAGS_team_number) + "-" +
           std::to_string(pi_number),
+      TargetType::kAprilTag, kImageChannel,
       [=](cv::Mat /*rgb_image*/, aos::monotonic_clock::time_point eof,
           std::vector<cv::Vec4i> april_ids,
           std::vector<std::vector<cv::Point2f>> /*april_corners*/, bool valid,
@@ -173,11 +178,8 @@
         }
       }));
 
-  std::string channel =
-      absl::StrCat("/pi", std::to_string(pi_number), "/camera");
-
   image_callbacks->emplace_back(std::make_unique<ImageCallback>(
-      pi_event_loop, "/pi" + std::to_string(pi_number) + "/camera",
+      pi_event_loop, kImageChannel,
       [&, charuco_extractor =
               charuco_extractors->at(charuco_extractors->size() - 1).get()](
           cv::Mat rgb_image, const aos::monotonic_clock::time_point eof) {
@@ -233,9 +235,6 @@
             "/superstructure");
   }
 
-  // Override target_type to AprilTag, since that's what we're using here
-  FLAGS_target_type = "april_tag";
-
   std::vector<std::unique_ptr<CharucoExtractor>> charuco_extractors;
   std::vector<std::unique_ptr<ImageCallback>> image_callbacks;