00001 /* 00002 * Copyright 2016 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_MAPPING_INTERNAL_3D_SCAN_MATCHING_PRECOMPUTATION_GRID_3D_H_ 00018 #define CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_PRECOMPUTATION_GRID_3D_H_ 00019 00020 #include "cartographer/mapping/3d/hybrid_grid.h" 00021 00022 namespace cartographer { 00023 namespace mapping { 00024 namespace scan_matching { 00025 00026 class PrecomputationGrid3D : public HybridGridBase<uint8> { 00027 public: 00028 explicit PrecomputationGrid3D(const float resolution) 00029 : HybridGridBase<uint8>(resolution) {} 00030 00031 // Maps values from [0, 255] to [kMinProbability, kMaxProbability]. 00032 static float ToProbability(float value) { 00033 return kMinProbability + 00034 value * ((kMaxProbability - kMinProbability) / 255.f); 00035 } 00036 }; 00037 00038 // Converts a HybridGrid to a PrecomputationGrid3D representing the same data, 00039 // but only using 8 bit instead of 2 x 16 bit. 00040 PrecomputationGrid3D ConvertToPrecomputationGrid(const HybridGrid& hybrid_grid); 00041 00042 // Returns a grid of the same resolution containing the maximum value of 00043 // original voxels in 'grid'. This maximum is over the 8 voxels that have 00044 // any combination of index components optionally increased by 'shift'. 00045 // If 'shift' is 2 ** (depth - 1), where depth 0 is the original grid, and this 00046 // is using the precomputed grid of one depth before, this results in 00047 // precomputation grids analogous to the 2D case. 00048 PrecomputationGrid3D PrecomputeGrid(const PrecomputationGrid3D& grid, 00049 bool half_resolution, 00050 const Eigen::Array3i& shift); 00051 00052 } // namespace scan_matching 00053 } // namespace mapping 00054 } // namespace cartographer 00055 00056 #endif // CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_PRECOMPUTATION_GRID_3D_H_