ROS Subscriber Listner String Message
this is the subscriber node from ros tutorials:
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
My string array consists of msg which is shown in image, Now i need to access a particular element in the msg (message consists first time and next CAN message, I want to use particularly CAN.ID whic is arrays second element) any suggestion. thanks in advance
First:
std_msgs/String
is a very bad choice for this, as it has no semantics whatsoever. aString
is not the same as a CAN frame, even though both consists of a 'string' of bytes.Second: if possible, see if you can reuse something that already exists. It could save you a lot of effort.
Perhaps ros_canopen can do what you need.
I am using some CAN USB interface, where I am using those receive and transmit nodes which are already existed for this hardware type. So the message that they have used here is std_msgs/String.