Automatic reverse-lookup of channel names in Foxglove

This makes it so that if you want to visualize a logfile, then
you will be able to, e.g., refer to "/aos aos.timing.Report"
regardless of what node you are on, without having to alter your
layouts to refer to "/pi1/pose aos.timing.Report". This may end up
causing extra confusion because it masks what the "true" channel name
is, but I expect that defaulting to shorter names will make it easier to
use.

Fix existing layouts that had prefixes hardcoded.

Change-Id: Ic708f48868bbb4b1e60bfef9ebec36100a1763fd
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/util/mcap_logger.h b/aos/util/mcap_logger.h
index d7409fb..d264c1e 100644
--- a/aos/util/mcap_logger.h
+++ b/aos/util/mcap_logger.h
@@ -36,8 +36,18 @@
     kJson,
     kFlatbuffer,
   };
+  // Whether to attempt to shorten channel names.
+  enum class CanonicalChannelNames {
+    // Just use the full, unambiguous, channel names.
+    kCanonical,
+    // Use GetChannelAliases() to determine the shortest possible name for the
+    // channel for the current node, and use that in the MCAP file. This makes
+    // it so that the channels in the resulting file are more likely to match
+    // the channel names that are used in "real" applications.
+    kShortened,
+  };
   McapLogger(EventLoop *event_loop, const std::string &output_path,
-             Serialization serialization);
+             Serialization serialization, CanonicalChannelNames canonical_channels);
   ~McapLogger();
 
  private:
@@ -131,6 +141,7 @@
   aos::EventLoop *event_loop_;
   std::ofstream output_;
   const Serialization serialization_;
+  const CanonicalChannelNames canonical_channels_;
   size_t total_message_bytes_ = 0;
   std::map<const Channel *, size_t> total_channel_bytes_;
   // Buffer containing serialized message data for the currently-being-built