Robotics StackExchange | Archived questions

Problem with Int32MultiArray publisher/subscriber

I have a problem with a Int32Multiarray message.

My publisher is like that:

stdmsgs::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 stdmsgs::Int32MultiArray& msg)
{
char temp
msg[100];
long int sx;
long int dx;
sx=msg.data[0];
dx=msg.data[1];
sprintf(tempmsg,"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!

Asked by Oper on 2016-07-18 06:36:27 UTC

Comments

Answers