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

This class defines the message to send. 更多...

#include <can_sender.h>

apollo::drivers::canbus::SenderMessage< SensorType > 的协作图:

Public 成员函数

 SenderMessage (const uint32_t message_id, ProtocolData< SensorType > *protocol_data)
 Constructor which takes message ID and protocol data.
 
 SenderMessage (const uint32_t message_id, ProtocolData< SensorType > *protocol_data, bool init_with_one)
 Constructor which takes message ID and protocol data and and indicator whether to initialize all bits of the .
 
virtual ~SenderMessage ()=default
 Destructor.
 
void UpdateCurrPeriod (const int32_t delta_period)
 Update the current period for sending messages by a difference.
 
void Update ()
 Update the protocol data.
 
void Update_Heartbeat ()
 Always update the protocol data.
 
struct CanFrame CanFrame ()
 Get the CAN frame to send.
 
uint32_t message_id () const
 Get the message ID.
 
int32_t curr_period () const
 Get the current period to send messages.
 

详细描述

template<typename SensorType>
class apollo::drivers::canbus::SenderMessage< SensorType >

This class defines the message to send.

在文件 can_sender.h56 行定义.

构造及析构函数说明

◆ SenderMessage() [1/2]

template<typename SensorType >
apollo::drivers::canbus::SenderMessage< SensorType >::SenderMessage ( const uint32_t  message_id,
ProtocolData< SensorType > *  protocol_data 
)

Constructor which takes message ID and protocol data.

参数
message_idThe message ID.
protocol_dataA pointer of ProtocolData which contains the content to send.

在文件 can_sender.h230 行定义.

232 : SenderMessage(message_id, protocol_data, false) {}
SenderMessage(const uint32_t message_id, ProtocolData< SensorType > *protocol_data)
Constructor which takes message ID and protocol data.
Definition can_sender.h:230
uint32_t message_id() const
Get the message ID.
Definition can_sender.h:288

◆ SenderMessage() [2/2]

template<typename SensorType >
apollo::drivers::canbus::SenderMessage< SensorType >::SenderMessage ( const uint32_t  message_id,
ProtocolData< SensorType > *  protocol_data,
bool  init_with_one 
)

Constructor which takes message ID and protocol data and and indicator whether to initialize all bits of the .

参数
message_idThe message ID.
protocol_dataA pointer of ProtocolData which contains the content to send.
init_with_oneIf it is true, then initialize all bits in the protocol data as one.

在文件 can_sender.h235 行定义.

238 : message_id_(message_id), protocol_data_(protocol_data) {
239 if (init_with_one) {
240 for (int32_t i = 0; i < protocol_data->GetLength(); ++i) {
241 can_frame_to_update_.data[i] = 0xFF;
242 }
243 }
244 int32_t len = protocol_data_->GetLength();
245
246 can_frame_to_update_.id = message_id_;
247 can_frame_to_update_.len = static_cast<uint8_t>(len);
248
249 period_ = protocol_data_->GetPeriod();
250 curr_period_ = period_;
251
252 Update();
253}
void Update()
Update the protocol data.
Definition can_sender.h:264
uint8_t len
Message length
Definition can_client.h:52
uint8_t data[8]
Message content
Definition can_client.h:54

◆ ~SenderMessage()

template<typename SensorType >
virtual apollo::drivers::canbus::SenderMessage< SensorType >::~SenderMessage ( )
virtualdefault

Destructor.

成员函数说明

◆ CanFrame()

template<typename SensorType >
struct CanFrame apollo::drivers::canbus::SenderMessage< SensorType >::CanFrame ( )

Get the CAN frame to send.

返回
The CAN frame to send.

在文件 can_sender.h293 行定义.

293 {
294 std::lock_guard<std::mutex> lock(mutex_);
295 return can_frame_to_send_;
296}

◆ curr_period()

template<typename SensorType >
int32_t apollo::drivers::canbus::SenderMessage< SensorType >::curr_period ( ) const

Get the current period to send messages.

It may be different from the period from protocol data by updating.

返回
The current period.

在文件 can_sender.h299 行定义.

299 {
300 return curr_period_;
301}

◆ message_id()

template<typename SensorType >
uint32_t apollo::drivers::canbus::SenderMessage< SensorType >::message_id ( ) const

Get the message ID.

返回
The message ID.

在文件 can_sender.h288 行定义.

288 {
289 return message_id_;
290}

◆ Update()

template<typename SensorType >
void apollo::drivers::canbus::SenderMessage< SensorType >::Update ( )

Update the protocol data.

But the updating process depends on the real type of protocol data which inherites ProtocolData.

在文件 can_sender.h264 行定义.

264 {
265 if (protocol_data_ == nullptr) {
266 AERROR << "Attention: ProtocolData is nullptr!";
267 return;
268 }
269 protocol_data_->UpdateData(can_frame_to_update_.data);
270
271 std::lock_guard<std::mutex> lock(mutex_);
272 can_frame_to_send_ = can_frame_to_update_;
273}
#define AERROR
Definition log.h:44

◆ Update_Heartbeat()

template<typename SensorType >
void apollo::drivers::canbus::SenderMessage< SensorType >::Update_Heartbeat ( )

Always update the protocol data.

But the updating process depends on the real type of protocol data which inherites ProtocolData.

在文件 can_sender.h276 行定义.

276 {
277 if (protocol_data_ == nullptr) {
278 AERROR << "Attention: ProtocolData is nullptr!";
279 return;
280 }
281 protocol_data_->UpdateData_Heartbeat(can_frame_to_update_.data);
282
283 std::lock_guard<std::mutex> lock(mutex_);
284 can_frame_to_send_ = can_frame_to_update_;
285}

◆ UpdateCurrPeriod()

template<typename SensorType >
void apollo::drivers::canbus::SenderMessage< SensorType >::UpdateCurrPeriod ( const int32_t  delta_period)

Update the current period for sending messages by a difference.

参数
delta_periodUpdate the current period by reducing delta_period.

在文件 can_sender.h256 行定义.

256 {
257 curr_period_ -= period_delta;
258 if (curr_period_ <= 0) {
259 curr_period_ = period_;
260 }
261}

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