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

#include <fusion_and_compensator_component.h>

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

Public 成员函数

bool Init () override
 
bool Proc (const std::shared_ptr< PointCloud > &point_cloud) override
 
- 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::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
virtual void Clear ()
 
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Node > node_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 fusion_and_compensator_component.h 第 48 行定义.

成员函数说明

◆ Init()

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

实现了 apollo::cyber::ComponentBase.

在文件 fusion_and_compensator_component.cc 第 30 行定义.

30 {
31 if (!GetProtoConfig(&conf_)) {
32 AWARN << "Load config failed, config file" << ConfigFilePath();
33 return false;
34 }
35 tf2_buffer_ptr_ = apollo::transform::Buffer::Instance();
36
37 writer_ = node_->CreateWriter<PointCloud>(conf_.output_channel());
38
39 for (const auto& channel : conf_.input_channel()) {
40 auto reader = node_->CreateReader<PointCloud>(channel);
41
42 readers_.emplace_back(reader);
43 }
44 for (const auto& filter_config : conf_.filter_config()) {
45 filter_map_.emplace(filter_config.frame_id(), &filter_config);
46 }
47 return true;
48}
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
#define AWARN
Definition log.h:43

◆ Proc()

bool apollo::drivers::lidar::FusionAndCompensatorComponent::Proc ( const std::shared_ptr< PointCloud > &  point_cloud)
override

在文件 fusion_and_compensator_component.cc 第 50 行定义.

50 {
51 auto target = writer_->AcquireMessage();
52 target->Clear();
53 target->mutable_point()->Reserve(reserved_point_size_);
54 target->mutable_header()->set_lidar_timestamp(point_cloud->header().lidar_timestamp());
55 if (conf_.has_target_frame_id()) {
56 target->mutable_header()->set_frame_id(conf_.target_frame_id());
57 } else {
58 target->mutable_header()->set_frame_id(point_cloud->header().frame_id());
59 }
60
61 auto start_time = Time::Now().ToSecond();
62 std::vector<std::shared_ptr<PointCloud>> point_clouds = {point_cloud};
63 auto fusion_readers = readers_;
64 while ((Time::Now().ToSecond() - start_time) < conf_.wait_time_s() && fusion_readers.size() > 0) {
65 for (auto itr = fusion_readers.begin(); itr != fusion_readers.end();) {
66 (*itr)->Observe();
67 if (!(*itr)->Empty()) {
68 auto source = (*itr)->GetLatestObserved();
69 if (conf_.drop_expired_data() && IsExpired(target, source)) {
70 ++itr;
71 } else {
72 point_clouds.emplace_back(source);
73 itr = fusion_readers.erase(itr);
74 }
75 } else {
76 ++itr;
77 }
78 }
79 std::this_thread::sleep_for(std::chrono::milliseconds(5));
80 }
81
82 auto diff = Time::Now().ToNanosecond() - target->header().lidar_timestamp();
83 AINFO << "Pointcloud fusion diff: " << diff / 1000000 << "ms";
84
85 uint64_t timestamp_min = 0;
86 uint64_t timestamp_max = 0;
87 GetTimestampInterval(point_clouds, &timestamp_min, &timestamp_max);
88
89 for (const auto& pc : point_clouds) {
90 if (!FusionAndCompensator(pc, timestamp_min, timestamp_max, target)) {
91 return false;
92 }
93 }
94
95 target->mutable_header()->set_sequence_num(seq_num_++);
96 target->mutable_header()->set_timestamp_sec(cyber::Time::Now().ToSecond());
97 target->set_height(point_cloud->height());
98 target->set_width(target->point_size() / target->height());
99 target->set_is_dense(point_cloud->is_dense());
100 target->set_measurement_time(point_cloud->measurement_time());
101
102 writer_->Write(target);
103 return true;
104}
uint64_t ToNanosecond() const
convert time to nanosecond.
Definition time.cc:83
static Time Now()
get the current time.
Definition time.cc:57
double ToSecond() const
convert time to second.
Definition time.cc:77
#define AINFO
Definition log.h:42
float diff(Image< float > *I, int x1, int y1, int x2, int y2)
Dissimilarity measure between pixels

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