map_builder_server_main.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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(&registry);
00044   RegisterMapBuilderServerMetrics(&registry);
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 }  // namespace cloud
00063 }  // namespace cartographer
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 }


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35