Apollo 10.0
自动驾驶开放平台
ndt_map_config.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 The Apollo Authors. All Rights Reserved.
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
18
19#include <algorithm>
20#include <string>
21
22namespace apollo {
23namespace localization {
24namespace msf {
25namespace pyramid_map {
26
27NdtMapConfig::NdtMapConfig(std::string map_version)
28 : BaseMapConfig(map_version) {
30 map_resolutions_z_.push_back(1.0f);
31}
32
33void NdtMapConfig::SetSingleResolutionZ(float resolution) {
34 map_resolutions_z_.clear();
35 map_resolutions_z_.push_back(resolution);
36}
37
39 map_resolutions_z_.clear();
40 map_resolutions_z_.push_back(0.03125);
41 map_resolutions_z_.push_back(0.0625);
42 map_resolutions_z_.push_back(0.125);
43 map_resolutions_z_.push_back(0.25);
44 map_resolutions_z_.push_back(0.5);
45 map_resolutions_z_.push_back(1);
46 map_resolutions_z_.push_back(2);
47 map_resolutions_z_.push_back(4);
48 map_resolutions_z_.push_back(8);
49 map_resolutions_z_.push_back(16);
50}
51
52bool NdtMapConfig::CreateXml(boost::property_tree::ptree* config) const {
54 config->put("map.map_config.compression", map_is_compression_);
55 for (size_t i = 0; i < map_resolutions_.size(); ++i) {
56 config->add("map.map_config.resolutions_z.resolution",
58 }
59 return true;
60}
61
62bool NdtMapConfig::LoadXml(boost::property_tree::ptree* config) {
64 map_is_compression_ = config->get<bool>("map.map_config.compression");
65 map_resolutions_z_.clear();
66 const auto& resolutions_z = config->get_child("map.map_config.resolutions_z");
67 std::for_each(resolutions_z.begin(), resolutions_z.end(),
68 [this](const boost::property_tree::ptree::value_type& v) {
69 map_resolutions_z_.push_back(
70 static_cast<float>(atof(v.second.data().c_str())));
71 });
72 return true;
73}
74
75} // namespace pyramid_map
76} // namespace msf
77} // namespace localization
78} // namespace apollo
virtual bool CreateXml(boost::property_tree::ptree *config) const
Create the XML structure.
std::vector< float > map_resolutions_
The pixel resolutions in the map in meters.
virtual bool LoadXml(const boost::property_tree::ptree &config)
Load the map options from a XML structure.
virtual bool LoadXml(boost::property_tree::ptree *config)
Load the map options from a XML structure.
void SetSingleResolutionZ(float resolution=1.0f)
Set single resolutions.
std::vector< float > map_resolutions_z_
The resolution of z-axis.
virtual bool CreateXml(boost::property_tree::ptree *config) const
Create the XML structure.
NdtMapConfig(std::string map_version="0.1")
The constructor gives the default map settings.
class register implement
Definition arena_queue.h:37