Skip to content

Commit

Permalink
Add load_frozen_state also to LoadStateFromFile gRPC requests. (#1423)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelGrupp authored and wally-the-cartographer committed Sep 13, 2018
1 parent 5cbe09f commit a21ecf9
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cartographer/cloud/client/map_builder_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ std::map<int, int> MapBuilderStub::LoadState(
}

std::map<int, int> 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<handlers::LoadStateFromFileSignature> client(
client_channel_);
CHECK(client.Write(request));
Expand Down
3 changes: 2 additions & 1 deletion cartographer/cloud/client/map_builder_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class MapBuilderStub : public mapping::MapBuilderInterface {
io::ProtoStreamWriterInterface* writer) override;
std::map<int, int> LoadState(io::ProtoStreamReaderInterface* reader,
bool load_frozen_state) override;
std::map<int, int> LoadStateFromFile(const std::string& filename) override;
std::map<int, int> LoadStateFromFile(const std::string& filename,
bool load_frozen_state) override;
int num_trajectory_builders() const override;
mapping::PoseGraphInterface* pose_graph() override;
const std::vector<mapping::proto::TrajectoryBuilderOptionsWithSensorIds>&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void LoadStateFromFileHandler::OnRequest(
// background.
auto trajectory_remapping =
GetContext<MapBuilderContextInterface>()->map_builder().LoadStateFromFile(
request.file_path());
request.file_path(), request.load_frozen_state());
for (const auto& entry : trajectory_remapping) {
GetContext<MapBuilderContextInterface>()->RegisterClientIdForTrajectory(
request.client_id(), entry.second);
Expand Down
1 change: 1 addition & 0 deletions cartographer/cloud/proto/map_builder_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ message LoadStateResponse {
message LoadStateFromFileRequest {
string file_path = 1;
string client_id = 2;
bool load_frozen_state = 3;
}

message LoadStateFromFileResponse {
Expand Down
3 changes: 2 additions & 1 deletion cartographer/mapping/internal/testing/mock_map_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class MockMapBuilder : public mapping::MapBuilderInterface {
MOCK_METHOD2(SerializeState, void(bool, io::ProtoStreamWriterInterface *));
MOCK_METHOD2(LoadState,
std::map<int, int>(io::ProtoStreamReaderInterface *, bool));
MOCK_METHOD1(LoadStateFromFile, std::map<int, int>(const std::string &));
MOCK_METHOD2(LoadStateFromFile,
std::map<int, int>(const std::string &, bool));
MOCK_CONST_METHOD0(num_trajectory_builders, int());
MOCK_METHOD0(pose_graph, mapping::PoseGraphInterface *());
MOCK_CONST_METHOD0(
Expand Down
4 changes: 2 additions & 2 deletions cartographer/mapping/map_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ std::map<int, int> MapBuilder::LoadState(
}

std::map<int, int> 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<int>(state_filename.size() - suffix.size(), 0)) != suffix) {
Expand All @@ -400,7 +400,7 @@ std::map<int, int> 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
Expand Down
3 changes: 2 additions & 1 deletion cartographer/mapping/map_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class MapBuilder : public MapBuilderInterface {
std::map<int, int> LoadState(io::ProtoStreamReaderInterface *reader,
bool load_frozen_state) override;

std::map<int, int> LoadStateFromFile(const std::string &filename) override;
std::map<int, int> LoadStateFromFile(const std::string &filename,
const bool load_frozen_state) override;

mapping::PoseGraphInterface *pose_graph() override {
return pose_graph_.get();
Expand Down
4 changes: 2 additions & 2 deletions cartographer/mapping/map_builder_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ class MapBuilderInterface {
virtual std::map<int /* trajectory id in proto */, int /* trajectory id */>
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<int /* trajectory id in proto */, int /* trajectory id */>
LoadStateFromFile(const std::string& filename) = 0;
LoadStateFromFile(const std::string& filename, bool load_frozen_state) = 0;

virtual int num_trajectory_builders() const = 0;

Expand Down

0 comments on commit a21ecf9

Please sign in to comment.