Apollo 11.0
自动驾驶开放平台
apollo::guardian::GuardianComponent类 参考

#include <guardian_component.h>

类 apollo::guardian::GuardianComponent 继承关系图:
apollo::guardian::GuardianComponent 的协作图:

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< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 guardian_component.h42 行定义.

成员函数说明

◆ Init()

bool apollo::guardian::GuardianComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 guardian_component.cc31 行定义.

31 {
32 if (!GetProtoConfig(&guardian_conf_)) {
33 AERROR << "Unable to load canbus conf file: " << ConfigFilePath();
34 return false;
35 }
36
37 chassis_reader_ = node_->CreateReader<Chassis>(
38 FLAGS_chassis_topic, [this](const std::shared_ptr<Chassis>& chassis) {
39 ADEBUG << "Received chassis data: run chassis callback.";
40 std::lock_guard<std::mutex> lock(mutex_);
41 chassis_.CopyFrom(*chassis);
42 });
43
44 control_cmd_reader_ = node_->CreateReader<ControlCommand>(
45 FLAGS_control_command_topic,
46 [this](const std::shared_ptr<ControlCommand>& cmd) {
47 ADEBUG << "Received control data: run control callback.";
48 std::lock_guard<std::mutex> lock(mutex_);
49 control_cmd_.CopyFrom(*cmd);
50 });
51
52 system_status_reader_ = node_->CreateReader<SystemStatus>(
53 FLAGS_system_status_topic,
54 [this](const std::shared_ptr<SystemStatus>& status) {
55 ADEBUG << "Received system status data: run system status callback.";
56 std::lock_guard<std::mutex> lock(mutex_);
57 last_status_received_s_ = Time::Now().ToSecond();
58 system_status_.CopyFrom(*status);
59 });
60
61 guardian_writer_ = node_->CreateWriter<GuardianCommand>(FLAGS_guardian_topic);
62
63 return true;
64}
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
static Time Now()
get the current time.
Definition time.cc:57
double ToSecond() const
convert time to second.
Definition time.cc:77
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

◆ Proc()

bool apollo::guardian::GuardianComponent::Proc ( )
overridevirtual

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

返回
returns true if successful, otherwise returns false

实现了 apollo::cyber::TimerComponent.

在文件 guardian_component.cc66 行定义.

66 {
67 constexpr double kSecondsTillTimeout(2.5);
68
69 bool safety_mode_triggered = false;
70 if (guardian_conf_.guardian_enable()) {
71 std::lock_guard<std::mutex> lock(mutex_);
72 if (Time::Now().ToSecond() - last_status_received_s_ >
73 kSecondsTillTimeout) {
74 safety_mode_triggered = true;
75 }
76 safety_mode_triggered =
77 safety_mode_triggered || system_status_.has_safety_mode_trigger_time();
78 }
79
80 if (safety_mode_triggered) {
81 ADEBUG << "Safety mode triggered, enable safety mode";
82 TriggerSafetyMode();
83 } else {
84 ADEBUG << "Safety mode not triggered, bypass control command";
85 PassThroughControlCommand();
86 }
87
88 common::util::FillHeader(node_->Name(), &guardian_cmd_);
89 guardian_writer_->Write(guardian_cmd_);
90 return true;
91}

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