Apollo 10.0
自动驾驶开放平台
region_state_402.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2021 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 "math.h"
19
20#include "glog/logging.h"
21
25
26namespace apollo {
27namespace drivers {
28namespace nano_radar {
29
31
33const uint32_t CollisionDetectionRegionState402::ID = 0x402;
34
35void CollisionDetectionRegionState402::Parse(const std::uint8_t* bytes,
36 int32_t length,
37 NanoRadar* nano_radar) const {
38 auto state = nano_radar->mutable_radar_region_state();
39 state->set_region_id(region_id(bytes, length));
40 state->set_region_max_output_number(region_max_output_number(bytes, length));
41 state->set_point1_longitude(point1_longitude(bytes, length));
42 state->set_point1_lateral(floor(point1_lateral(bytes, length)));
43 state->set_point2_longitude(point2_longitude(bytes, length));
44 state->set_point2_lateral(floor(point2_lateral(bytes, length)));
45}
46
47int CollisionDetectionRegionState402::region_id(const std::uint8_t* bytes,
48 int32_t length) const {
49 Byte t0(bytes);
50 uint32_t x = t0.get_byte(6, 2);
51
52 int ret = x;
53 return ret;
54}
55
56int CollisionDetectionRegionState402::region_max_output_number(
57 const std::uint8_t* bytes, int32_t length) const {
58 Byte t0(bytes);
59 uint32_t x = t0.get_byte(0, 5);
60
61 int ret = x;
62 return ret;
63}
64
65double CollisionDetectionRegionState402::point1_longitude(
66 const std::uint8_t* bytes, int32_t length) const {
67 Byte t0(bytes + 1);
68 int32_t x = t0.get_byte(0, 8);
69
70 Byte t1(bytes + 2);
71 int32_t t = t1.get_byte(3, 5);
72
73 x <<= 5;
74 x |= t;
75
76 double ret = x * REGION_POINT_RES + REGION_POINT_LONG_MIN;
77 return ret;
78}
79
80double CollisionDetectionRegionState402::point1_lateral(
81 const std::uint8_t* bytes, int32_t length) const {
82 Byte t0(bytes + 2);
83 int32_t x = t0.get_byte(0, 3);
84
85 Byte t1(bytes + 3);
86 int32_t t = t1.get_byte(0, 8);
87
88 x <<= 8;
89 x |= t;
90
91 double ret = x * REGION_POINT_RES + REGION_POINT_LAT_MIN;
92 return ret;
93}
94
95double CollisionDetectionRegionState402::point2_longitude(
96 const std::uint8_t* bytes, int32_t length) const {
97 Byte t0(bytes + 4);
98 int32_t x = t0.get_byte(0, 8);
99
100 Byte t1(bytes + 5);
101 int32_t t = t1.get_byte(3, 5);
102
103 x <<= 5;
104 x |= t;
105
106 double ret = x * REGION_POINT_RES + REGION_POINT_LONG_MIN;
107 return ret;
108}
109
110double CollisionDetectionRegionState402::point2_lateral(
111 const std::uint8_t* bytes, int32_t length) const {
112 Byte t0(bytes + 5);
113 int32_t x = t0.get_byte(0, 3);
114
115 Byte t1(bytes + 6);
116 int32_t t = t1.get_byte(0, 8);
117
118 x <<= 8;
119 x |= t;
120
121 double ret = x * REGION_POINT_RES + REGION_POINT_LAT_MIN;
122 return ret;
123}
124
125} // namespace nano_radar
126} // namespace drivers
127} // namespace apollo
Defines the Byte class.
The class of one byte, which is 8 bits.
Definition byte.h:39
void Parse(const std::uint8_t *bytes, int32_t length, NanoRadar *nano_radar) const override
const double REGION_POINT_RES
Definition const_vars.h:58
const double REGION_POINT_LAT_MIN
Definition const_vars.h:60
const double REGION_POINT_LONG_MIN
Definition const_vars.h:59
class register implement
Definition arena_queue.h:37