Apollo 10.0
自动驾驶开放平台
apollo::routing::RoutingComponent类 参考final

#include <routing_component.h>

类 apollo::routing::RoutingComponent 继承关系图:
apollo::routing::RoutingComponent 的协作图:

Public 成员函数

 RoutingComponent ()=default
 
 ~RoutingComponent ()=default
 
bool Init () override
 
bool Proc (const std::shared_ptr< routing::RoutingRequest > &request) override
 
- Public 成员函数 继承自 apollo::cyber::Component< routing::RoutingRequest >
 Component ()
 
 ~Component () override
 
bool Initialize (const ComponentConfig &config) override
 init the component by protobuf object.
 
bool Process (const std::shared_ptr< routing::RoutingRequest > &msg0, const std::shared_ptr< NullType > &msg1, const std::shared_ptr< NullType > &msg2, const std::shared_ptr< NullType > &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< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 routing_component.h26 行定义.

构造及析构函数说明

◆ RoutingComponent()

apollo::routing::RoutingComponent::RoutingComponent ( )
default

◆ ~RoutingComponent()

apollo::routing::RoutingComponent::~RoutingComponent ( )
default

成员函数说明

◆ Init()

bool apollo::routing::RoutingComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 routing_component.cc29 行定义.

29 {
30 RoutingConfig routing_conf;
32 << "Unable to load routing conf file: "
34
35 AINFO << "Config file: " << cyber::ComponentBase::ConfigFilePath()
36 << " is loaded.";
37
39 attr.set_channel_name(routing_conf.topic_config().routing_response_topic());
40 auto qos = attr.mutable_qos_profile();
42 qos->set_reliability(
44 qos->set_durability(
46 response_writer_ = node_->CreateWriter<routing::RoutingResponse>(attr);
47
49 attr_history.set_channel_name(
50 routing_conf.topic_config().routing_response_history_topic());
51 auto qos_history = attr_history.mutable_qos_profile();
52 qos_history->set_history(
54 qos_history->set_reliability(
56 qos_history->set_durability(
58
59 response_history_writer_ =
60 node_->CreateWriter<routing::RoutingResponse>(attr_history);
61 std::weak_ptr<RoutingComponent> self =
62 std::dynamic_pointer_cast<RoutingComponent>(shared_from_this());
63 timer_.reset(new ::apollo::cyber::Timer(
64 FLAGS_routing_response_history_interval_ms,
65 [self, this]() {
66 auto ptr = self.lock();
67 if (ptr) {
68 std::lock_guard<std::mutex> guard(this->mutex_);
69 if (this->response_ != nullptr) {
71 response_->mutable_header()->set_timestamp_sec(timestamp);
72 this->response_history_writer_->Write(*response_);
73 }
74 }
75 },
76 false));
77 timer_->Start();
78
79 return routing_.Init().ok() && routing_.Start().ok();
80}
bool ok() const
check whether the return status is OK.
Definition status.h:67
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
apollo::common::Status Init()
module initialization function
Definition routing.cc:37
apollo::common::Status Start()
module start function
Definition routing.cc:48
#define ACHECK(cond)
Definition log.h:80
#define AINFO
Definition log.h:42

◆ Proc()

bool apollo::routing::RoutingComponent::Proc ( const std::shared_ptr< routing::RoutingRequest > &  request)
override

在文件 routing_component.cc82 行定义.

83 {
84 auto response = std::make_shared<routing::RoutingResponse>();
85 if (!routing_.Process(request, response.get())) {
86 return false;
87 }
88 common::util::FillHeader(node_->Name(), response.get());
89 response_writer_->Write(response);
90 {
91 std::lock_guard<std::mutex> guard(mutex_);
92 response_ = std::move(response);
93 }
94 return true;
95}
bool Process(const std::shared_ptr< routing::RoutingRequest > &routing_request, routing::RoutingResponse *const routing_response)
Definition routing.cc:129

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