Apollo 10.0
自动驾驶开放平台
object_extended_info_60d.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
19#include "glog/logging.h"
23
24namespace apollo {
25namespace drivers {
26namespace conti_radar {
27
29
31const uint32_t ObjectExtendedInfo60D::ID = 0x60D;
32
33void ObjectExtendedInfo60D::Parse(const std::uint8_t* bytes, int32_t length,
34 ContiRadar* conti_radar) const {
35 int obj_id = object_id(bytes, length);
36 for (int i = 0; i < conti_radar->contiobs_size(); ++i) {
37 if (conti_radar->contiobs(i).obstacle_id() == obj_id) {
38 auto obs = conti_radar->mutable_contiobs(i);
39 obs->set_longitude_accel(longitude_accel(bytes, length));
40 obs->set_lateral_accel(lateral_accel(bytes, length));
41 obs->set_oritation_angle(oritation_angle(bytes, length));
42 obs->set_length(object_length(bytes, length));
43 obs->set_width(object_width(bytes, length));
44 obs->set_obstacle_class(obstacle_class(bytes, length));
45 break;
46 }
47 }
48 // auto conti_obs = conti_radar->mutable_contiobs(object_id(bytes, length));
49}
50
51int ObjectExtendedInfo60D::object_id(const std::uint8_t* bytes,
52 int32_t length) const {
53 Byte t0(bytes);
54 int32_t x = t0.get_byte(0, 8);
55
56 int ret = x;
57 return ret;
58}
59
60double ObjectExtendedInfo60D::longitude_accel(const std::uint8_t* bytes,
61 int32_t length) const {
62 Byte t0(bytes + 1);
63 int32_t x = t0.get_byte(0, 8);
64
65 Byte t1(bytes + 2);
66 int32_t t = t1.get_byte(5, 3);
67
68 x <<= 3;
69 x |= t;
70
71 double ret = x * OBJECT_AREL_RES + OBJECT_AREL_LONG_MIN;
72 return ret;
73}
74
75double ObjectExtendedInfo60D::lateral_accel(const std::uint8_t* bytes,
76 int32_t length) const {
77 Byte t0(bytes + 2);
78 int32_t x = t0.get_byte(0, 5);
79
80 Byte t1(bytes + 3);
81 int32_t t = t1.get_byte(4, 4);
82
83 x <<= 4;
84 x |= t;
85
86 double ret = x * OBJECT_AREL_RES + OBJECT_AREL_LAT_MIN;
87 return ret;
88}
89
90int ObjectExtendedInfo60D::obstacle_class(const std::uint8_t* bytes,
91 int32_t length) const {
92 Byte t0(bytes + 3);
93 int32_t x = t0.get_byte(0, 3);
94
95 int ret = x;
96 return ret;
97}
98
99double ObjectExtendedInfo60D::oritation_angle(const std::uint8_t* bytes,
100 int32_t length) const {
101 Byte t0(bytes + 4);
102 int32_t x = t0.get_byte(0, 8);
103
104 Byte t1(bytes + 5);
105 int32_t t = t1.get_byte(6, 2);
106
107 x <<= 2;
108 x |= t;
109
111 return ret;
112}
113
114double ObjectExtendedInfo60D::object_length(const std::uint8_t* bytes,
115 int32_t length) const {
116 Byte t0(bytes + 6);
117 int32_t x = t0.get_byte(0, 8);
118
119 double ret = x * OBJECT_LENGTH_RES;
120 return ret;
121}
122
123double ObjectExtendedInfo60D::object_width(const std::uint8_t* bytes,
124 int32_t length) const {
125 Byte t0(bytes + 7);
126 int32_t x = t0.get_byte(0, 8);
127
128 double ret = x * OBJECT_WIDTH_RES;
129 return ret;
130}
131
132} // namespace conti_radar
133} // namespace drivers
134} // 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, ContiRadar *conti_radar) const override
const double OBJECT_AREL_LONG_MIN
Definition const_vars.h:75
const double OBJECT_ORIENTATION_ANGEL_MIN
Definition const_vars.h:77
const double OBJECT_AREL_LAT_MIN
Definition const_vars.h:76
const double OBJECT_ORIENTATION_ANGEL_RES
Definition const_vars.h:78
class register implement
Definition arena_queue.h:37
repeated ContiRadarObs contiobs