Apollo 10.0
自动驾驶开放平台
apollo::drivers::SensorCanbus< SensorType > 模板类 参考

template of canbus-based sensor module main class (e.g., mobileye). 更多...

#include <sensor_canbus.h>

类 apollo::drivers::SensorCanbus< SensorType > 继承关系图:
apollo::drivers::SensorCanbus< SensorType > 的协作图:

Public 成员函数

 SensorCanbus ()
 
 ~SensorCanbus ()
 
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_
 

详细描述

template<typename SensorType>
class apollo::drivers::SensorCanbus< SensorType >

template of canbus-based sensor module main class (e.g., mobileye).

在文件 sensor_canbus.h70 行定义.

构造及析构函数说明

◆ SensorCanbus()

template<typename SensorType >
apollo::drivers::SensorCanbus< SensorType >::SensorCanbus ( )
inline

◆ ~SensorCanbus()

template<typename SensorType >
apollo::drivers::SensorCanbus< SensorType >::~SensorCanbus ( )

在文件 sensor_canbus.h197 行定义.

197 {
198 if (FLAGS_sensor_freq > 0) {
199 timer_->Stop();
200 }
201
202 can_receiver_.Stop();
203 can_client_->Stop();
204
205 if (data_trigger_running_) {
206 data_trigger_running_ = false;
207 if (thread_ != nullptr && thread_->joinable()) {
208 sensor_message_manager_->GetMutableCVar()->notify_all();
209 thread_->join();
210 }
211 thread_.reset();
212 }
213 AINFO << "Data trigger stopped [ok].";
214}
#define AINFO
Definition log.h:42

成员函数说明

◆ Init()

template<typename SensorType >
bool apollo::drivers::SensorCanbus< SensorType >::Init ( )
overridevirtual

module initialization function

返回
initialization status

实现了 apollo::cyber::ComponentBase.

在文件 sensor_canbus.h110 行定义.

110 {
111 // load conf
113 return OnError("Unable to load canbus conf file: " + config_file_path_);
114 }
115
116 AINFO << "The canbus conf file is loaded: " << config_file_path_;
117 ADEBUG << "Canbus_conf:" << canbus_conf_.ShortDebugString();
118
119 // Init can client
120 auto *can_factory = CanClientFactory::Instance();
121 can_factory->RegisterCanClients();
122 can_client_ = can_factory->CreateCANClient(canbus_conf_.can_card_parameter());
123 if (!can_client_) {
124 return OnError("Failed to create can client.");
125 }
126 AINFO << "Can client is successfully created.";
127
128 sensor_message_manager_.reset(new canbus::MessageManager<SensorType>());
129 if (sensor_message_manager_ == nullptr) {
130 return OnError("Failed to create message manager.");
131 }
132 AINFO << "Sensor message manager is successfully created.";
133
134 if (can_receiver_.Init(can_client_.get(), sensor_message_manager_.get(),
135 canbus_conf_.enable_receiver_log()) != ErrorCode::OK) {
136 return OnError("Failed to init can receiver.");
137 }
138 AINFO << "The can receiver is successfully initialized.";
139 sensor_writer_ = node_->CreateWriter<SensorType>(FLAGS_sensor_node_name);
140 return Start();
141}
std::shared_ptr< Node > node_
#define ADEBUG
Definition log.h:41
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
SensorType
Sensor types are set in the order of lidar, radar, camera, ultrasonic Please make sure SensorType has...
Definition sensor_meta.h:29
optional apollo::drivers::canbus::CANCardParameter can_card_parameter

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