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

#include <compensator_component.h>

类 apollo::drivers::compensator::CompensatorComponent 继承关系图:
apollo::drivers::compensator::CompensatorComponent 的协作图:

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_
 

详细描述

在文件 compensator_component.h 第 36 行定义.

成员函数说明

◆ Init()

bool apollo::drivers::compensator::CompensatorComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 compensator_component.cc 第 32 行定义.

32 {
33 CompensatorConfig config;
34 if (!GetProtoConfig(&config)) {
35 AWARN << "Load config failed, config file" << ConfigFilePath();
36 return false;
37 }
38
39 writer_ = node_->CreateWriter<PointCloud>(config.output_channel());
40 compensator_.reset(new Compensator(config));
41 return true;
42}
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::compensator::CompensatorComponent::Proc ( const std::shared_ptr< PointCloud > &  point_cloud)
override

在文件 compensator_component.cc 第 44 行定义.

45 {
46 const auto start_time = Time::Now();
47 std::shared_ptr<PointCloud> point_cloud_compensated =
48 writer_->AcquireMessage();
49 if (point_cloud_compensated == nullptr) {
50 AWARN << "compensator fail to getobject, will be new";
51 point_cloud_compensated = std::make_shared<PointCloud>();
52 point_cloud_compensated->mutable_point()->Reserve(140000);
53 }
54 if (point_cloud_compensated == nullptr) {
55 AWARN << "compensator point_cloud is nullptr";
56 return false;
57 }
58 point_cloud_compensated->Clear();
59 if (compensator_->MotionCompensation(point_cloud, point_cloud_compensated)) {
60 const auto end_time = Time::Now();
61 const auto diff = end_time - start_time;
62 const auto meta_diff =
63 end_time - Time(point_cloud_compensated->header().lidar_timestamp());
64 AINFO << "compenstator diff (ms):" << (diff.ToNanosecond() / 1e6)
65 << ";meta (ns):"
66 << point_cloud_compensated->header().lidar_timestamp()
67 << ";meta diff (ms): " << (meta_diff.ToNanosecond() / 1e6);
68 static common::LatencyRecorder latency_recorder(FLAGS_pointcloud_topic);
69 latency_recorder.AppendLatencyRecord(
70 point_cloud_compensated->header().lidar_timestamp(), start_time,
71 end_time);
72
73 point_cloud_compensated->mutable_header()->set_sequence_num(seq_);
74 writer_->Write(point_cloud_compensated);
75 seq_++;
76 }
77
78 return true;
79}
Cyber has builtin time type Time.
Definition time.h:31
static Time Now()
get the current time.
Definition time.cc:57
#define AINFO
Definition log.h:42

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