Apollo 10.0
自动驾驶开放平台
gps_6f.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 Gps6f::ID = 0x6F;
28
29void Gps6f::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 chassis_detail->mutable_basic()->set_altitude(altitude(bytes, length));
32 chassis_detail->mutable_basic()->set_heading(heading(bytes, length));
33 // speed mph -> mps
34 chassis_detail->mutable_basic()->set_gps_speed(speed(bytes, length) *
35 0.44704);
36 chassis_detail->mutable_basic()->set_hdop(hdop(bytes, length));
37 chassis_detail->mutable_basic()->set_vdop(vdop(bytes, length));
38 switch (fix_quality(bytes, length)) {
39 case 0:
40 chassis_detail->mutable_basic()->set_quality(FIX_NO);
41 break;
42 case 1:
43 chassis_detail->mutable_basic()->set_quality(FIX_2D);
44 break;
45 case 2:
46 chassis_detail->mutable_basic()->set_quality(FIX_3D);
47 break;
48 default:
49 chassis_detail->mutable_basic()->set_quality(FIX_INVALID);
50 break;
51 }
52 chassis_detail->mutable_basic()->set_num_satellites(
53 num_satellites(bytes, length));
54}
55
56double Gps6f::altitude(const std::uint8_t *bytes, int32_t length) const {
57 Byte high_frame(bytes + 1);
58 int32_t high = high_frame.get_byte(0, 8);
59 Byte low_frame(bytes + 0);
60 int32_t low = low_frame.get_byte(0, 8);
61 int32_t value = (high << 8) | low;
62 if (value > 0x7FFF) {
63 value -= 0x10000;
64 }
65 return value * 0.250000;
66}
67
68double Gps6f::heading(const std::uint8_t *bytes, int32_t length) const {
69 Byte high_frame(bytes + 3);
70 int32_t high = high_frame.get_byte(0, 8);
71 Byte low_frame(bytes + 2);
72 int32_t low = low_frame.get_byte(0, 8);
73 int32_t value = (high << 8) | low;
74 return value * 0.010000;
75}
76
77int32_t Gps6f::speed(const std::uint8_t *bytes, int32_t length) const {
78 Byte frame(bytes + 4);
79 int32_t x = frame.get_byte(0, 8);
80 return x;
81}
82
83double Gps6f::hdop(const std::uint8_t *bytes, int32_t length) const {
84 Byte frame(bytes + 5);
85 int32_t x = frame.get_byte(0, 5);
86 return x * 0.200000;
87}
88
89double Gps6f::vdop(const std::uint8_t *bytes, int32_t length) const {
90 Byte frame(bytes + 6);
91 int32_t x = frame.get_byte(0, 5);
92 return x * 0.200000;
93}
94
95int32_t Gps6f::fix_quality(const std::uint8_t *bytes, int32_t length) const {
96 Byte frame(bytes + 7);
97 int32_t x = frame.get_byte(0, 3);
98 return x;
99}
100
101int32_t Gps6f::num_satellites(const std::uint8_t *bytes, int32_t length) const {
102 Byte frame(bytes + 7);
103 int32_t x = frame.get_byte(3, 5);
104 return x;
105}
106
107} // namespace lincoln
108} // namespace canbus
109} // namespace apollo
Defines the Byte class.
static const int32_t ID
Definition gps_6f.h:43
double vdop(const std::uint8_t *bytes, int32_t length) const
get vdop from byte array config detail: {'name': 'vdop', 'offset': 0.0, 'precision': 0....
Definition gps_6f.cc:89
int32_t num_satellites(const std::uint8_t *bytes, int32_t length) const
get number of satellites from byte array config detail: {'name': 'numsat', 'offset': 0....
Definition gps_6f.cc:101
int32_t speed(const std::uint8_t *bytes, int32_t length) const
get speed from byte array config detail: {'name': 'speed', 'offset': 0.0, 'precision': 1....
Definition gps_6f.cc:77
double hdop(const std::uint8_t *bytes, int32_t length) const
get hdop from byte array config detail: {'name': 'hdop', 'offset': 0.0, 'precision': 0....
Definition gps_6f.cc:83
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
Definition gps_6f.cc:29
int32_t fix_quality(const std::uint8_t *bytes, int32_t length) const
get fix quality from byte array config detail: {'name': 'quality', 'offset': 0.0, 'precision': 1....
Definition gps_6f.cc:95
double altitude(const std::uint8_t *bytes, int32_t length) const
get altitude from byte array config detail: {'name': 'altitude', 'offset': 0.0, 'precision': 0....
Definition gps_6f.cc:56
double heading(const std::uint8_t *bytes, int32_t length) const
get heading from byte array config detail: {'name': 'heading', 'offset': 0.0, 'precision': 0....
Definition gps_6f.cc:68
the class of Gps6f (for lincoln vehicle)
class register implement
Definition arena_queue.h:37