map_builder_server_main.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2017 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
21 #include "gflags/gflags.h"
22 #include "glog/logging.h"
23 #if USE_PROMETHEUS
25 #include "prometheus/exposer.h"
26 #endif
27 
28 DEFINE_string(configuration_directory, "",
29  "First directory in which configuration files are searched, "
30  "second is always the Cartographer installation to allow "
31  "including files from there.");
32 DEFINE_string(configuration_basename, "",
33  "Basename, i.e. not containing any directory prefix, of the "
34  "configuration file.");
35 
36 namespace cartographer {
37 namespace cloud {
38 
39 void Run(const std::string& configuration_directory,
40  const std::string& configuration_basename) {
41 #if USE_PROMETHEUS
45  ::prometheus::Exposer exposer("0.0.0.0:9100");
46  exposer.RegisterCollectable(registry.GetCollectable());
47  LOG(INFO) << "Exposing metrics at http://localhost:9100/metrics";
48 #endif
49 
50  proto::MapBuilderServerOptions map_builder_server_options =
51  LoadMapBuilderServerOptions(configuration_directory,
52  configuration_basename);
53  // TODO(gaschler): Remove this override when parameter is imported from lua
54  // config.
55  map_builder_server_options.mutable_map_builder_options()
56  ->set_collate_by_trajectory(true);
57  auto map_builder = common::make_unique<mapping::MapBuilder>(
58  map_builder_server_options.map_builder_options());
59  std::unique_ptr<MapBuilderServerInterface> map_builder_server =
60  CreateMapBuilderServer(map_builder_server_options,
61  std::move(map_builder));
62  map_builder_server->Start();
63  map_builder_server->WaitForShutdown();
64 }
65 
66 } // namespace cloud
67 } // namespace cartographer
68 
69 int main(int argc, char** argv) {
70  google::InitGoogleLogging(argv[0]);
71  FLAGS_logtostderr = true;
72  google::SetUsageMessage(
73  "\n\n"
74  "This program offers a MapBuilder service via a gRPC interface.\n");
75  google::ParseCommandLineFlags(&argc, &argv, true);
76  if (FLAGS_configuration_directory.empty() ||
77  FLAGS_configuration_basename.empty()) {
78  google::ShowUsageWithFlagsRestrict(argv[0], "cloud_server");
79  return EXIT_FAILURE;
80  }
81  cartographer::cloud::Run(FLAGS_configuration_directory,
82  FLAGS_configuration_basename);
83 }
std::weak_ptr<::prometheus::Collectable > GetCollectable() const
int main(int argc, char **argv)
void RegisterMapBuilderServerMetrics(metrics::FamilyFactory *factory)
DEFINE_string(configuration_directory, "", "First directory in which configuration files are searched, " "second is always the Cartographer installation to allow " "including files from there.")
std::unique_ptr< MapBuilderServerInterface > CreateMapBuilderServer(const proto::MapBuilderServerOptions &map_builder_server_options, std::unique_ptr< mapping::MapBuilderInterface > map_builder)
void RegisterAllMetrics(FamilyFactory *registry)
Definition: register.cc:28
proto::MapBuilderServerOptions LoadMapBuilderServerOptions(const std::string &configuration_directory, const std::string &configuration_basename)
void Run(const std::string &configuration_directory, const std::string &configuration_basename)


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58