submap_painter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CARTOGRAPHER_IO_SUBMAP_PAINTER_H_
18 #define CARTOGRAPHER_IO_SUBMAP_PAINTER_H_
19 
20 #include "Eigen/Geometry"
21 #include "cairo/cairo.h"
22 #include "cartographer/io/image.h"
24 #include "cartographer/mapping/proto/serialization.pb.h"
26 
27 namespace cartographer {
28 namespace io {
29 
32  Eigen::Array2f origin)
33  : surface(std::move(surface)), origin(origin) {}
35 
36  // Top left pixel of 'surface' in map frame.
37  Eigen::Array2f origin;
38 };
39 
40 struct SubmapSlice {
42  : surface(::cartographer::io::MakeUniqueCairoSurfacePtr(nullptr)) {}
43 
44  // Texture data.
45  int width;
46  int height;
47  int version;
48  double resolution;
51  // Pixel data used by 'surface'. Must outlive 'surface'.
52  std::vector<uint32_t> cairo_data;
53 
54  // Metadata.
56  int metadata_version = -1;
57 };
58 
59 struct SubmapTexture {
60  struct Pixels {
61  std::vector<char> intensity;
62  std::vector<char> alpha;
63  };
65  int width;
66  int height;
67  double resolution;
69 };
70 
72  int version;
73  std::vector<SubmapTexture> textures;
74 };
75 
77  const std::map<::cartographer::mapping::SubmapId, SubmapSlice>& submaps,
78  double resolution);
79 
80 void FillSubmapSlice(
81  const ::cartographer::transform::Rigid3d& global_submap_pose,
82  const ::cartographer::mapping::proto::Submap& proto,
83  SubmapSlice* const submap_slice);
84 
85 // Unpacks cell data as provided by the backend into 'intensity' and 'alpha'.
86 SubmapTexture::Pixels UnpackTextureData(const std::string& compressed_cells,
87  int width, int height);
88 
89 // Draw a texture into a cairo surface. 'cairo_data' will store the pixel data
90 // for the surface and must therefore outlive the use of the surface.
91 UniqueCairoSurfacePtr DrawTexture(const std::vector<char>& intensity,
92  const std::vector<char>& alpha, int width,
93  int height,
94  std::vector<uint32_t>* cairo_data);
95 
96 } // namespace io
97 } // namespace cartographer
98 
99 #endif // CARTOGRAPHER_IO_SUBMAP_PAINTER_H_
Rigid3< double > Rigid3d
::cartographer::transform::Rigid3d pose
std::vector< SubmapTexture > textures
UniqueCairoSurfacePtr MakeUniqueCairoSurfacePtr(cairo_surface_t *surface)
Definition: image.cc:41
PaintSubmapSlicesResult PaintSubmapSlices(const std::map<::cartographer::mapping::SubmapId, SubmapSlice > &submaps, const double resolution)
std::vector< uint32_t > cairo_data
::cartographer::transform::Rigid3d slice_pose
void FillSubmapSlice(const ::cartographer::transform::Rigid3d &global_submap_pose, const ::cartographer::mapping::proto::Submap &proto, SubmapSlice *const submap_slice)
UniqueCairoSurfacePtr DrawTexture(const std::vector< char > &intensity, const std::vector< char > &alpha, const int width, const int height, std::vector< uint32_t > *const cairo_data)
::cartographer::io::UniqueCairoSurfacePtr surface
::cartographer::transform::Rigid3d slice_pose
::cartographer::io::UniqueCairoSurfacePtr surface
PaintSubmapSlicesResult(::cartographer::io::UniqueCairoSurfacePtr surface, Eigen::Array2f origin)
SubmapTexture::Pixels UnpackTextureData(const std::string &compressed_cells, const int width, const int height)
std::unique_ptr< cairo_surface_t, void(*)(cairo_surface_t *)> UniqueCairoSurfacePtr
Definition: image.h:38


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58