Apollo 10.0
自动驾驶开放平台
decode_0A.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 *****************************************************************************/
16
17#include <iostream>
18
20
22 filename1 = "BDDB0A.csv";
23 content1 =
24 "GyroX_degps,GyroY_degps,GyroZ_degps,AccX_g,AccY_g,AccZ_g,T_deg[0],"
25 "SysTime_ms";
26
27 // createFileAndWrite(filename1, content1);
28
29 registProtocol(m_type, m_length, this);
30}
31
33
34void Decode_0A::subData(const uint8_t* sub_address, int& index) {
35 int sub_index = 3;
36 uint8_t check_sum = 0;
37 int dataLength = getLength(m_type);
38 /* check xor */
39 for (int i = 0; i < dataLength - 1; ++i) {
40 check_sum ^= sub_address[i];
41 }
42
43 if (check_sum == sub_address[dataLength - 1]) {
44 int16_t middle;
45 sub_index = 3;
46 // gyro
47 float pubMsg_gx = toValue<float>(sub_address, sub_index);
48 float m_msg_gx = pubMsg_gx;
49 float pubMsg_gy = toValue<float>(sub_address, sub_index);
50 float m_msg_gy = pubMsg_gy;
51 float pubMsg_gz = toValue<float>(sub_address, sub_index);
52 float m_msg_gz = pubMsg_gz;
53
54 // acc
55 float pubMsg_ax = toValue<float>(sub_address, sub_index);
56 float m_msg_ax = pubMsg_ax;
57 float pubMsg_ay = toValue<float>(sub_address, sub_index);
58 float m_msg_ay = pubMsg_ay;
59 float pubMsg_az = toValue<float>(sub_address, sub_index);
60 float m_msg_az = pubMsg_az;
61
62 // temp
63 middle = toValue<int16_t>(sub_address, sub_index);
64 float pubMsg_temperature = middle * 200.0 / 32768;
65
66 // time
67 uint32_t timiddle = toValue<uint32_t>(sub_address, sub_index);
68 double time = timiddle * 2.5 * 0.0001;
69
70 index += dataLength;
71
72 // Do not write csv.
73 // std::vector<std::string> data_w;
74 // data_w.clear();
75 // data_w.push_back(std::to_string(pubMsg_gx));
76 // data_w.push_back(std::to_string(pubMsg_gy));
77 // data_w.push_back(std::to_string(pubMsg_gz));
78 // data_w.push_back(std::to_string(pubMsg_ax));
79 // data_w.push_back(std::to_string(pubMsg_ay));
80 // data_w.push_back(std::to_string(pubMsg_az));
81 // data_w.push_back(std::to_string(pubMsg_temperature));
82 // data_w.push_back(std::to_string(time));
83 // if (AppendCsv(filename1, data_w)) {
84 // // std::cout << "数据成功写入到文件 " << filename << "\n";
85 // } else {
86 // std::cerr << "写入文件时出现错误\n";
87 // }
88
89 } else {
90 index += 3;
91 }
92}
void subData(const uint8_t *sub_address, int &index)
Definition decode_0A.cc:34
virtual ~Decode_0A()
Definition decode_0A.cc:32
bool registProtocol(const std::string &protocolFlag, int length, ProtocolAsensing *sub)
int getLength(const std::string &flag)