Apollo 11.0
自动驾驶开放平台
apollo::latency_statistic::LatencyStatisticComponent类 参考

#include <latency_statistic_component.h>

类 apollo::latency_statistic::LatencyStatisticComponent 继承关系图:
apollo::latency_statistic::LatencyStatisticComponent 的协作图:

Public 成员函数

bool Init () override
 
bool Proc () override
 The Proc logic of the component, which called by the CyberRT frame.
 
- Public 成员函数 继承自 apollo::cyber::TimerComponent
 TimerComponent ()
 
 ~TimerComponent () override
 
bool Initialize (const TimerComponentConfig &config) override
 init the component by protobuf object.
 
void Clear () override
 
bool Process ()
 
uint32_t GetInterval () const
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const ComponentConfig &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
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_
 

详细描述

在文件 latency_statistic_component.h 第 58 行定义.

成员函数说明

◆ Init()

bool apollo::latency_statistic::LatencyStatisticComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 latency_statistic_component.cc 第 39 行定义.

39 {
40 // hook: Apollo License Verification: v_apollo_park
41 // Init Channel Defines
42 compensator_topic = FLAGS_compensator_topic;
43 perception_topic = FLAGS_perception_obstacle_topic;
44 prediction_topic = FLAGS_prediction_topic;
45 planning_topic = FLAGS_planning_trajectory_topic;
46 control_topic = FLAGS_control_command_topic;
47 // create readers
48 CreateReaders();
49 // create metric writer
50 metric_writer_ = node_->CreateWriter<LatencyMetrics>(FLAGS_latency_statistic_topic);
51 return true;
52}
std::shared_ptr< Node > node_

◆ Proc()

bool apollo::latency_statistic::LatencyStatisticComponent::Proc ( )
overridevirtual

The Proc logic of the component, which called by the CyberRT frame.

返回
returns true if successful, otherwise returns false

实现了 apollo::cyber::TimerComponent.

在文件 latency_statistic_component.cc 第 54 行定义.

54 {
55 auto metrics = std::make_shared<LatencyMetrics>();
56 apollo::common::util::FillHeader(node_->Name(), metrics.get());
57
58 Result result;
59 // get result from metric data
60 std::lock_guard<std::mutex> guard(lock_);
61 for (auto it = latency_map_.begin(); it != latency_map_.end();) {
62 auto& lidar_timestamp = it->first;
63 if (latest_stamp_ - lidar_timestamp > EXPIRED_NANOSECONDS || latency_map_.size() > MAX_SAMPLE_SIZE) {
64 it = latency_map_.erase(it);
65 continue;
66 }
67 auto& metric = it->second;
68 FillResult(lidar_timestamp, metric, &result);
69 ++it;
70 }
71 // calculate latency
72 CalculateLatency(result, metrics);
73 // write latency metrics
74 metric_writer_->Write(metrics);
75 return true;
76}

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