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

#include <racobit_radar_canbus_component.h>

类 apollo::drivers::racobit_radar::RacobitRadarCanbusComponent 继承关系图:
apollo::drivers::racobit_radar::RacobitRadarCanbusComponent 的协作图:

Public 成员函数

 RacobitRadarCanbusComponent ()
 
 ~RacobitRadarCanbusComponent ()
 
bool Init () override
 module initialization function
 
- 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< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 racobit_radar_canbus_component.h71 行定义.

构造及析构函数说明

◆ RacobitRadarCanbusComponent()

apollo::drivers::racobit_radar::RacobitRadarCanbusComponent::RacobitRadarCanbusComponent ( )

◆ ~RacobitRadarCanbusComponent()

apollo::drivers::racobit_radar::RacobitRadarCanbusComponent::~RacobitRadarCanbusComponent ( )

在文件 racobit_radar_canbus_component.cc110 行定义.

110 {
111 if (start_success_) {
112 can_receiver_.Stop();
113 can_client_->Stop();
114 }
115}

成员函数说明

◆ Init()

bool apollo::drivers::racobit_radar::RacobitRadarCanbusComponent::Init ( )
overridevirtual

module initialization function

返回
initialization success(true) or not(false).

实现了 apollo::cyber::ComponentBase.

在文件 racobit_radar_canbus_component.cc40 行定义.

40 {
41 if (!GetProtoConfig(&racobit_radar_conf_)) {
42 return OnError("Unable to load canbus conf file: " + ConfigFilePath()).ok();
43 }
44
45 AINFO << "The canbus conf file is loaded: " << ConfigFilePath();
46 ADEBUG << "Canbus_conf:" << racobit_radar_conf_.ShortDebugString();
47 racobit_radar_writer_ =
48 node_->CreateWriter<RacobitRadar>(FLAGS_racobit_radar_topic);
50 &racobit_radar_conf_)) {
51 return OnError("Unable to load canbus conf file: " + ConfigFilePath()).ok();
52 }
53
54 AINFO << "The canbus conf file is loaded: " << ConfigFilePath();
55 ADEBUG << "Canbus_conf:" << racobit_radar_conf_.ShortDebugString();
56
57 auto can_factory = CanClientFactory::Instance();
58 can_factory->RegisterCanClients();
59 can_client_ = can_factory->CreateCANClient(
60 racobit_radar_conf_.can_conf().can_card_parameter());
61 if (!can_client_) {
62 return OnError("Failed to create can client.").ok();
63 }
64 AINFO << "Can client is successfully created.";
65
66 sensor_message_manager_ = std::unique_ptr<RacobitRadarMessageManager>(
67 new RacobitRadarMessageManager(racobit_radar_writer_));
68 if (sensor_message_manager_ == nullptr) {
69 return OnError("Failed to create message manager.").ok();
70 }
71 sensor_message_manager_->set_radar_conf(racobit_radar_conf_.radar_conf());
72 sensor_message_manager_->set_can_client(can_client_);
73 AINFO << "Sensor message manager is successfully created.";
74
75 if (can_receiver_.Init(
76 can_client_.get(), sensor_message_manager_.get(),
77 racobit_radar_conf_.can_conf().enable_receiver_log()) !=
78 ErrorCode::OK) {
79 return OnError("Failed to init can receiver.").ok();
80 }
81 AINFO << "The can receiver is successfully initialized.";
82
83 if (can_client_->Start() != ErrorCode::OK) {
84 return OnError("Failed to start can client").ok();
85 }
86
87 AINFO << "Can client is started.";
88 if (ConfigureRadar() != ErrorCode::OK) {
89 return OnError("Failed to configure radar.").ok();
90 }
91 AINFO << "The radar is successfully configured.";
92
93 if (can_receiver_.Start() != ErrorCode::OK) {
94 return OnError("Failed to start can receiver.").ok();
95 }
96 AINFO << "Can receiver is started.";
97 monitor_logger_buffer_.INFO("Canbus is started.");
98
99 return true;
100}
bool ok() const
check whether the return status is OK.
Definition status.h:67
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
#define ADEBUG
Definition log.h:41
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
optional apollo::drivers::canbus::CANCardParameter can_card_parameter

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