Apollo 10.0
自动驾驶开放平台
apollo::data::RecordProcessor类 参考abstract

Process messages and apply the rules based on configured triggers 更多...

#include <record_processor.h>

类 apollo::data::RecordProcessor 继承关系图:
apollo::data::RecordProcessor 的协作图:

Public 成员函数

 RecordProcessor (const std::string &source_record_dir, const std::string &restored_output_dir)
 
virtual bool Init (const SmartRecordTrigger &trigger_conf)
 
virtual bool Process ()=0
 
virtual std::string GetDefaultOutputFile () const =0
 
virtual ~RecordProcessor ()
 

Protected 成员函数

bool InitTriggers (const SmartRecordTrigger &trigger_conf)
 
bool ShouldRestore (const cyber::record::RecordMessage &msg) const
 

Protected 属性

const std::string source_record_dir_
 
const std::string restored_output_dir_
 
std::vector< std::unique_ptr< TriggerBase > > triggers_
 
std::unique_ptr< cyber::record::RecordWriterwriter_ = nullptr
 

详细描述

Process messages and apply the rules based on configured triggers

在文件 record_processor.h36 行定义.

构造及析构函数说明

◆ RecordProcessor()

apollo::data::RecordProcessor::RecordProcessor ( const std::string &  source_record_dir,
const std::string &  restored_output_dir 
)

在文件 record_processor.cc39 行定义.

41 : source_record_dir_(source_record_dir),
42 restored_output_dir_(restored_output_dir) {}
const std::string restored_output_dir_
const std::string source_record_dir_

◆ ~RecordProcessor()

virtual apollo::data::RecordProcessor::~RecordProcessor ( )
inlinevirtual

在文件 record_processor.h43 行定义.

43{ writer_->Close(); }
std::unique_ptr< cyber::record::RecordWriter > writer_

成员函数说明

◆ GetDefaultOutputFile()

virtual std::string apollo::data::RecordProcessor::GetDefaultOutputFile ( ) const
pure virtual

◆ Init()

bool apollo::data::RecordProcessor::Init ( const SmartRecordTrigger trigger_conf)
virtual

apollo::data::PostRecordProcessor , 以及 apollo::data::RealtimeRecordProcessor 重载.

在文件 record_processor.cc44 行定义.

44 {
45 // Init input/output
47 AERROR << "source record dir does not exist: " << source_record_dir_;
48 return false;
49 }
51 AERROR << "unable to open output dir: " << restored_output_dir_;
52 return false;
53 }
54 // Init triggers
55 if (!InitTriggers(trigger_conf)) {
56 AERROR << "unable to init triggers";
57 return false;
58 }
59 // Init writer
60 static constexpr uint64_t kMBToKB = 1024UL;
61 writer_.reset(new RecordWriter());
62 writer_->SetIntervalOfFileSegmentation(
63 trigger_conf.segment_setting().time_segment());
64 writer_->SetSizeOfFileSegmentation(
65 trigger_conf.segment_setting().size_segment() * kMBToKB);
66 const std::string output_file = GetDefaultOutputFile();
67 AINFO << "output file path: " << output_file;
68 if (!writer_->Open(output_file)) {
69 AERROR << "failed to open file for writing: " << output_file;
70 return false;
71 }
72 // Init intervals pool
73 IntervalPool::Instance()->Reset();
74 IntervalPool::Instance()->SetIntervalEventLogFilePath(
75 trigger_conf.trigger_log_file_path(), GetFileName(restored_output_dir_));
76 return true;
77}
bool InitTriggers(const SmartRecordTrigger &trigger_conf)
virtual std::string GetDefaultOutputFile() const =0
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
std::string GetFileName(const std::string &path, const bool remove_extension)
Definition file.cc:415
bool DirectoryExists(const std::string &directory_path)
Check if the directory specified by directory_path exists and is indeed a directory.
Definition file.cc:207
bool EnsureDirectory(const std::string &directory_path)
Check if a specified directory specified by directory_path exists.
Definition file.cc:299

◆ InitTriggers()

bool apollo::data::RecordProcessor::InitTriggers ( const SmartRecordTrigger trigger_conf)
protected

在文件 record_processor.cc79 行定义.

79 {
80 triggers_.push_back(std::unique_ptr<TriggerBase>(new DriveEventTrigger));
81 triggers_.push_back(std::unique_ptr<TriggerBase>(new EmergencyModeTrigger));
82 triggers_.push_back(std::unique_ptr<TriggerBase>(new HardBrakeTrigger));
83 triggers_.push_back(std::unique_ptr<TriggerBase>(new SmallTopicsTrigger));
84 triggers_.push_back(std::unique_ptr<TriggerBase>(new RegularIntervalTrigger));
85 triggers_.push_back(std::unique_ptr<TriggerBase>(new SwerveTrigger));
86 triggers_.push_back(std::unique_ptr<TriggerBase>(new BumperCrashTrigger));
87 for (const auto& trigger : triggers_) {
88 if (!trigger->Init(trigger_conf)) {
89 AERROR << "unable to initiate trigger and collect channels";
90 return false;
91 }
92 }
93 return true;
94}
std::vector< std::unique_ptr< TriggerBase > > triggers_

◆ Process()

virtual bool apollo::data::RecordProcessor::Process ( )
pure virtual

◆ ShouldRestore()

bool apollo::data::RecordProcessor::ShouldRestore ( const cyber::record::RecordMessage msg) const
protected

在文件 record_processor.cc96 行定义.

97 {
98 for (const auto& trigger : triggers_) {
99 if (trigger->ShouldRestore(msg)) {
100 return true;
101 }
102 }
103 return false;
104}

类成员变量说明

◆ restored_output_dir_

const std::string apollo::data::RecordProcessor::restored_output_dir_
protected

在文件 record_processor.h50 行定义.

◆ source_record_dir_

const std::string apollo::data::RecordProcessor::source_record_dir_
protected

在文件 record_processor.h49 行定义.

◆ triggers_

std::vector<std::unique_ptr<TriggerBase> > apollo::data::RecordProcessor::triggers_
protected

在文件 record_processor.h51 行定义.

◆ writer_

std::unique_ptr<cyber::record::RecordWriter> apollo::data::RecordProcessor::writer_ = nullptr
protected

在文件 record_processor.h52 行定义.


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