ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
C++'s std::string
class provides an indexing operator implementation that lets you access individual characters in the string. See std::string::operator[] for details.
In your particular case, you could do something like:
size_t my_index = ...;
char the_byte = msg->data[my_index];
Now the_byte
contains the char
at position index_of_byte_you_are_interested_in
in msg->data
(which is of type std::string
(wiki/msg)).
As I wrote in my comment on your OP though: std_msgs/String
is really not a good message to use for interfacing with CAN wrappers (or for storing byte buffers in, period).
2 | No.2 Revision |
C++'s std::string
class provides an indexing operator implementation that lets you access individual characters in the string. See std::string::operator[] for details.
In your particular case, you could do something like:
size_t my_index = ...;
char the_byte = msg->data[my_index];
Now the_byte
contains the char
at position
in index_of_byte_you_are_interested_inmy_indexmsg->data
(which is of type std::string
(wiki/msg)).
As I wrote in my comment on your OP though: std_msgs/String
is really not a good message to use for interfacing with CAN wrappers (or for storing byte buffers in, period).