map_builder_context_interface.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_CLOUD_MAP_BUILDER_CONTEXT_INTERFACE_H
00018 #define CARTOGRAPHER_CLOUD_MAP_BUILDER_CONTEXT_INTERFACE_H
00019 
00020 #include "async_grpc/execution_context.h"
00021 #include "cartographer/cloud/internal/local_trajectory_uploader.h"
00022 #include "cartographer/common/blocking_queue.h"
00023 #include "cartographer/mapping/map_builder_interface.h"
00024 #include "cartographer/mapping/pose_graph_interface.h"
00025 #include "cartographer/mapping/proto/serialization.pb.h"
00026 #include "cartographer/sensor/data.h"
00027 #include "cartographer/sensor/range_data.h"
00028 #include "cartographer/transform/rigid_transform.h"
00029 
00030 namespace cartographer {
00031 namespace cloud {
00032 
00033 class MapBuilderServer;
00034 class MapBuilderContextInterface : public async_grpc::ExecutionContext {
00035  public:
00036   struct LocalSlamResult {
00037     int trajectory_id;
00038     common::Time time;
00039     transform::Rigid3d local_pose;
00040     std::shared_ptr<const sensor::RangeData> range_data;
00041     std::unique_ptr<const mapping::TrajectoryBuilderInterface::InsertionResult>
00042         insertion_result;
00043   };
00044   // Calling with 'nullptr' signals subscribers that the subscription has ended,
00045   // e.g. this happens when the corresponding trajectory was finished and hence
00046   // no more local SLAM updates will occur.
00047   // The callback can return 'false' to indicate that the client is not
00048   // interested in more local SLAM updates and 'MapBuilderServer' will end the
00049   // subscription.
00050   using LocalSlamSubscriptionCallback =
00051       std::function<bool(std::unique_ptr<LocalSlamResult>)>;
00052 
00053   // The callback can return 'false' to indicate that the client is not
00054   // interested in more global SLAM runs and 'MapBuilderServer' will end the
00055   // subscription.
00056   using GlobalSlamOptimizationCallback = std::function<bool(
00057       const std::map<int /* trajectory_id */, mapping::SubmapId>&,
00058       const std::map<int /* trajectory_id */, mapping::NodeId>&)>;
00059 
00060   struct Data {
00061     int trajectory_id;
00062     std::unique_ptr<sensor::Data> data;
00063   };
00064   struct LocalSlamSubscriptionId {
00065     const int trajectory_id;
00066     const int subscription_index;
00067   };
00068 
00069   MapBuilderContextInterface() = default;
00070   ~MapBuilderContextInterface() = default;
00071 
00072   MapBuilderContextInterface(const MapBuilderContextInterface&) = delete;
00073   MapBuilderContextInterface& operator=(const MapBuilderContextInterface&) =
00074       delete;
00075 
00076   virtual mapping::MapBuilderInterface& map_builder() = 0;
00077   virtual common::BlockingQueue<std::unique_ptr<Data>>& sensor_data_queue() = 0;
00078   virtual mapping::TrajectoryBuilderInterface::LocalSlamResultCallback
00079   GetLocalSlamResultCallbackForSubscriptions() = 0;
00080   virtual void AddSensorDataToTrajectory(const Data& sensor_data) = 0;
00081   virtual LocalSlamSubscriptionId SubscribeLocalSlamResults(
00082       int trajectory_id, LocalSlamSubscriptionCallback callback) = 0;
00083   virtual void UnsubscribeLocalSlamResults(
00084       const LocalSlamSubscriptionId& subscription_id) = 0;
00085   virtual int SubscribeGlobalSlamOptimizations(
00086       GlobalSlamOptimizationCallback callback) = 0;
00087   virtual void UnsubscribeGlobalSlamOptimizations(int subscription_index) = 0;
00088   virtual void NotifyFinishTrajectory(int trajectory_id) = 0;
00089   virtual LocalTrajectoryUploaderInterface* local_trajectory_uploader() = 0;
00090   virtual void EnqueueSensorData(int trajectory_id,
00091                                  std::unique_ptr<sensor::Data> data) = 0;
00092   virtual void EnqueueLocalSlamResultData(
00093       int trajectory_id, const std::string& sensor_id,
00094       const mapping::proto::LocalSlamResultData& local_slam_result_data) = 0;
00095   virtual void RegisterClientIdForTrajectory(const std::string& client_id,
00096                                              int trajectory_id) = 0;
00097   virtual bool CheckClientIdForTrajectory(const std::string& client_id,
00098                                           int trajectory_id) = 0;
00099 };
00100 
00101 }  // namespace cloud
00102 }  // namespace cartographer
00103 
00104 #endif  // CARTOGRAPHER_CLOUD_MAP_BUILDER_CONTEXT_INTERFACE_H


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35