Add load_frozen_state also to LoadStateFromFile gRPC requests. (#1423)

master
Michael Grupp 2018-09-13 10:13:16 +02:00 committed by Wally B. Feed
parent 5cbe09fef2
commit a21ecf9b99
8 changed files with 14 additions and 9 deletions

View File

@ -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));

View File

@ -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>&

View File

@ -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);

View File

@ -161,6 +161,7 @@ message LoadStateResponse {
message LoadStateFromFileRequest {
string file_path = 1;
string client_id = 2;
bool load_frozen_state = 3;
}
message LoadStateFromFileResponse {

View File

@ -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(

View File

@ -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) {
@ -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

View File

@ -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();

View File

@ -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;