Apollo 11.0
自动驾驶开放平台
asensing_binary_parser.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 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 *****************************************************************************/
18
19namespace apollo {
20namespace drivers {
21namespace gnss {
22
24 public:
25 explicit AsensingBinaryParser(const config::Config &config)
26 : AsensingBaseParser(config) {}
27 bool PrepareMessage() override;
28
29 void FillGnssBestpos() override;
30 void FillIns() override;
31 void FillInsStat() override;
32 void FillImu() override;
33 void FillHeading() override;
34
35 private:
36 ProtocolAsensing asensing;
37 Decode_0A decode_a;
38 Decode_0B decode_b;
39};
40
42 return new AsensingBinaryParser(config);
43}
44
46 asensing.addData(
47 std::string(reinterpret_cast<const char *>(data_), data_end_ - data_));
48 AINFO << "get protocol: " << asensing.getProtocol();
49 if (asensing.getProtocol() != decode_b.m_typeImu) {
50 return false;
51 }
52 if ((decode_b.insdata.InsStatus & 0x0F) == 0x0F) {
54 } else {
56 }
57 if (SolutionType_IsValid(decode_b.insdata.flag_pos)) {
59 } else {
61 }
62 gps_sec_ =
64 return true;
65}
66
68 bestpos_.set_measurement_time(gps_sec_);
69 bestpos_.set_sol_status(solution_status_);
70 bestpos_.set_sol_type(solution_type_);
71 bestpos_.set_latitude(decode_b.insdata.Lat_gnss_deg);
72 bestpos_.set_longitude(decode_b.insdata.Lon_gnss_deg);
73 bestpos_.set_height_msl(decode_b.insdata.Alt_gnss_m);
74
75 if (decode_b.insdata.LoopType == 0) {
76 bestpos_.set_latitude_std_dev(exp(decode_b.insdata.data1 / 100));
77 bestpos_.set_longitude_std_dev(exp(decode_b.insdata.data2 / 100));
78 bestpos_.set_height_std_dev(exp(decode_b.insdata.data3 / 100));
79 }
80 bestpos_.set_differential_age(decode_b.insdata.differential_age);
81 // bestpos_.set_num_sats_tracked(0);
82 // bestpos_.set_num_sats_in_solution(0);
83 // bestpos_.set_num_sats_l1(0);
84 // bestpos_.set_num_sats_multi(0);
85}
86
88 ins_.mutable_euler_angles()->set_x(decode_b.insdata.Roll_deg * DEG_TO_RAD);
89 ins_.mutable_euler_angles()->set_y(-decode_b.insdata.Pitch_deg * DEG_TO_RAD);
90 ins_.mutable_euler_angles()->set_z(
92
93 ins_.mutable_position()->set_lon(decode_b.insdata.Lon_deg);
94 ins_.mutable_position()->set_lat(decode_b.insdata.Lat_deg);
95 ins_.mutable_position()->set_height(decode_b.insdata.Alt_m);
96 ins_.mutable_linear_velocity()->set_x(decode_b.insdata.VelE_mps);
97 ins_.mutable_linear_velocity()->set_y(decode_b.insdata.VelN_mps);
98 ins_.mutable_linear_velocity()->set_z(-decode_b.insdata.VelD_mps);
99 rfu_to_flu(decode_b.insdata.AccX_g, decode_b.insdata.AccY_g,
100 decode_b.insdata.AccZ_g, ins_.mutable_linear_acceleration());
101 rfu_to_flu(decode_b.insdata.GyroX, decode_b.insdata.GyroY,
102 decode_b.insdata.GyroZ, ins_.mutable_angular_velocity());
103 ins_.set_measurement_time(gps_sec_);
104 ins_.mutable_header()->set_timestamp_sec(cyber::Time::Now().ToSecond());
105
106 switch (solution_type_) {
111 ins_.set_type(Ins::GOOD);
112 break;
114 ins_.set_type(Ins::CONVERGING);
115 break;
116 default:
117 ins_.set_type(Ins::INVALID);
118 break;
119 }
120}
121
123 ins_stat_.set_ins_status(solution_status_);
124 ins_stat_.set_pos_type(solution_type_);
125}
126
128 rfu_to_flu(decode_b.insdata.AccX_g, decode_b.insdata.AccY_g,
129 decode_b.insdata.AccZ_g, imu_.mutable_linear_acceleration());
130 rfu_to_flu(decode_b.insdata.GyroX, decode_b.insdata.GyroY,
131 decode_b.insdata.GyroZ, imu_.mutable_angular_velocity());
132 imu_.set_measurement_time(gps_sec_);
133}
134
136 heading_.set_solution_status(solution_status_);
137 heading_.set_position_type(solution_type_);
138 heading_.set_measurement_time(gps_sec_);
139 heading_.set_heading(decode_b.insdata.Yaw_deg);
140 heading_.set_pitch(decode_b.insdata.Pitch_deg);
141
142 if (decode_b.insdata.LoopType == 2) {
143 heading_.set_heading_std_dev(exp(decode_b.insdata.data3 / 100));
144 heading_.set_pitch_std_dev(exp(decode_b.insdata.data2 / 100));
145 }
146
147 // heading_.set_station_id("0");
148 // heading_.set_satellite_number_multi(0);
149 // heading_.set_satellite_soulution_number(0);
150}
151
152} // namespace gnss
153} // namespace drivers
154} // namespace apollo
std::string m_typeImu
std::string getProtocol()
void addData(const std::string &data)
static Time Now()
get the current time.
Definition time.cc:57
static Parser * CreateAsensingBinary(const config::Config &config)
const uint8_t * data_
Definition parser.h:145
const uint8_t * data_end_
Definition parser.h:146
#define AINFO
Definition log.h:42
constexpr double DEG_TO_RAD
void rfu_to_flu(double r, double f, double u, ::apollo::common::Point3D *flu)
constexpr double azimuth_deg_to_yaw_rad(double azimuth)
T unix2gps(const T unix_seconds)
class register implement
Definition arena_queue.h:37
uint8_t InsStatus
double Lon_gnss_deg
double Lat_gnss_deg
float differential_age
uint8_t flag_pos
uint8_t LoopType
int64_t SysTime_ms