Apollo 10.0
自动驾驶开放平台
object_general_info_60b.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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"
20
21#include "cyber/time/time.h"
25
26namespace apollo {
27namespace drivers {
28namespace racobit_radar {
29
31
33const uint32_t ObjectGeneralInfo60B::ID = 0x60B;
34
35void ObjectGeneralInfo60B::Parse(const std::uint8_t* bytes, int32_t length,
36 RacobitRadar* racobit_radar) const {
37 int obj_id = object_id(bytes, length);
38 auto racobit_obs = racobit_radar->add_contiobs();
39 racobit_obs->set_clusterortrack(false);
40 racobit_obs->set_obstacle_id(obj_id);
41 racobit_obs->set_longitude_dist(longitude_dist(bytes, length));
42 racobit_obs->set_lateral_dist(lateral_dist(bytes, length));
43 racobit_obs->set_longitude_vel(longitude_vel(bytes, length));
44 racobit_obs->set_lateral_vel(lateral_vel(bytes, length));
45 racobit_obs->set_rcs(rcs(bytes, length));
46 racobit_obs->set_dynprop(dynprop(bytes, length));
47 double timestamp = apollo::cyber::Time::Now().ToSecond();
48 auto header = racobit_obs->mutable_header();
49 header->CopyFrom(racobit_radar->header());
50 header->set_timestamp_sec(timestamp);
51}
52
53int ObjectGeneralInfo60B::object_id(const std::uint8_t* bytes,
54 int32_t length) const {
55 Byte t0(bytes);
56 int32_t x = t0.get_byte(0, 8);
57
58 int ret = x;
59 return ret;
60}
61
62double ObjectGeneralInfo60B::longitude_dist(const std::uint8_t* bytes,
63 int32_t length) const {
64 Byte t0(bytes + 1);
65 int32_t x = t0.get_byte(0, 8);
66
67 Byte t1(bytes + 2);
68 int32_t t = t1.get_byte(3, 5);
69
70 x <<= 5;
71 x |= t;
72
73 double ret = x * OBJECT_DIST_RES + OBJECT_DIST_LONG_MIN;
74 return ret;
75}
76
77double ObjectGeneralInfo60B::lateral_dist(const std::uint8_t* bytes,
78 int32_t length) const {
79 Byte t0(bytes + 2);
80 int32_t x = t0.get_byte(0, 3);
81
82 Byte t1(bytes + 3);
83 int32_t t = t1.get_byte(0, 8);
84
85 x <<= 8;
86 x |= t;
87
88 double ret = x * OBJECT_DIST_RES + OBJECT_DIST_LAT_MIN;
89 return ret;
90}
91
92double ObjectGeneralInfo60B::longitude_vel(const std::uint8_t* bytes,
93 int32_t length) const {
94 Byte t0(bytes + 4);
95 int32_t x = t0.get_byte(0, 8);
96 Byte t1(bytes + 5);
97 int32_t t = t1.get_byte(6, 2);
98
99 x <<= 2;
100 x |= t;
101 double ret = x * OBJECT_VREL_RES + OBJECT_VREL_LONG_MIN;
102 return ret;
103}
104
105double ObjectGeneralInfo60B::lateral_vel(const std::uint8_t* bytes,
106 int32_t length) const {
107 Byte t0(bytes + 5);
108 int32_t x = t0.get_byte(0, 6);
109
110 Byte t1(bytes + 6);
111 int32_t t = t1.get_byte(5, 3);
112
113 x <<= 3;
114 x |= t;
115
116 double ret = x * OBJECT_VREL_RES + OBJECT_VREL_LAT_MIN;
117 return ret;
118}
119
120double ObjectGeneralInfo60B::rcs(const std::uint8_t* bytes,
121 int32_t length) const {
122 Byte t0(bytes + 7);
123 int32_t x = t0.get_byte(0, 8);
124
125 double ret = x * OBJECT_RCS_RES + OBJECT_RCS_MIN;
126 return ret;
127}
128
129int ObjectGeneralInfo60B::dynprop(const std::uint8_t* bytes,
130 int32_t length) const {
131 Byte t0(bytes + 6);
132 int32_t x = t0.get_byte(0, 3);
133
134 int ret = x;
135 return ret;
136}
137
138} // namespace racobit_radar
139} // namespace drivers
140} // namespace apollo
Defines the Byte class.
static Time Now()
get the current time.
Definition time.cc:57
double ToSecond() const
convert time to second.
Definition time.cc:77
The class of one byte, which is 8 bits.
Definition byte.h:39
void Parse(const std::uint8_t *bytes, int32_t length, RacobitRadar *racobit_radar) const override
class register implement
Definition arena_queue.h:37
optional apollo::common::Header header