Apollo 10.0
自动驾驶开放平台
common.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 *****************************************************************************/
17
18#include "cyber/cyber.h"
19
20namespace apollo {
21namespace hdmap {
22
23std::shared_ptr<JsonConf> ParseJson(std::string conf_path) {
24 AINFO << "parsing json config";
25 boost::filesystem::path path(conf_path);
26 if (!boost::filesystem::exists(path)) {
27 AERROR << "json config file " << conf_path << " does not exist";
28 return nullptr;
29 }
30
31 std::shared_ptr<JsonConf> conf(new JsonConf);
32 boost::property_tree::ptree pt;
33 try {
34 boost::property_tree::read_json(conf_path, pt);
35 conf->use_system_time = pt.get<bool>("use_system_time");
36 conf->topic_rate_tolerance = pt.get<double>("topic_rate_tolerance");
37 boost::property_tree::ptree children2 = pt.get_child("topic_list");
38 for (auto it = children2.begin(); it != children2.end(); ++it) {
39 conf->topic_list.push_back(
40 std::make_pair(it->first, it->second.get_value<double>()));
41 }
42
43 conf->solution_status = pt.get<unsigned int>("solution_status");
44
45 boost::property_tree::ptree position_type = pt.get_child("position_type");
46 for (auto it = position_type.begin(); it != position_type.end(); ++it) {
47 conf->position_type_range.insert(it->second.get_value<unsigned int>());
48 }
49
50 conf->local_std_upper_limit = pt.get<double>("local_std_upper_limit");
51
52 boost::property_tree::ptree diff_age = pt.get_child("diff_age");
53 {
54 auto it = diff_age.begin();
55 conf->diff_age_range.first = it->second.get_value<float>();
56 ++it;
57 conf->diff_age_range.second = it->second.get_value<float>();
58 }
59
60 conf->channel_check_trigger_gap = pt.get<int>("channel_check_trigger_gap");
61 conf->alignment_featch_pose_sleep =
62 pt.get<int>("alignment_featch_pose_sleep");
63 conf->static_align_duration = pt.get<double>("static_align_duration");
64 conf->static_align_tolerance = pt.get<double>("static_align_tolerance");
65 conf->static_align_dist_thresh = pt.get<double>("static_align_dist_thresh");
66
67 conf->eight_angle = pt.get<double>("eight_angle");
68 conf->eight_duration = pt.get<double>("eight_duration");
69 conf->eight_vel = pt.get<double>("eight_vel");
70 conf->eight_bad_pose_tolerance = pt.get<int>("eight_bad_pose_tolerance");
71
72 conf->laps_frames_thresh = pt.get<int>("laps_frames_thresh");
73 conf->laps_alpha_err_thresh = pt.get<double>("laps_alpha_err_thresh");
74 conf->laps_time_err_thresh = pt.get<double>("laps_time_err_thresh");
75 conf->laps_search_diameter = pt.get<int>("laps_search_diameter");
76 conf->laps_number = pt.get<int>("laps_number");
77 conf->laps_number_additional = pt.get<int>("laps_number_additional");
78 conf->laps_rate_thresh = pt.get<double>("laps_rate_thresh");
79 } catch (const boost::property_tree::json_parser_error& e) {
80 AERROR << e.what();
81 return nullptr;
82 } catch (const std::exception& e) {
83 AERROR << e.what();
84 return nullptr;
85 }
86 return conf;
87}
88
89} // namespace hdmap
90} // namespace apollo
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
std::shared_ptr< JsonConf > ParseJson(std::string conf_path)
Definition common.cc:23
class register implement
Definition arena_queue.h:37