Apollo 10.0
自动驾驶开放平台
apollo::drivers::lslidar::parser::LslidarCXV4Parser类 参考

#include <lslidar_parser.h>

类 apollo::drivers::lslidar::parser::LslidarCXV4Parser 继承关系图:
apollo::drivers::lslidar::parser::LslidarCXV4Parser 的协作图:

Public 成员函数

 LslidarCXV4Parser (const Config &config)
 
 ~LslidarCXV4Parser ()
 
void decodePacket (const RawPacket_C32 *packet)
 
void GeneratePointcloud (const std::shared_ptr< apollo::drivers::lslidar::LslidarScan > &scan_msg, const std::shared_ptr< apollo::drivers::PointCloud > &out_msg)
 
void Order (std::shared_ptr< apollo::drivers::PointCloud > cloud)
 
bool checkPacketValidity (const RawPacket_C32 *packet)
 
- Public 成员函数 继承自 apollo::drivers::lslidar::parser::LslidarParser
 LslidarParser ()
 
 LslidarParser (const Config &config)
 
virtual ~LslidarParser ()
 
virtual void GeneratePointcloud (const std::shared_ptr< LslidarScan > &scan_msg, const std::shared_ptr< apollo::drivers::PointCloud > &out_msg)=0
 Set up for data processing.
 
virtual void setup ()
 Set up for on-line operation.
 
const double get_last_timestamp ()
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::drivers::lslidar::parser::LslidarParser
bool is_scan_valid (int rotation, float distance)
 
void ComputeCoords (const float &raw_distance, LaserCorrection *corrections, const uint16_t rotation, PointXYZIT *point)
 
void ComputeCoords2 (int Laser_ring, int Type, const float &raw_distance, LaserCorrection *corrections, const double rotation, PointXYZIT *point)
 
- Protected 属性 继承自 apollo::drivers::lslidar::parser::LslidarParser
double scan_altitude [16]
 
float sin_azimuth_table [ROTATION_MAX_UNITS]
 
float cos_azimuth_table [ROTATION_MAX_UNITS]
 
double cos_scan_altitude_caliration [LSC32_SCANS_PER_FIRING]
 
double sin_scan_altitude_caliration [LSC32_SCANS_PER_FIRING]
 
double last_time_stamp_
 
double theat1_s [128]
 
double theat2_s [128]
 
double theat1_c [128]
 
double theat2_c [128]
 
double prism_angle [4]
 
double prism_angle64 [4]
 
Config config_
 
Calibration calibration_
 
bool need_two_pt_correction_
 
bool config_vert_angle
 
uint64_t current_packet_time = 0
 
uint64_t previous_packet_time = 0
 

详细描述

在文件 lslidar_parser.h623 行定义.

构造及析构函数说明

◆ LslidarCXV4Parser()

apollo::drivers::lslidar::parser::LslidarCXV4Parser::LslidarCXV4Parser ( const Config config)
explicit

在文件 lslidarCXV4_parser.cc24 行定义.

24 :
25 LslidarParser(config), previous_packet_stamp_(0), gps_base_usec_(0) {
26 vertical_angle_ = config.vertical_angle();
27 distance_unit_ = config.distance_unit();
28 is_new_c32w_ = true;
29 is_get_scan_altitude_ = false;
30 AERROR << "vertical_angle_ " << vertical_angle_;
31 if (config_.model() == LSLIDAR_C16_V4) {
32 lidar_number_ = 16;
33 AERROR << "lidar: c16";
34 for (int i = 0; i < 16; ++i) {
35 sin_scan_altitude[i] = sin(c16_vertical_angle[i] * DEG_TO_RAD);
36 cos_scan_altitude[i] = cos(c16_vertical_angle[i] * DEG_TO_RAD);
37 }
38 } else if (config_.model() == LSLIDAR_C8_V4) {
39 lidar_number_ = 8;
40 AERROR << "lidar: c8";
41 for (int i = 0; i < 8; ++i) {
42 sin_scan_altitude[i] = sin(c8_vertical_angle[i] * DEG_TO_RAD);
43 cos_scan_altitude[i] = cos(c8_vertical_angle[i] * DEG_TO_RAD);
44 }
45 } else if (config_.model() == LSLIDAR_C1_V4) {
46 lidar_number_ = 1;
47 AERROR << "lidar: c1";
48 for (int i = 0; i < 8; ++i) {
49 sin_scan_altitude[i] = sin(c1_vertical_angle[i] * DEG_TO_RAD);
50 cos_scan_altitude[i] = cos(c1_vertical_angle[i] * DEG_TO_RAD);
51 }
52 } else if (config_.model() == LSLIDAR_C32_V4) {
53 lidar_number_ = 32;
54 if (32 == config.vertical_angle()) {
55 AERROR << "Vertical angle: 32 degrees";
56 for (int i = 0; i < 32; ++i) {
57 sin_scan_altitude[i]
58 = sin(c32_32_vertical_angle[i] * DEG_TO_RAD);
59 cos_scan_altitude[i]
60 = cos(c32_32_vertical_angle[i] * DEG_TO_RAD);
61 }
62 } else if (70 == config.vertical_angle()) {
63 AERROR << "Vertical angle: 70 degrees";
64 for (int k = 0; k < 32; ++k) {
65 sin_scan_altitude[k]
66 = sin(c32_70_vertical_angle2[k] * DEG_TO_RAD);
67 cos_scan_altitude[k]
68 = cos(c32_70_vertical_angle2[k] * DEG_TO_RAD);
69 }
70 } else if (90 == config.vertical_angle()) {
71 AERROR << "Vertical angle: 90 degrees";
72 for (int k = 0; k < 32; ++k) {
73 sin_scan_altitude[k]
74 = sin(c32_90_vertical_angle[k] * DEG_TO_RAD);
75 cos_scan_altitude[k]
76 = cos(c32_90_vertical_angle[k] * DEG_TO_RAD);
77 }
78 }
79 }
80
81 // create the sin and cos table for different azimuth values
82 for (int j = 0; j < 36000; ++j) {
83 double angle = static_cast<double>(j) / 100.0 * DEG_TO_RAD;
84 sin_azimuth_table[j] = sin(angle);
85 cos_azimuth_table[j] = cos(angle);
86 }
87 config_vert_angle = false;
88 lslidar_type = 2;
89}
#define AERROR
Definition log.h:44
#define DEG_TO_RAD
float cos(Angle16 a)
Definition angle.cc:42
float sin(Angle16 a)
Definition angle.cc:25

◆ ~LslidarCXV4Parser()

apollo::drivers::lslidar::parser::LslidarCXV4Parser::~LslidarCXV4Parser ( )
inline

在文件 lslidar_parser.h626 行定义.

626{}

成员函数说明

◆ checkPacketValidity()

bool apollo::drivers::lslidar::parser::LslidarCXV4Parser::checkPacketValidity ( const RawPacket_C32 packet)

在文件 lslidarCXV4_parser.cc158 行定义.

158 {
159 for (size_t blk_idx = 0; blk_idx < BLOCKS_PER_PACKET; ++blk_idx) {
160 if (packet->blocks[blk_idx].header != UPPER_BANK) {
161 return false;
162 }
163 }
164 return true;
165}
constexpr int BLOCKS_PER_PACKET
Definition driver.h:37

◆ decodePacket()

void apollo::drivers::lslidar::parser::LslidarCXV4Parser::decodePacket ( const RawPacket_C32 packet)

在文件 lslidarCXV4_parser.cc91 行定义.

91 {
92 // couputer azimuth angle for each firing, 12
93 for (size_t b_idx = 0; b_idx < BLOCKS_PER_PACKET; ++b_idx) {
94 firings.firing_azimuth[b_idx] = packet->blocks[b_idx].rotation
95 % 36000; //* 0.01 * DEG_TO_RAD;
96 }
97 for (size_t block_idx = 0; block_idx < BLOCKS_PER_PACKET; ++block_idx) {
98 const RawBlock &raw_block = packet->blocks[block_idx];
99
100 int32_t azimuth_diff_b = 0;
101 if (config_.return_mode() == 1) {
102 if (block_idx < BLOCKS_PER_PACKET - 1) {
103 azimuth_diff_b = firings.firing_azimuth[block_idx + 1]
104 - firings.firing_azimuth[block_idx];
105 azimuth_diff_b = azimuth_diff_b < 0 ? azimuth_diff_b + 36000
106 : azimuth_diff_b;
107
108 } else {
109 azimuth_diff_b = firings.firing_azimuth[block_idx]
110 - firings.firing_azimuth[block_idx - 1];
111
112 azimuth_diff_b = azimuth_diff_b < 0 ? azimuth_diff_b + 36000
113 : azimuth_diff_b;
114 }
115 } else {
116 // return mode 2
117 if (block_idx < BLOCKS_PER_PACKET - 2) {
118 azimuth_diff_b = firings.firing_azimuth[block_idx + 2]
119 - firings.firing_azimuth[block_idx];
120 azimuth_diff_b = azimuth_diff_b < 0 ? azimuth_diff_b + 36000
121 : azimuth_diff_b;
122
123 } else {
124 azimuth_diff_b = firings.firing_azimuth[block_idx]
125 - firings.firing_azimuth[block_idx - 2];
126
127 azimuth_diff_b = azimuth_diff_b < 0 ? azimuth_diff_b + 36000
128 : azimuth_diff_b;
129 }
130 }
131
132 // 32 scan
133 for (size_t scan_fir_idx = 0; scan_fir_idx < SCANS_PER_FIRING_C32;
134 ++scan_fir_idx) {
135 size_t byte_idx = RAW_SCAN_SIZE * scan_fir_idx;
136 // azimuth
137 firings.azimuth[block_idx * 32 + scan_fir_idx]
138 = firings.firing_azimuth[block_idx]
139 + scan_fir_idx * azimuth_diff_b / FIRING_TOFFSET_C32;
140 firings.azimuth[block_idx * 32 + scan_fir_idx]
141 = firings.azimuth[block_idx * 32 + scan_fir_idx] % 36000;
142 // distance
143 TwoBytes raw_distance{};
144 raw_distance.bytes[0] = raw_block.data[byte_idx];
145 raw_distance.bytes[1] = raw_block.data[byte_idx + 1];
146 firings.distance[block_idx * 32 + scan_fir_idx]
147 = static_cast<double>(raw_distance.distance)
148 * DISTANCE_RESOLUTION * distance_unit_;
149
150 // intensity
151 firings.intensity[block_idx * 32 + scan_fir_idx]
152 = static_cast<double>(raw_block.data[byte_idx + 2]);
153 }
154 }
155 return;
156}
uint16_t firing_azimuth[BLOCKS_PER_PACKET]

◆ GeneratePointcloud()

void apollo::drivers::lslidar::parser::LslidarCXV4Parser::GeneratePointcloud ( const std::shared_ptr< apollo::drivers::lslidar::LslidarScan > &  scan_msg,
const std::shared_ptr< apollo::drivers::PointCloud > &  out_msg 
)

在文件 lslidarCXV4_parser.cc167 行定义.

169 {
170 // allocate a point cloud with same time and frame ID as raw data
171 out_msg->mutable_header()->set_timestamp_sec(
172 scan_msg->basetime() / 1000000000.0);
173 out_msg->mutable_header()->set_module_name(
174 scan_msg->header().module_name());
175 out_msg->mutable_header()->set_frame_id(scan_msg->header().frame_id());
176 out_msg->set_height(1);
177 out_msg->set_measurement_time(scan_msg->basetime() / 1000000000.0);
178 out_msg->mutable_header()->set_sequence_num(
179 scan_msg->header().sequence_num());
180 gps_base_usec_ = scan_msg->basetime();
181
182 const unsigned char *difop_ptr
183 = (const unsigned char *)scan_msg->difop_pkts(0).data().c_str();
184 if (difop_ptr[0] == 0xa5 && difop_ptr[1] == 0xff && difop_ptr[2] == 0x00
185 && difop_ptr[3] == 0x5a) {
186 AINFO << "设备包,暂时用不上..."; // todo 暂时不用设备包
187 }
188
189 size_t packets_size = scan_msg->firing_pkts_size();
190 block_num = 0;
191 packet_number_ = packets_size;
192
193 AINFO << "packets_size :" << packets_size;
194
195 for (size_t i = 0; i < packets_size; ++i) {
196 Unpack(scan_msg->firing_pkts(static_cast<int>(i)), out_msg, i);
197 last_time_stamp_ = out_msg->measurement_time();
198 ADEBUG << "stamp: " << std::fixed << last_time_stamp_;
199 }
200
201 if (out_msg->point().empty()) {
202 // we discard this pointcloud if empty
203 AERROR << "All points is NAN!Please check lslidar:" << config_.model();
204 }
205
206 // set default width
207 out_msg->set_width(out_msg->point_size());
208}
#define ADEBUG
Definition log.h:41
#define AINFO
Definition log.h:42

◆ Order()

void apollo::drivers::lslidar::parser::LslidarCXV4Parser::Order ( std::shared_ptr< apollo::drivers::PointCloud cloud)
virtual

实现了 apollo::drivers::lslidar::parser::LslidarParser.

在文件 lslidarCXV4_parser.cc364 行定义.

364 {
365 int width = 32;
366 cloud->set_width(width);
367 int height = cloud->point_size() / cloud->width();
368 cloud->set_height(height);
369
370 std::shared_ptr<PointCloud> cloud_origin = std::make_shared<PointCloud>();
371 cloud_origin->CopyFrom(*cloud);
372
373 for (int i = 0; i < width; ++i) {
374 int col = ORDER_32[i];
375
376 for (int j = 0; j < height; ++j) {
377 // make sure offset is initialized, should be init at setup() just
378 // once
379 int target_index = j * width + i;
380 int origin_index = j * width + col;
381 cloud->mutable_point(target_index)
382 ->CopyFrom(cloud_origin->point(origin_index));
383 }
384 }
385}
uint32_t height
Height of point cloud
uint32_t width
Width of point cloud

该类的文档由以下文件生成: