21 #include "gflags/gflags.h" 25 "First directory in which configuration files are searched, " 26 "second is always the Cartographer installation to allow " 27 "including files from there.");
29 "Basename, i.e. not containing any directory prefix, of the " 30 "configuration file.");
32 "gRPC server address to " 33 "stream the sensor data to.");
35 start_trajectory_with_default_topics,
true,
36 "Enable to immediately start the first trajectory with default topics.");
38 save_map_filename,
"",
39 "If non-empty, serialize state and write it to disk before shutting down.");
41 "If non-empty, filename of a .pbstream file " 42 "to load, containing a saved SLAM state.");
48 constexpr
double kTfBufferCacheTimeInSeconds = 10.;
51 NodeOptions node_options;
52 TrajectoryOptions trajectory_options;
53 std::tie(node_options, trajectory_options) =
54 LoadOptions(FLAGS_configuration_directory, FLAGS_configuration_basename);
57 cartographer::common::make_unique<::cartographer::cloud::MapBuilderStub>(
58 FLAGS_server_address);
59 Node node(node_options, std::move(map_builder), &tf_buffer);
61 if (!FLAGS_load_state_filename.empty()) {
62 node.LoadState(FLAGS_load_state_filename,
true );
65 if (FLAGS_start_trajectory_with_default_topics) {
66 node.StartTrajectoryWithDefaultTopics(trajectory_options);
71 node.FinishAllTrajectories();
72 node.RunFinalOptimization();
74 if (!FLAGS_save_map_filename.empty()) {
75 node.SerializeState(FLAGS_save_map_filename);
82 int main(
int argc,
char** argv) {
83 google::InitGoogleLogging(argv[0]);
84 google::ParseCommandLineFlags(&argc, &argv,
true);
86 CHECK(!FLAGS_configuration_directory.empty())
87 <<
"-configuration_directory is missing.";
88 CHECK(!FLAGS_configuration_basename.empty())
89 <<
"-configuration_basename is missing.";
91 ::ros::init(argc, argv,
"cartographer_grpc_node");
95 cartographer_ros::Run();
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::tuple< NodeOptions, TrajectoryOptions > LoadOptions(const std::string &configuration_directory, const std::string &configuration_basename)
DEFINE_bool(start_trajectory_with_default_topics, true, "Enable to immediately start the first trajectory with default topics.")
int main(int argc, char **argv)
void Run(const std::string &configuration_directory, const std::string &configuration_basename)
tf2_ros::Buffer * tf_buffer