Apollo 10.0
自动驾驶开放平台
cluster_general_info_701.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"
20
21#include "cyber/time/time.h"
25
26namespace apollo {
27namespace drivers {
28namespace conti_radar {
29
31
33const uint32_t ClusterGeneralInfo701::ID = 0x701;
34
35void ClusterGeneralInfo701::Parse(const std::uint8_t* bytes, int32_t length,
36 ContiRadar* conti_radar) const {
37 auto obs = conti_radar->add_contiobs();
38 obs->set_clusterortrack(true);
39 obs->set_obstacle_id(obstacle_id(bytes, length));
40 obs->set_longitude_dist(longitude_dist(bytes, length));
41 obs->set_lateral_dist(lateral_dist(bytes, length));
42 obs->set_longitude_vel(longitude_vel(bytes, length));
43 obs->set_lateral_vel(lateral_vel(bytes, length));
44 obs->set_rcs(rcs(bytes, length));
45 obs->set_dynprop(dynprop(bytes, length));
46 double timestamp = apollo::cyber::Time::Now().ToSecond();
47 auto header = obs->mutable_header();
48 header->CopyFrom(conti_radar->header());
49 header->set_timestamp_sec(timestamp);
50}
51
52int ClusterGeneralInfo701::obstacle_id(const std::uint8_t* bytes,
53 int32_t length) const {
54 Byte t0(bytes);
55 uint32_t x = t0.get_byte(0, 8);
56
57 int ret = x;
58 return ret;
59}
60
61double ClusterGeneralInfo701::longitude_dist(const std::uint8_t* bytes,
62 int32_t length) const {
63 Byte t0(bytes + 1);
64 uint32_t x = t0.get_byte(0, 8);
65
66 Byte t1(bytes + 2);
67 uint32_t t = t1.get_byte(3, 5);
68 x <<= 5;
69 x |= t;
70 double ret = x * CLUSTER_DIST_RES + CLUSTER_DIST_LONG_MIN;
71 return ret;
72}
73
74double ClusterGeneralInfo701::lateral_dist(const std::uint8_t* bytes,
75 int32_t length) const {
76 Byte t0(bytes + 2);
77 uint32_t x = t0.get_byte(0, 2);
78
79 Byte t1(bytes + 3);
80 uint32_t t = t1.get_byte(0, 8);
81 x <<= 8;
82 x |= t;
83 double ret = x * CLUSTER_DIST_RES + CLUSTER_DIST_LAT_MIN;
84 return ret;
85}
86
87double ClusterGeneralInfo701::longitude_vel(const std::uint8_t* bytes,
88 int32_t length) const {
89 Byte t0(bytes + 4);
90 uint32_t x = t0.get_byte(0, 8);
91
92 Byte t1(bytes + 5);
93 uint32_t t = t1.get_byte(6, 2);
94 x <<= 2;
95 x |= t;
96 double ret = x * CLUSTER_VREL_RES + CLUSTER_VREL_LONG_MIN;
97 return ret;
98}
99
100double ClusterGeneralInfo701::lateral_vel(const std::uint8_t* bytes,
101 int32_t length) const {
102 Byte t0(bytes + 5);
103 uint32_t x = t0.get_byte(0, 6);
104
105 Byte t1(bytes + 6);
106 uint32_t t = t1.get_byte(5, 3);
107 x <<= 3;
108 x |= t;
109 double ret = x * CLUSTER_VREL_RES + CLUSTER_VREL_LAT_MIN;
110 return ret;
111}
112
113double ClusterGeneralInfo701::rcs(const std::uint8_t* bytes,
114 int32_t length) const {
115 Byte t0(bytes + 7);
116 uint32_t x = t0.get_byte(0, 8);
117 double ret = x * CLUSTER_RCS_RES + CLUSTER_RCS;
118 return ret;
119}
120
121int ClusterGeneralInfo701::dynprop(const std::uint8_t* bytes,
122 int32_t length) const {
123 Byte t0(bytes + 6);
124 uint32_t x = t0.get_byte(0, 3);
125 int ret = x;
126 return ret;
127}
128
129} // namespace conti_radar
130} // namespace drivers
131} // 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, ContiRadar *conti_radar) const override
const double CLUSTER_DIST_LAT_MIN
Definition const_vars.h:56
const double CLUSTER_VREL_LONG_MIN
Definition const_vars.h:58
const double CLUSTER_DIST_LONG_MIN
Definition const_vars.h:55
const double CLUSTER_VREL_LAT_MIN
Definition const_vars.h:59
class register implement
Definition arena_queue.h:37
optional apollo::common::Header header