submap_painter.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 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_IO_SUBMAP_PAINTER_H_
00018 #define CARTOGRAPHER_IO_SUBMAP_PAINTER_H_
00019 
00020 #include "Eigen/Geometry"
00021 #include "cairo/cairo.h"
00022 #include "cartographer/io/image.h"
00023 #include "cartographer/io/proto_stream_deserializer.h"
00024 #include "cartographer/mapping/id.h"
00025 #include "cartographer/mapping/proto/serialization.pb.h"
00026 #include "cartographer/mapping/value_conversion_tables.h"
00027 #include "cartographer/transform/rigid_transform.h"
00028 
00029 namespace cartographer {
00030 namespace io {
00031 
00032 struct PaintSubmapSlicesResult {
00033   PaintSubmapSlicesResult(::cartographer::io::UniqueCairoSurfacePtr surface,
00034                           Eigen::Array2f origin)
00035       : surface(std::move(surface)), origin(origin) {}
00036   ::cartographer::io::UniqueCairoSurfacePtr surface;
00037 
00038   // Top left pixel of 'surface' in map frame.
00039   Eigen::Array2f origin;
00040 };
00041 
00042 struct SubmapSlice {
00043   SubmapSlice()
00044       : surface(::cartographer::io::MakeUniqueCairoSurfacePtr(nullptr)) {}
00045 
00046   // Texture data.
00047   int width;
00048   int height;
00049   int version;
00050   double resolution;
00051   ::cartographer::transform::Rigid3d slice_pose;
00052   ::cartographer::io::UniqueCairoSurfacePtr surface;
00053   // Pixel data used by 'surface'. Must outlive 'surface'.
00054   std::vector<uint32_t> cairo_data;
00055 
00056   // Metadata.
00057   ::cartographer::transform::Rigid3d pose;
00058   int metadata_version = -1;
00059 };
00060 
00061 struct SubmapTexture {
00062   struct Pixels {
00063     std::vector<char> intensity;
00064     std::vector<char> alpha;
00065   };
00066   Pixels pixels;
00067   int width;
00068   int height;
00069   double resolution;
00070   ::cartographer::transform::Rigid3d slice_pose;
00071 };
00072 
00073 struct SubmapTextures {
00074   int version;
00075   std::vector<SubmapTexture> textures;
00076 };
00077 
00078 PaintSubmapSlicesResult PaintSubmapSlices(
00079     const std::map<::cartographer::mapping::SubmapId, SubmapSlice>& submaps,
00080     double resolution);
00081 
00082 void FillSubmapSlice(
00083     const ::cartographer::transform::Rigid3d& global_submap_pose,
00084     const ::cartographer::mapping::proto::Submap& proto,
00085     SubmapSlice* const submap_slice,
00086     mapping::ValueConversionTables* conversion_tables);
00087 
00088 void DeserializeAndFillSubmapSlices(
00089     ProtoStreamDeserializer* deserializer,
00090     std::map<::cartographer::mapping::SubmapId, SubmapSlice>* submap_slices,
00091     mapping::ValueConversionTables* conversion_tables);
00092 
00093 // Unpacks cell data as provided by the backend into 'intensity' and 'alpha'.
00094 SubmapTexture::Pixels UnpackTextureData(const std::string& compressed_cells,
00095                                         int width, int height);
00096 
00097 // Draw a texture into a cairo surface. 'cairo_data' will store the pixel data
00098 // for the surface and must therefore outlive the use of the surface.
00099 UniqueCairoSurfacePtr DrawTexture(const std::vector<char>& intensity,
00100                                   const std::vector<char>& alpha, int width,
00101                                   int height,
00102                                   std::vector<uint32_t>* cairo_data);
00103 
00104 }  // namespace io
00105 }  // namespace cartographer
00106 
00107 #endif  // CARTOGRAPHER_IO_SUBMAP_PAINTER_H_


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