30 #include <can_msgs/Frame.h> 40 uint32_t
id =
static_cast<int>(t);
45 return tofilter(static_cast<std::string>(t));
55 can_topic_ = nh->
advertise<can_msgs::Frame>(
"received_messages",
56 nh_param->
param(
"received_messages_queue_size", 10));
60 void SocketCANToTopic::setup()
63 frame_listener_ = driver_->createMsgListenerM(
this, &SocketCANToTopic::frameCallback);
64 state_listener_ = driver_->createStateListenerM(
this, &SocketCANToTopic::stateCallback);
70 std::bind(&SocketCANToTopic::frameCallback,
72 std::placeholders::_1),
75 state_listener_ = driver_->createStateListenerM(
this, &SocketCANToTopic::stateCallback);
90 void SocketCANToTopic::frameCallback(
const can::Frame& f)
95 ROS_ERROR(
"Invalid frame from SocketCAN: id: %#04x, length: %d, is_extended: %d, is_error: %d, is_rtr: %d",
113 msg.header.frame_id =
"";
116 can_topic_.publish(msg);
FilteredFrameListener::FilterVector tofilters(const T &v)
std::shared_ptr< DriverInterface > DriverInterfaceSharedPtr
std::string tostring(const Header &h, bool lc)
FrameFilterSharedPtr tofilter(const T &ct)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
bool getParam(const std::string &key, std::string &s) const
void convertSocketCANToMessage(const can::Frame &f, can_msgs::Frame &m)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< FrameFilterSharedPtr > FilterVector
unsigned int internal_error
std::shared_ptr< FrameFilter > FrameFilterSharedPtr
boost::system::error_code error_code