19 #include "async_grpc/rpc_handler.h" 22 #include "cartographer/cloud/proto/map_builder_service.pb.h" 29 void AddTrajectoryHandler::OnRequest(
30 const proto::AddTrajectoryRequest& request) {
31 auto local_slam_result_callback =
32 GetUnsynchronizedContext<MapBuilderContextInterface>()
33 ->GetLocalSlamResultCallbackForSubscriptions();
34 std::set<mapping::TrajectoryBuilderInterface::SensorId> expected_sensor_ids;
35 for (
const auto& sensor_id : request.expected_sensor_ids()) {
36 expected_sensor_ids.insert(
FromProto(sensor_id));
38 const int trajectory_id =
39 GetContext<MapBuilderContextInterface>()
41 .AddTrajectoryBuilder(expected_sensor_ids,
42 request.trajectory_builder_options(),
43 local_slam_result_callback);
44 if (GetUnsynchronizedContext<MapBuilderContextInterface>()
45 ->local_trajectory_uploader()) {
46 auto trajectory_builder_options = request.trajectory_builder_options();
51 trajectory_builder_options.clear_trajectory_builder_2d_options();
52 trajectory_builder_options.clear_trajectory_builder_3d_options();
56 trajectory_builder_options.set_pure_localization(
false);
58 GetContext<MapBuilderContextInterface>()
59 ->local_trajectory_uploader()
60 ->AddTrajectory(trajectory_id, expected_sensor_ids,
61 trajectory_builder_options);
64 auto response = common::make_unique<proto::AddTrajectoryResponse>();
65 response->set_trajectory_id(trajectory_id);
66 Send(std::move(response));
mapping::TrajectoryBuilderInterface::SensorId FromProto(const proto::SensorId &proto)