Problem with Int32MultiArray publisher/subscriber

asked 2016-07-18 06:36:27 -0500

Oper gravatar image

I have a problem with a Int32Multiarray message.

My publisher is like that:

std_msgs::Int32MultiArray msg;
...
while(ros::ok()){
...
msg.data.push_back(value);
msg.data.push_back(value1);
motorcmdvel.publish(msg);
...
}

and my subscriber uses rosserial, so it is like that:

void motorCmdVelSub(const std_msgs::Int32MultiArray& msg)
{
char temp_msg[100];
long int sx;
long int dx;
sx=msg.data[0];
dx=msg.data[1];
sprintf(temp_msg,"left %ld , right %ld", sx, dx);
nh.loginfo(temp_msg);
maincontrol.setSpeeds(sx,dx);
}

when i execute:

'rostopic echo motor'

it prints:

layout:
dim: []
data_offset: 0
data: [255, 255]
---

and this are the right values, but at the same time my subscriber via function call to nh.loginfo prints out to me the wrong values.

sx 128 dx 255

Can you help me? thank u!

edit retag flag offensive close merge delete