ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Reading an bytemultiarray message

asked 2017-08-21 13:21:50 -0500

barovehicles gravatar image

updated 2017-08-21 16:45:36 -0500

jayess gravatar image

Hi i need to read an bytemultiarray message.

I try with routings like this, but don't work with bytemultiarray.

void arrayCallback(const std_msgs::ByteMultiArray::ConstPtr& array)
{

    int i = 0;
    // print all the remaining numbers
    for(std::vector<int>::const_iterator it = array->data.begin(); it != array->data.end(); ++it)
    {
        Arr[i] = *it;
        i++;
    }

    return;
}
edit retag flag offensive close merge delete

Comments

What do you mean by

I try with routings like this, but don't work with bytemultiarray

?

jayess gravatar image jayess  ( 2017-08-21 16:47:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-04 07:41:07 -0500

Hello,

I tried to create a node here using your for loop, and the problem is that CPP bytes are handled using signed char type, not int. So, you have to do like this:

void arrayCallback(const std_msgs::ByteMultiArray::ConstPtr& array)
{

    int i = 0;
    // print all the remaining numbers
    for(std::vector<signed char>::const_iterator it = array->data.begin(); it != array->data.end(); ++it)
    {
        Arr[i] = *it;
        i++;
    }

    return;
}

There's a tutorial showing how to deal with ByteMultiArray messages, you can check it here: https://youtu.be/RMTLKf5q3Ro

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-08-21 13:21:50 -0500

Seen: 752 times

Last updated: Sep 04 '17