diff --git a/cartographer/cloud/client/map_builder_stub.cc b/cartographer/cloud/client/map_builder_stub.cc index d68e02e..dabe02e 100644 --- a/cartographer/cloud/client/map_builder_stub.cc +++ b/cartographer/cloud/client/map_builder_stub.cc @@ -197,10 +197,11 @@ std::map MapBuilderStub::LoadState( } std::map MapBuilderStub::LoadStateFromFile( - const std::string& filename) { + const std::string& filename, const bool load_frozen_state) { proto::LoadStateFromFileRequest request; request.set_file_path(filename); request.set_client_id(client_id_); + request.set_load_frozen_state(load_frozen_state); async_grpc::Client client( client_channel_); CHECK(client.Write(request)); diff --git a/cartographer/cloud/client/map_builder_stub.h b/cartographer/cloud/client/map_builder_stub.h index 0f6ca5b..733ee56 100644 --- a/cartographer/cloud/client/map_builder_stub.h +++ b/cartographer/cloud/client/map_builder_stub.h @@ -52,7 +52,8 @@ class MapBuilderStub : public mapping::MapBuilderInterface { io::ProtoStreamWriterInterface* writer) override; std::map LoadState(io::ProtoStreamReaderInterface* reader, bool load_frozen_state) override; - std::map LoadStateFromFile(const std::string& filename) override; + std::map LoadStateFromFile(const std::string& filename, + bool load_frozen_state) override; int num_trajectory_builders() const override; mapping::PoseGraphInterface* pose_graph() override; const std::vector& diff --git a/cartographer/cloud/internal/handlers/load_state_from_file_handler.cc b/cartographer/cloud/internal/handlers/load_state_from_file_handler.cc index f0c81d5..d11f6b7 100644 --- a/cartographer/cloud/internal/handlers/load_state_from_file_handler.cc +++ b/cartographer/cloud/internal/handlers/load_state_from_file_handler.cc @@ -32,7 +32,7 @@ void LoadStateFromFileHandler::OnRequest( // background. auto trajectory_remapping = GetContext()->map_builder().LoadStateFromFile( - request.file_path()); + request.file_path(), request.load_frozen_state()); for (const auto& entry : trajectory_remapping) { GetContext()->RegisterClientIdForTrajectory( request.client_id(), entry.second); diff --git a/cartographer/cloud/proto/map_builder_service.proto b/cartographer/cloud/proto/map_builder_service.proto index 282c9ee..ef0bb96 100644 --- a/cartographer/cloud/proto/map_builder_service.proto +++ b/cartographer/cloud/proto/map_builder_service.proto @@ -161,6 +161,7 @@ message LoadStateResponse { message LoadStateFromFileRequest { string file_path = 1; string client_id = 2; + bool load_frozen_state = 3; } message LoadStateFromFileResponse { diff --git a/cartographer/mapping/internal/testing/mock_map_builder.h b/cartographer/mapping/internal/testing/mock_map_builder.h index 7059feb..1fcdd85 100644 --- a/cartographer/mapping/internal/testing/mock_map_builder.h +++ b/cartographer/mapping/internal/testing/mock_map_builder.h @@ -50,7 +50,8 @@ class MockMapBuilder : public mapping::MapBuilderInterface { MOCK_METHOD2(SerializeState, void(bool, io::ProtoStreamWriterInterface *)); MOCK_METHOD2(LoadState, std::map(io::ProtoStreamReaderInterface *, bool)); - MOCK_METHOD1(LoadStateFromFile, std::map(const std::string &)); + MOCK_METHOD2(LoadStateFromFile, + std::map(const std::string &, bool)); MOCK_CONST_METHOD0(num_trajectory_builders, int()); MOCK_METHOD0(pose_graph, mapping::PoseGraphInterface *()); MOCK_CONST_METHOD0( diff --git a/cartographer/mapping/map_builder.cc b/cartographer/mapping/map_builder.cc index 80eb7fe..58e1d79 100644 --- a/cartographer/mapping/map_builder.cc +++ b/cartographer/mapping/map_builder.cc @@ -391,7 +391,7 @@ std::map MapBuilder::LoadState( } std::map MapBuilder::LoadStateFromFile( - const std::string& state_filename) { + const std::string& state_filename, const bool load_frozen_state) { const std::string suffix = ".pbstream"; if (state_filename.substr( std::max(state_filename.size() - suffix.size(), 0)) != suffix) { @@ -400,7 +400,7 @@ std::map MapBuilder::LoadStateFromFile( } LOG(INFO) << "Loading saved state '" << state_filename << "'..."; io::ProtoStreamReader stream(state_filename); - return LoadState(&stream, true); + return LoadState(&stream, load_frozen_state); } } // namespace mapping diff --git a/cartographer/mapping/map_builder.h b/cartographer/mapping/map_builder.h index cd3f9e9..0249c00 100644 --- a/cartographer/mapping/map_builder.h +++ b/cartographer/mapping/map_builder.h @@ -62,7 +62,8 @@ class MapBuilder : public MapBuilderInterface { std::map LoadState(io::ProtoStreamReaderInterface *reader, bool load_frozen_state) override; - std::map LoadStateFromFile(const std::string &filename) override; + std::map LoadStateFromFile(const std::string &filename, + const bool load_frozen_state) override; mapping::PoseGraphInterface *pose_graph() override { return pose_graph_.get(); diff --git a/cartographer/mapping/map_builder_interface.h b/cartographer/mapping/map_builder_interface.h index 3919a4a..f1fceb6 100644 --- a/cartographer/mapping/map_builder_interface.h +++ b/cartographer/mapping/map_builder_interface.h @@ -89,10 +89,10 @@ class MapBuilderInterface { virtual std::map LoadState(io::ProtoStreamReaderInterface* reader, bool load_frozen_state) = 0; - // Loads the SLAM state froma a pbstream file. Returns the remapping of new + // Loads the SLAM state from a pbstream file. Returns the remapping of new // trajectory_ids. virtual std::map - LoadStateFromFile(const std::string& filename) = 0; + LoadStateFromFile(const std::string& filename, bool load_frozen_state) = 0; virtual int num_trajectory_builders() const = 0;