Apollo 10.0
自动驾驶开放平台
gps_6d.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
20
21namespace apollo {
22namespace canbus {
23namespace lincoln {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Gps6d::ID = 0x6D;
28
29void Gps6d::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 chassis_detail->mutable_basic()->set_latitude(latitude(bytes, length));
32 chassis_detail->mutable_basic()->set_longitude(longitude(bytes, length));
33 chassis_detail->mutable_basic()->set_gps_valid(is_valid(bytes, length));
34}
35
36double Gps6d::latitude(const std::uint8_t *bytes, int32_t length) const {
37 Byte frame_0(bytes + 3);
38 int32_t value = frame_0.get_byte(0, 7);
39
40 Byte frame_1(bytes + 2);
41 int32_t t = frame_1.get_byte(0, 8);
42 value <<= 8;
43 value |= t;
44
45 Byte frame_2(bytes + 1);
46 t = frame_2.get_byte(0, 8);
47 value <<= 8;
48 value |= t;
49
50 Byte frame_3(bytes);
51 t = frame_3.get_byte(0, 8);
52 value <<= 8;
53 value |= t;
54
55 if (value > 0x3FFFFFFF) {
56 value -= 0x80000000;
57 }
58
59 return value * (1.000000 / 3.000000) * 1e-6;
60}
61
62double Gps6d::longitude(const std::uint8_t *bytes, int32_t length) const {
63 Byte frame_0(bytes + 7);
64 int32_t value = frame_0.get_byte(0, 7);
65
66 Byte frame_1(bytes + 6);
67 int32_t t = frame_1.get_byte(0, 8);
68 value <<= 8;
69 value |= t;
70
71 Byte frame_2(bytes + 5);
72 t = frame_2.get_byte(0, 8);
73 value <<= 8;
74 value |= t;
75
76 Byte frame_3(bytes + 4);
77 t = frame_3.get_byte(0, 8);
78 value <<= 8;
79 value |= t;
80
81 if (value > 0x3FFFFFFF) {
82 value -= 0x80000000;
83 }
84
85 return value * (1.000000 / 3.000000) * 1e-6;
86}
87
88bool Gps6d::is_valid(const std::uint8_t *bytes, int32_t length) const {
89 Byte frame(bytes + 7);
90 return frame.is_bit_1(7);
91}
92
93} // namespace lincoln
94} // namespace canbus
95} // namespace apollo
Defines the Byte class.
static const int32_t ID
Definition gps_6d.h:43
double longitude(const std::uint8_t *bytes, int32_t length) const
get longitude from byte array config detail: {'name': 'longitude', 'offset': 0.0, 'precision': 3....
Definition gps_6d.cc:62
double latitude(const std::uint8_t *bytes, int32_t length) const
get latitude from byte array config detail: {'name': 'latitude', 'offset': 0.0, 'precision': 3....
Definition gps_6d.cc:36
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
Definition gps_6d.cc:29
bool is_valid(const std::uint8_t *bytes, int32_t length) const
check is_valid from byte array config detail: {'name': 'valid', 'offset': 0.0, 'precision': 1....
Definition gps_6d.cc:88
the class of Gps6d (for lincoln vehicle)
class register implement
Definition arena_queue.h:37