Apollo 10.0
自动驾驶开放平台
common.h
浏览该文件的文档.
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#pragma once
17
18#include <cmath>
19#include <ctime>
20
21#include <iostream>
22#include <memory>
23#include <set>
24#include <string>
25#include <utility>
26#include <vector>
27
28#include <boost/filesystem.hpp>
29#include <boost/property_tree/json_parser.hpp>
30#include <boost/property_tree/ptree.hpp>
31
32#include "cyber/cyber.h"
33
34namespace apollo {
35namespace hdmap {
36
37constexpr double kRADIANS_TO_DEGREES = 180.0 / M_PI;
38constexpr double kDEGRESS_TO_RADIANS = M_PI / 180.0;
39
40typedef unsigned char uchar;
41
42struct FramePose {
43 double time_stamp; // unix time
44 double tx, ty, tz;
45 double qx, qy, qz, qw;
47 double velx, vely, velz;
48 double roll, pitch, azimuth;
49 unsigned int ins_status;
50 unsigned int solution_status;
51 unsigned int position_type;
52 float diff_age;
53 double local_std;
54};
55
56enum class State { IDLE, RUNNING };
57
58struct JsonConf {
59 std::vector<std::pair<std::string, double>> topic_list;
62
63 unsigned int solution_status;
64 std::set<unsigned int> position_type_range;
65 std::pair<float, float> diff_age_range;
67
68 /*Period of channel check trigger. The unit is seconds.*/
70 /*Period of alignment, The unit is seconds.
71 Eight route maneuver is also included in the alignment process.*/
73 /*the time that static alignment must last. The unit is seconds.*/
75 /*the maximum time that bad pose included in static alignment.
76 The unit is seconds.*/
78 /*Maximum Motion Distance Tolerated by Static Alignment*/
80
81 /*Angle threshold between adjacent frames in eight route. The unit is degree*/
83 /*the time that eight route must last,The unit is seconds.*/
85 /*Minimum speed should be achieved in eight route*/
86 double eight_vel;
87 /*The tolerance of bad pose in eight route. The unit is frame*/
89
90 /*Minimum frame number threshold for acquisition of multiple loops*/
92 /*The angle error of adjacent poses on the same trajectory should not be
93 greater than alpha_err_thresh. The unit is degree*/
95 /*The time stamp interval of adjacent poses on the same track should not be
96 greater than time_err_thresh. The unit is minutes.*/
98 /*The diameter of the searched square area*/
100 /*loops to check*/
102 /*additional loops to check*/
104 /*Proportional thresholds for all required points
105 in acquisition cycle checking*/
107};
108
109std::shared_ptr<JsonConf> ParseJson(std::string conf_path);
110
111inline double GetYaw(double from_x, double from_y, double to_x, double to_y) {
112 double vecx = to_x - from_x;
113 double vecy = to_y - from_y;
114 double alpha = acos(vecy / sqrt(vecx * vecx + vecy * vecy));
115 if (vecx < 0) {
116 alpha = 2 * M_PI - alpha;
117 }
118 return kRADIANS_TO_DEGREES * alpha;
119}
120
121inline double UnixNow() { return apollo::cyber::Time::Now().ToSecond(); }
122
123} // namespace hdmap
124} // namespace apollo
static Time Now()
get the current time.
Definition time.cc:57
double ToSecond() const
convert time to second.
Definition time.cc:77
unsigned char uchar
Definition common.h:40
constexpr double kRADIANS_TO_DEGREES
Definition common.h:37
double UnixNow()
std::shared_ptr< JsonConf > ParseJson(std::string conf_path)
Definition common.cc:23
double GetYaw(double from_x, double from_y, double to_x, double to_y)
Definition common.h:111
constexpr double kDEGRESS_TO_RADIANS
Definition common.h:38
class register implement
Definition arena_queue.h:37
unsigned int position_type
Definition common.h:51
unsigned int solution_status
Definition common.h:50
unsigned int ins_status
Definition common.h:49
double static_align_duration
Definition common.h:74
double laps_time_err_thresh
Definition common.h:97
std::pair< float, float > diff_age_range
Definition common.h:65
std::vector< std::pair< std::string, double > > topic_list
Definition common.h:59
double local_std_upper_limit
Definition common.h:66
double laps_alpha_err_thresh
Definition common.h:94
unsigned int solution_status
Definition common.h:63
double static_align_tolerance
Definition common.h:77
double static_align_dist_thresh
Definition common.h:79
std::set< unsigned int > position_type_range
Definition common.h:64
int alignment_featch_pose_sleep
Definition common.h:72
double topic_rate_tolerance
Definition common.h:61