Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/cloud/map_builder_server_interface.h"
00018 #include "cartographer/cloud/map_builder_server_options.h"
00019 #include "cartographer/mapping/map_builder.h"
00020 #include "cartographer/metrics/register.h"
00021 #include "gflags/gflags.h"
00022 #include "glog/logging.h"
00023 #if USE_PROMETHEUS
00024 #include "cartographer/cloud/metrics/prometheus/family_factory.h"
00025 #include "prometheus/exposer.h"
00026 #endif
00027
00028 DEFINE_string(configuration_directory, "",
00029 "First directory in which configuration files are searched, "
00030 "second is always the Cartographer installation to allow "
00031 "including files from there.");
00032 DEFINE_string(configuration_basename, "",
00033 "Basename, i.e. not containing any directory prefix, of the "
00034 "configuration file.");
00035
00036 namespace cartographer {
00037 namespace cloud {
00038
00039 void Run(const std::string& configuration_directory,
00040 const std::string& configuration_basename) {
00041 #if USE_PROMETHEUS
00042 metrics::prometheus::FamilyFactory registry;
00043 ::cartographer::metrics::RegisterAllMetrics(®istry);
00044 RegisterMapBuilderServerMetrics(®istry);
00045 ::prometheus::Exposer exposer("0.0.0.0:9100");
00046 exposer.RegisterCollectable(registry.GetCollectable());
00047 LOG(INFO) << "Exposing metrics at http://localhost:9100/metrics";
00048 #endif
00049
00050 proto::MapBuilderServerOptions map_builder_server_options =
00051 LoadMapBuilderServerOptions(configuration_directory,
00052 configuration_basename);
00053 auto map_builder = absl::make_unique<mapping::MapBuilder>(
00054 map_builder_server_options.map_builder_options());
00055 std::unique_ptr<MapBuilderServerInterface> map_builder_server =
00056 CreateMapBuilderServer(map_builder_server_options,
00057 std::move(map_builder));
00058 map_builder_server->Start();
00059 map_builder_server->WaitForShutdown();
00060 }
00061
00062 }
00063 }
00064
00065 int main(int argc, char** argv) {
00066 google::InitGoogleLogging(argv[0]);
00067 FLAGS_logtostderr = true;
00068 google::SetUsageMessage(
00069 "\n\n"
00070 "This program offers a MapBuilder service via a gRPC interface.\n");
00071 google::ParseCommandLineFlags(&argc, &argv, true);
00072 if (FLAGS_configuration_directory.empty() ||
00073 FLAGS_configuration_basename.empty()) {
00074 google::ShowUsageWithFlagsRestrict(argv[0], "map_builder_server");
00075 return EXIT_FAILURE;
00076 }
00077 cartographer::cloud::Run(FLAGS_configuration_directory,
00078 FLAGS_configuration_basename);
00079 }