Apollo 10.0
自动驾驶开放平台
apollo::drivers::lidar::HesaiComponent2类 参考

#include <hesai_component.h>

类 apollo::drivers::lidar::HesaiComponent2 继承关系图:
apollo::drivers::lidar::HesaiComponent2 的协作图:

Public 成员函数

virtual ~HesaiComponent2 ()
 
bool Init () override
 
void ReadScanCallback (const std::shared_ptr< HesaiUdpFrame > &scan_message) override
 
void SendPointCloud (const LidarDecodedFrame< LidarPointXYZIRT > &msg)
 
void SendPacket (const UdpFrame_t &hesai_raw_msg, double)
 
- Public 成员函数 继承自 apollo::drivers::lidar::LidarComponentBase< HesaiUdpFrame >
virtual ~LidarComponentBase ()=default
 
bool InitBase (const LidarConfigBase &lidar_config_base) override
 
bool WriteScan (const std::shared_ptr< HesaiUdpFrame > &scan_message)
 
std::shared_ptr< PointCloudAllocatePointCloud ()
 
bool WritePointCloud (const std::shared_ptr< PointCloud > &point_cloud)
 
- Public 成员函数 继承自 apollo::drivers::lidar::LidarComponentBaseImpl< ScanType, ComponentType >
virtual ~LidarComponentBaseImpl ()=default
 
virtual void ReadScanCallback (const std::shared_ptr< ScanType > &scan_message)=0
 
std::shared_ptr< ScanType > AcquireScanMessage ()
 
- Public 成员函数 继承自 apollo::cyber::Component< M0, M1, M2, M3 >
 Component ()
 
 ~Component () override
 
bool Initialize (const ComponentConfig &config) override
 init the component by protobuf object.
 
bool Process (const std::shared_ptr< M0 > &msg0, const std::shared_ptr< M1 > &msg1, const std::shared_ptr< M2 > &msg2, const std::shared_ptr< M3 > &msg3)
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const TimerComponentConfig &config)
 
virtual void Shutdown ()
 
template<typename T >
bool GetProtoConfig (T *config) const
 

额外继承的成员函数

- Public 类型 继承自 apollo::drivers::lidar::LidarComponentBase< HesaiUdpFrame >
using BaseComponent = LidarComponentBaseImpl< HesaiUdpFrame >
 
- Public 类型 继承自 apollo::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::drivers::lidar::LidarComponentBaseImpl< ScanType, ComponentType >
bool InitConverter (const LidarConfigBase &lidar_config_base)
 
bool InitPacket (const LidarConfigBase &lidar_config_base)
 
virtual bool WriteScan (const std::shared_ptr< ScanType > &scan_message)
 
virtual std::shared_ptr< apollo::cyber::base::ArenaQueue< PointXYZIT > > GetPointQueue ()
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
virtual void Clear ()
 
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- 静态 Protected 成员函数 继承自 apollo::drivers::lidar::LidarComponentBaseImpl< ScanType, ComponentType >
static void PcdDefaultCleaner (std::shared_ptr< PointCloud > &unused_pcd_frame)
 
- Protected 属性 继承自 apollo::drivers::lidar::LidarComponentBaseImpl< ScanType, ComponentType >
std::string frame_id_
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 hesai_component.h33 行定义.

构造及析构函数说明

◆ ~HesaiComponent2()

virtual apollo::drivers::lidar::HesaiComponent2::~HesaiComponent2 ( )
inlinevirtual

在文件 hesai_component.h35 行定义.

35{}

成员函数说明

◆ Init()

bool apollo::drivers::lidar::HesaiComponent2::Init ( )
overridevirtual

实现了 apollo::drivers::lidar::LidarComponentBase< HesaiUdpFrame >.

在文件 hesai_component.cc26 行定义.

26 {
27 if (!GetProtoConfig(&conf_)) {
28 AERROR << "load config error, file:" << config_file_path_;
29 return false;
30 }
31 this->InitBase(conf_.config_base());
32
33 if (conf_.has_convert_thread_nums()) {
34 convert_threads_num_ = conf_.convert_thread_nums();
35 }
36
37 driver_ptr_ = std::make_shared<HesaiLidarSdk<LidarPointXYZIRT>>();
38
39 DriverParam param;
40 param.input_param.source_type
41 = static_cast<SourceType>(conf_.source_type());
42 param.input_param.pcap_path = conf_.pcap_path();
43 param.input_param.correction_file_path = conf_.correction_file_path();
44 param.input_param.firetimes_path = conf_.firetimes_path();
45 param.input_param.device_ip_address = conf_.device_ip();
46 param.input_param.host_ip_address = conf_.host_ip();
47 param.input_param.ptc_port = conf_.ptc_port();
48 param.input_param.udp_port = conf_.udp_port();
49 param.input_param.multicast_ip_address = "";
50 param.input_param.read_pcap = true;
51
52 param.decoder_param.pcap_play_synchronization = false;
53 param.decoder_param.frame_start_azimuth = conf_.frame_start_azimuth();
54 param.decoder_param.enable_parser_thread = true;
55
56 param.decoder_param.transform_param.x = 0;
57 param.decoder_param.transform_param.y = 0;
58 param.decoder_param.transform_param.z = 0;
59 param.decoder_param.transform_param.pitch = 0;
60 param.decoder_param.transform_param.yaw = 0;
61 param.decoder_param.transform_param.roll = 0;
62
63 param.lidar_type = conf_.lidar_type();
64
65 driver_ptr_->RegRecvCallback(std::bind(
66 &HesaiComponent2::SendPointCloud, this, std::placeholders::_1));
67
68 if (conf_.config_base().source_type()
69 == LidarConfigBase_SourceType_RAW_PACKET) {
70 param.decoder_param.enable_udp_thread = false;
71 }
72
73 if (conf_.config_base().source_type()
74 == LidarConfigBase_SourceType_ONLINE_LIDAR) {
75 driver_ptr_->RegRecvCallback(std::bind(
77 this,
78 std::placeholders::_1,
79 std::placeholders::_2));
80 }
81
82 if (!driver_ptr_->Init(param)) {
83 AERROR << "init fail";
84 return false;
85 }
86 driver_ptr_->Start();
87
88 return true;
89}
bool GetProtoConfig(T *config) const
void SendPacket(const UdpFrame_t &hesai_raw_msg, double)
void SendPointCloud(const LidarDecodedFrame< LidarPointXYZIRT > &msg)
bool InitBase(const LidarConfigBase &lidar_config_base) override
#define AERROR
Definition log.h:44
required apollo::drivers::lidar::LidarConfigBase config_base

◆ ReadScanCallback()

void apollo::drivers::lidar::HesaiComponent2::ReadScanCallback ( const std::shared_ptr< HesaiUdpFrame > &  scan_message)
overridevirtual

实现了 apollo::drivers::lidar::LidarComponentBase< HesaiUdpFrame >.

在文件 hesai_component.cc91 行定义.

92 {
93 // UdpPacket packet;
94 // UdpFrame_t frame_t;
95 for (int i = 0, packet_size = scan_message->packets_size(); i < packet_size;
96 ++i) {
97 driver_ptr_->lidar_ptr_->origin_packets_buffer_.emplace_back(
98 reinterpret_cast<const uint8_t*>(
99 scan_message->packets(i).data().c_str()),
100 scan_message->packets(i).data().length());
101 }
102}

◆ SendPacket()

void apollo::drivers::lidar::HesaiComponent2::SendPacket ( const UdpFrame_t &  hesai_raw_msg,
double   
)

在文件 hesai_component.cc143 行定义.

145 {
146 std::shared_ptr<HesaiUdpFrame> udp_frame
147 = std::make_shared<HesaiUdpFrame>();
148
149 for (int i = 0; i < hesai_raw_msg.size(); ++i) {
150 auto packet = udp_frame->add_packets();
151 packet->set_timestamp_sec(timestamp);
152 packet->set_size(hesai_raw_msg[i].packet_len);
153 packet->mutable_data()->assign(
154 reinterpret_cast<const char*>(hesai_raw_msg[i].buffer),
155 reinterpret_cast<const char*>(hesai_raw_msg[i].buffer)
156 + hesai_raw_msg[i].packet_len);
157 }
158 this->WriteScan(udp_frame);
159}
bool WriteScan(const std::shared_ptr< HesaiUdpFrame > &scan_message)

◆ SendPointCloud()

void apollo::drivers::lidar::HesaiComponent2::SendPointCloud ( const LidarDecodedFrame< LidarPointXYZIRT > &  msg)

在文件 hesai_component.cc104 行定义.

105 {
106 std::shared_ptr<PointCloud> cloud_message = this->AllocatePointCloud();
107
108 cloud_message->set_is_dense(false);
109 cloud_message->mutable_header()->set_timestamp_sec(
110 cyber::Time().Now().ToSecond());
111
112 double timestamp_diff = 0.0;
113 int point_size = msg.points_num;
114
115 if (point_size > 0) {
116 const double pcl_timestamp = msg.points[point_size - 1].timestamp;
117 cloud_message->set_measurement_time(pcl_timestamp);
118 timestamp_diff = pcl_timestamp - msg.points[0].timestamp;
119 } else {
120 cloud_message->set_measurement_time(0.0);
121 }
122
123 for (int i = 0; i < point_size; ++i) {
124 cloud_message->add_point();
125 }
126
127#pragma omp parallel for schedule(static) num_threads(convert_threads_num_)
128 for (int i = 0; i < point_size; ++i) {
129 cloud_message->mutable_point(i)->set_x(msg.points[i].x);
130 cloud_message->mutable_point(i)->set_y(msg.points[i].y);
131 cloud_message->mutable_point(i)->set_z(msg.points[i].z);
132 cloud_message->mutable_point(i)->set_timestamp(
134 msg.points[i].timestamp));
135 cloud_message->mutable_point(i)->set_intensity(msg.points[i].intensity);
136 }
137
138 AINFO << boost::format("point cnt = %d; timestamp_diff = %.9f s")
139 % point_size % timestamp_diff;
140 this->WritePointCloud(cloud_message);
141}
bool WritePointCloud(const std::shared_ptr< PointCloud > &point_cloud)
#define AINFO
Definition log.h:42
uint64_t GetNanosecondTimestampFromSecondTimestamp(double second_timestamp)

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