Apollo 11.0
自动驾驶开放平台
lidar_msg_transfer.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 "Eigen/Core"
20#include "Eigen/Geometry"
21
22#include "cyber/common/log.h"
23#include "cyber/time/time.h"
25
26namespace apollo {
27namespace localization {
28namespace msf {
29
31 LidarFrame *lidar_frame) {
32 CHECK_NOTNULL(lidar_frame);
33
34 if (msg.height() > 1 && msg.width() > 1) {
35 for (unsigned int i = 0; i < msg.height(); ++i) {
36 for (unsigned int j = 0; j < msg.width(); ++j) {
37 Eigen::Vector3d pt3d;
38 pt3d[0] = static_cast<double>(msg.point(i * msg.width() + j).x());
39 pt3d[1] = static_cast<double>(msg.point(i * msg.width() + j).y());
40 pt3d[2] = static_cast<double>(msg.point(i * msg.width() + j).z());
41 if (!std::isnan(pt3d[0])) {
42 Eigen::Vector3d pt3d_tem = pt3d;
43
44 if (pt3d_tem[2] > max_height_) {
45 continue;
46 }
47 unsigned char intensity = static_cast<unsigned char>(
48 msg.point(i * msg.width() + j).intensity());
49 lidar_frame->pt_xs.push_back(pt3d[0]);
50 lidar_frame->pt_ys.push_back(pt3d[1]);
51 lidar_frame->pt_zs.push_back(pt3d[2]);
52 lidar_frame->intensities.push_back(intensity);
53 }
54 }
55 }
56 } else {
57 AINFO << "Receiving un-organized-point-cloud, width " << msg.width()
58 << " height " << msg.height() << "size " << msg.point_size();
59 for (int i = 0; i < msg.point_size(); ++i) {
60 Eigen::Vector3d pt3d;
61 pt3d[0] = static_cast<double>(msg.point(i).x());
62 pt3d[1] = static_cast<double>(msg.point(i).y());
63 pt3d[2] = static_cast<double>(msg.point(i).z());
64 if (!std::isnan(pt3d[0])) {
65 Eigen::Vector3d pt3d_tem = pt3d;
66
67 if (pt3d_tem[2] > max_height_) {
68 continue;
69 }
70 unsigned char intensity =
71 static_cast<unsigned char>(msg.point(i).intensity());
72 lidar_frame->pt_xs.push_back(pt3d[0]);
73 lidar_frame->pt_ys.push_back(pt3d[1]);
74 lidar_frame->pt_zs.push_back(pt3d[2]);
75 lidar_frame->intensities.push_back(intensity);
76 }
77 }
78 }
79
80 lidar_frame->measurement_time =
82 if (FLAGS_lidar_debug_log_flag) {
83 AINFO << std::setprecision(15) << "LocalLidar Debug Log: velodyne msg. "
84 << "[time:" << lidar_frame->measurement_time
85 << "][height:" << msg.height() << "][width:" << msg.width()
86 << "][point_cnt:" << msg.point_size() << "]";
87 }
88}
89
90} // namespace msf
91} // namespace localization
92} // namespace apollo
Cyber has builtin time type Time.
Definition time.h:31
double ToSecond() const
convert time to second.
Definition time.cc:77
void Transfer(const drivers::PointCloud &message, LidarFrame *lidar_frame)
The class of LidarMagTransfer
The gflags used by localization module
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37
optional double measurement_time
repeated PointXYZIT point
std::vector< unsigned char > intensities