Apollo  6.0
Open source self driving car software
msg_exporter.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 #pragma once
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "Eigen/Dense"
23 
24 #include "cyber/cyber.h"
25 #include "modules/drivers/proto/pointcloud.pb.h"
26 #include "modules/drivers/proto/sensor_image.pb.h"
30 
31 namespace apollo {
32 namespace perception {
33 namespace lidar {
34 
36 
37 class MsgExporter {
38  public:
39  typedef apollo::drivers::Image ImgMsg;
41 
42  public:
43  MsgExporter(std::shared_ptr<apollo::cyber::Node> node,
44  const std::vector<std::string> channels,
45  const std::vector<std::string> child_frame_ids);
46  ~MsgExporter() = default;
47 
48  private:
49  void ImageMessageHandler(const std::shared_ptr<const ImgMsg>& img_msg,
50  const std::string& channel,
51  const std::string& child_frame_id,
52  const std::string& folder);
53  void PointCloudMessageHandler(const std::shared_ptr<const PcMsg>& cloud_msg,
54  const std::string& channel,
55  const std::string& child_frame_id,
56  const std::string& folder);
57  bool SavePointCloud(const pcl::PointCloud<PCLPointXYZIT>& point_cloud,
58  double timestamp, const std::string& folder);
59  bool SaveImage(const unsigned char* color_image,
60  const unsigned char* range_image, std::size_t width,
61  std::size_t height, double timestamp,
62  const std::string& folder);
63  bool QuerySensorToWorldPose(double timestamp,
64  const std::string& child_frame_id,
65  Eigen::Matrix4d* pose);
66  bool QueryPose(double timestamp, const std::string& frame_id,
67  const std::string& child_frame_id, Eigen::Matrix4d* pose);
68  bool SavePose(const Eigen::Matrix4d& pose, double timestamp,
69  const std::string& folder);
70  bool IsStereoCamera(const std::string& channel);
71  bool IsCamera(const std::string& channel);
72  bool IsLidar(const std::string& channel);
73  std::string TransformChannelToFolder(const std::string& channel);
74 
75  private:
76  std::shared_ptr<apollo::cyber::Node> _cyber_node;
77  std::vector<std::string> _channels;
78  std::vector<std::string> _child_frame_ids;
79  std::string _localization_method;
80  Buffer* tf2_buffer_ = Buffer::Instance();
81 };
82 
83 } // namespace lidar
84 } // namespace perception
85 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
pcl::PointCloud< Point > PointCloud
Definition: types.h:64
Eigen::Matrix4d Matrix4d
Definition: base_map_fwd.h:32
MsgExporter(std::shared_ptr< apollo::cyber::Node > node, const std::vector< std::string > channels, const std::vector< std::string > child_frame_ids)
Definition: msg_exporter.h:37
Definition: buffer.h:33
apollo::drivers::Image ImgMsg
Definition: msg_exporter.h:39
apollo::drivers::PointCloud PcMsg
Definition: msg_exporter.h:40