From 4173beaf049522b2c971471bc6ef37082a91b5ad Mon Sep 17 00:00:00 2001 From: Wolfgang Hess Date: Thu, 10 Aug 2017 09:18:16 +0200 Subject: [PATCH] Only write pbstream file on success. (#481) The offline node will now only write the pbstream with the results if the node finished processing without being interrupted. Partial results are no longer written. This also adds logging so that it is clear whether output was written. --- cartographer_ros/cartographer_ros/offline_node_main.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cartographer_ros/cartographer_ros/offline_node_main.cc b/cartographer_ros/cartographer_ros/offline_node_main.cc index 5db3523..c582c97 100644 --- a/cartographer_ros/cartographer_ros/offline_node_main.cc +++ b/cartographer_ros/cartographer_ros/offline_node_main.cc @@ -234,7 +234,11 @@ void Run(const std::vector& bag_filenames) { << (cpu_timespec.tv_sec + 1e-9 * cpu_timespec.tv_nsec) << " s"; #endif - node.SerializeState(bag_filenames.front() + ".pbstream"); + if (::ros::ok()) { + const string output_filename = bag_filenames.front() + ".pbstream"; + LOG(INFO) << "Writing state to '" << output_filename << "'..."; + node.SerializeState(output_filename); + } if (FLAGS_keep_running) { ::ros::waitForShutdown(); }