25 LslidarParser(config), previous_packet_stamp_(0), gps_base_usec_(0) {
26 point_time_diff = 1 / (60.0 * 1000 * 32);
27 for (
int i = 0; i < 4; ++i) {
30 for (
int j = 0; j < 128; ++j) {
32 theat1_s[j] = sin((-25 + floor(j / 8) * 2.5) * M_PI / 180);
34 theat1_c[j] = cos((-25 + floor(j / 8) * 2.5) * M_PI / 180);
37 theat1_s[j] = sin((-24 + floor(j / 8) * 2.5) * M_PI / 180);
39 theat1_c[j] = cos((-24 + floor(j / 8) * 2.5) * M_PI / 180);
46 const std::shared_ptr<LslidarScan>& scan_msg,
47 const std::shared_ptr<PointCloud>& out_msg) {
49 out_msg->mutable_header()->set_timestamp_sec(
50 scan_msg->basetime() / 1000000000.0);
51 out_msg->mutable_header()->set_module_name(
52 scan_msg->header().module_name());
53 out_msg->mutable_header()->set_frame_id(scan_msg->header().frame_id());
54 out_msg->set_height(1);
55 out_msg->set_measurement_time(scan_msg->basetime() / 1000000000.0);
56 out_msg->mutable_header()->set_sequence_num(
57 scan_msg->header().sequence_num());
58 gps_base_usec_ = scan_msg->basetime();
60 packets_size = scan_msg->firing_pkts_size();
61 AINFO <<
"packets_size :" << packets_size;
62 for (
size_t i = 0; i < packets_size; ++i) {
63 Unpack(
static_cast<int>(i),
64 scan_msg->firing_pkts(
static_cast<int>(i)),
69 if (out_msg->point().empty()) {
75 out_msg->set_width(out_msg->point_size());
82void LslidarCH64wParser::Unpack(
85 std::shared_ptr<PointCloud> pc) {
88 uint64_t packet_end_time;
102 packet_end_time = pkt.
stamp();
106 for (
size_t point_idx = 0; point_idx < POINTS_PER_PACKET; point_idx++) {
117 point_distance.
bytes[3] = 0;
118 firings[point_idx].
distance =
static_cast<double>(point_distance.
uint)
119 * DISTANCE_RESOLUTION2;
123 for (
size_t point_idx = 0; point_idx < POINTS_PER_PACKET; point_idx++) {
124 LaserCorrection& corrections
129 firings[point_idx].distance
130 = firings[point_idx].distance + corrections.dist_correction;
137 if (line_num / 4 % 2 == 0) {
139 = cos((firings[point_idx].azimuth *
RAD_TO_DEG / 2.0 + 22.5)
143 (-firings[point_idx].azimuth *
RAD_TO_DEG / 2.0 + 112.5)
147 _R_ = theat2_c[line_num] * theat1_c[line_num] * cos_xita
148 - theat2_s[line_num] * theat1_s[line_num];
149 sin_theat = theat1_s[line_num] + 2 * _R_ * theat2_s[line_num];
150 cos_theat = sqrt(1 - pow(sin_theat, 2));
152 = (2 * _R_ * theat2_c[line_num] * cos_xita - theat1_c[line_num])
154 sin_H_xita = sqrt(1 - pow(cos_H_xita, 2));
156 if (line_num / 4 % 2 == 0) {
157 cos_xita_F = (cos_H_xita + sin_H_xita) * sqrt(0.5);
158 sin_xita_F = sqrt(1 - pow(cos_xita_F, 2));
160 cos_xita_F = (cos_H_xita + sin_H_xita) * (-sqrt(0.5));
161 sin_xita_F = sqrt(1 - pow(cos_xita_F, 2));
164 x = firings[point_idx].
distance * cos_theat * cos_xita_F;
165 y = firings[point_idx].
distance * cos_theat * sin_xita_F;
166 z = firings[point_idx].
distance * sin_theat;
174 - (POINTS_PER_PACKET - point_idx - 1)
176 / (POINTS_PER_PACKET);
181 PointXYZIT* point = pc->add_point();
182 point->set_timestamp(point_time);
183 point->set_intensity(firings[point_idx].intensity);
187 firings[point_idx].vertical_line,
189 firings[point_idx].distance,
191 firings[point_idx].azimuth,
201 point->set_timestamp(point_time);
202 point->set_intensity(0);
std::map< int, LaserCorrection > laser_corrections_
LslidarCH64wParser(const Config &config)
void GeneratePointcloud(const std::shared_ptr< LslidarScan > &scan_msg, const std::shared_ptr< apollo::drivers::PointCloud > &out_msg)
Set up for data processing.
void Order(std::shared_ptr< apollo::drivers::PointCloud > cloud)
Lslidar data conversion class
uint64_t current_packet_time
void ComputeCoords2(int Laser_ring, int Type, const float &raw_distance, LaserCorrection *corrections, const double rotation, PointXYZIT *point)
uint64_t previous_packet_time
These classes Unpack raw Lslidar LIDAR packets into several useful formats.
optional float bottom_left_y
optional float top_right_x
optional float top_right_y
optional bool calibration
optional float bottom_left_x
Point points[POINTS_PER_PACKET]
used for unpacking the first two data bytes in a block