Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
rm_hw::CanBus Class Reference

#include <can_bus.h>

Public Member Functions

 CanBus (const std::string &bus_name, CanDataPtr data_ptr, int thread_priority)
 Initialize device at can_device, retry if fail. Set up header of CAN frame. More...
 
void read (ros::Time time)
 Read active data from read_buffer_ to data_ptr_, such as position, velocity, torque and so on. Clear read_buffer_ after reading. More...
 
void write ()
 Write commands to can bus. More...
 
void write (can_frame *frame)
 

Public Attributes

const std::string bus_name_
 

Private Member Functions

void frameCallback (const can_frame &frame)
 This function will be called when CAN bus receive message. It push frame which received into a vector: read_buffer_. More...
 

Private Attributes

CanDataPtr data_ptr_
 
std::mutex mutex_
 
std::vector< CanFrameStampread_buffer_
 
can_frame rm_frame0_ {}
 
can_frame rm_frame1_ {}
 
can::SocketCAN socket_can_
 

Detailed Description

Definition at line 86 of file can_bus.h.

Constructor & Destructor Documentation

◆ CanBus()

rm_hw::CanBus::CanBus ( const std::string &  bus_name,
CanDataPtr  data_ptr,
int  thread_priority 
)

Initialize device at can_device, retry if fail. Set up header of CAN frame.

Parameters
bus_nameBus's name(example: can0).
data_ptrPointer which point to CAN data.

Definition at line 75 of file can_bus.cpp.

Member Function Documentation

◆ frameCallback()

void rm_hw::CanBus::frameCallback ( const can_frame &  frame)
private

This function will be called when CAN bus receive message. It push frame which received into a vector: read_buffer_.

Parameters
frameThe frame which socketcan receive.

Definition at line 301 of file can_bus.cpp.

◆ read()

void rm_hw::CanBus::read ( ros::Time  time)

Read active data from read_buffer_ to data_ptr_, such as position, velocity, torque and so on. Clear read_buffer_ after reading.

Parameters
timeROS time, but it doesn't be used.

Definition at line 150 of file can_bus.cpp.

◆ write() [1/2]

void rm_hw::CanBus::write ( )

Write commands to can bus.

Definition at line 90 of file can_bus.cpp.

◆ write() [2/2]

void rm_hw::CanBus::write ( can_frame *  frame)

Definition at line 296 of file can_bus.cpp.

Member Data Documentation

◆ bus_name_

const std::string rm_hw::CanBus::bus_name_

Definition at line 109 of file can_bus.h.

◆ data_ptr_

CanDataPtr rm_hw::CanBus::data_ptr_
private

Definition at line 119 of file can_bus.h.

◆ mutex_

std::mutex rm_hw::CanBus::mutex_
mutableprivate

Definition at line 125 of file can_bus.h.

◆ read_buffer_

std::vector<CanFrameStamp> rm_hw::CanBus::read_buffer_
private

Definition at line 120 of file can_bus.h.

◆ rm_frame0_

can_frame rm_hw::CanBus::rm_frame0_ {}
private

Definition at line 122 of file can_bus.h.

◆ rm_frame1_

can_frame rm_hw::CanBus::rm_frame1_ {}
private

Definition at line 123 of file can_bus.h.

◆ socket_can_

can::SocketCAN rm_hw::CanBus::socket_can_
private

Definition at line 118 of file can_bus.h.


The documentation for this class was generated from the following files:


rm_hw
Author(s): Qiayuan Liao
autogenerated on Tue May 6 2025 02:23:44