From c8c81dff350396fcf0c0996a389e0fc95a65858f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Sch=C3=BCtte?= <cschuet@google.com>
Date: Wed, 28 Feb 2018 12:47:19 +0100
Subject: [PATCH] Ignore pure_localization option on server (#933)

Fixes #914
---
 cartographer_grpc/handlers/add_trajectory_handler.cc      | 4 ++++
 cartographer_grpc/handlers/add_trajectory_handler_test.cc | 1 +
 2 files changed, 5 insertions(+)

diff --git a/cartographer_grpc/handlers/add_trajectory_handler.cc b/cartographer_grpc/handlers/add_trajectory_handler.cc
index 927af24..a43f3bc 100644
--- a/cartographer_grpc/handlers/add_trajectory_handler.cc
+++ b/cartographer_grpc/handlers/add_trajectory_handler.cc
@@ -51,6 +51,10 @@ void AddTrajectoryHandler::OnRequest(
     trajectory_builder_options.clear_trajectory_builder_2d_options();
     trajectory_builder_options.clear_trajectory_builder_3d_options();
 
+    // Don't instantiate the 'PureLocalizationTrimmer' on the server and don't
+    // freeze the trajectory on the server.
+    trajectory_builder_options.set_pure_localization(false);
+
     GetContext<MapBuilderContextInterface>()
         ->local_trajectory_uploader()
         ->AddTrajectory(trajectory_id, expected_sensor_ids,
diff --git a/cartographer_grpc/handlers/add_trajectory_handler_test.cc b/cartographer_grpc/handlers/add_trajectory_handler_test.cc
index 5fd24dd..addac4e 100644
--- a/cartographer_grpc/handlers/add_trajectory_handler_test.cc
+++ b/cartographer_grpc/handlers/add_trajectory_handler_test.cc
@@ -122,6 +122,7 @@ TEST_F(AddTrajectoryHandlerTest, WithLocalSlamUploader) {
       request.trajectory_builder_options();
   upstream_trajectory_builder_options.clear_trajectory_builder_2d_options();
   upstream_trajectory_builder_options.clear_trajectory_builder_3d_options();
+  upstream_trajectory_builder_options.set_pure_localization(false);
   EXPECT_CALL(*mock_local_trajectory_uploader_,
               AddTrajectory(Eq(13), ParseSensorIds(request),
                             Truly(testing::BuildProtoPredicateEquals(