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 "If non-empty, filename of a .pbstream file to load, containing " 33 "a saved SLAM state.");
35 "Load the saved state as frozen (non-optimized) trajectories.");
37 start_trajectory_with_default_topics,
true,
38 "Enable to immediately start the first trajectory with default topics.");
40 save_state_filename,
"",
41 "If non-empty, serialize state and write it to disk before shutting down.");
47 constexpr
double kTfBufferCacheTimeInSeconds = 10.;
50 NodeOptions node_options;
51 TrajectoryOptions trajectory_options;
52 std::tie(node_options, trajectory_options) =
53 LoadOptions(FLAGS_configuration_directory, FLAGS_configuration_basename);
56 cartographer::common::make_unique<cartographer::mapping::MapBuilder>(
57 node_options.map_builder_options);
58 Node node(node_options, std::move(map_builder), &tf_buffer);
59 if (!FLAGS_load_state_filename.empty()) {
60 node.LoadState(FLAGS_load_state_filename, FLAGS_load_frozen_state);
63 if (FLAGS_start_trajectory_with_default_topics) {
64 node.StartTrajectoryWithDefaultTopics(trajectory_options);
69 node.FinishAllTrajectories();
70 node.RunFinalOptimization();
72 if (!FLAGS_save_state_filename.empty()) {
73 node.SerializeState(FLAGS_save_state_filename);
80 int main(
int argc,
char** argv) {
81 google::InitGoogleLogging(argv[0]);
82 google::ParseCommandLineFlags(&argc, &argv,
true);
84 CHECK(!FLAGS_configuration_directory.empty())
85 <<
"-configuration_directory is missing.";
86 CHECK(!FLAGS_configuration_basename.empty())
87 <<
"-configuration_basename is missing.";
89 ::ros::init(argc, argv,
"cartographer_node");
93 cartographer_ros::Run();
DEFINE_bool(load_frozen_state, true, "Load the saved state as frozen (non-optimized) trajectories.")
std::tuple< NodeOptions, TrajectoryOptions > LoadOptions(const std::string &configuration_directory, const std::string &configuration_basename)
int main(int argc, char **argv)
DEFINE_string(configuration_directory, "", "First directory in which configuration files are searched, " "second is always the Cartographer installation to allow " "including files from there.")
void Run(const std::string &configuration_directory, const std::string &configuration_basename)
tf2_ros::Buffer * tf_buffer