From c418ff5580f6584537329edfd28f27e9101143a4 Mon Sep 17 00:00:00 2001 From: Michael Grupp Date: Thu, 13 Sep 2018 11:29:26 +0200 Subject: [PATCH] Disable forwarding proto stream by default in node_grpc_main.cc (#1013) ...and use `LoadStateFromFile` from `MapBuilderStub`. The `LoadState` stub that's used in `Node::LoadState` streams the state file instead, which can now be used by explicitly setting the `--upload_load_state_file` flag. Solves problems with the gRPC message size limit when loading large state files. --- .../cartographer_grpc/node_grpc_main.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cartographer_ros/cartographer_ros/cartographer_grpc/node_grpc_main.cc b/cartographer_ros/cartographer_ros/cartographer_grpc/node_grpc_main.cc index 34d1cca..20ee55d 100644 --- a/cartographer_ros/cartographer_ros/cartographer_grpc/node_grpc_main.cc +++ b/cartographer_ros/cartographer_ros/cartographer_grpc/node_grpc_main.cc @@ -33,8 +33,7 @@ DEFINE_string(configuration_basename, "", "Basename, i.e. not containing any directory prefix, of the " "configuration file."); DEFINE_string(server_address, "localhost:50051", - "gRPC server address to " - "stream the sensor data to."); + "gRPC server address to stream the sensor data to."); DEFINE_bool( start_trajectory_with_default_topics, true, "Enable to immediately start the first trajectory with default topics."); @@ -43,9 +42,14 @@ DEFINE_string( "If non-empty, serialize state and write it to disk before shutting down."); DEFINE_string(load_state_filename, "", "If non-empty, filename of a .pbstream file " - "to load, containing a saved SLAM state."); + "to load, containing a saved SLAM state. " + "Unless --upload_load_state_file is set, the filepath refers " + "to the gRPC server's file system."); DEFINE_bool(load_frozen_state, true, "Load the saved state as frozen (non-optimized) trajectories."); +DEFINE_bool(upload_load_state_file, false, + "Upload the .pbstream file from a local path to the (remote) gRPC " + "server instead of loading it from the server file system."); DEFINE_string(client_id, "", "Cartographer client ID to use when connecting to the server."); @@ -63,10 +67,16 @@ void Run() { auto map_builder = absl::make_unique<::cartographer::cloud::MapBuilderStub>( FLAGS_server_address, FLAGS_client_id); + + if (!FLAGS_load_state_filename.empty() && !FLAGS_upload_load_state_file) { + map_builder->LoadStateFromFile(FLAGS_load_state_filename, + FLAGS_load_frozen_state); + } + Node node(node_options, std::move(map_builder), &tf_buffer, FLAGS_collect_metrics); - if (!FLAGS_load_state_filename.empty()) { + if (!FLAGS_load_state_filename.empty() && FLAGS_upload_load_state_file) { node.LoadState(FLAGS_load_state_filename, FLAGS_load_frozen_state); }