0
$\begingroup$

Rosanswers logo

Hello All,

I am trying to send Int16MultiArray messages with rosserial_tivac using the code in this here.

There is the statement:

my_array.data = (int*) malloc(sizeof(int) * 8);

which causes compile error:

sketch_mar20b.cpp:23:17: error: cannot convert 'int*' to 'int16_t* {aka short int*}' in assignment

in order to compile I had to change it to:

my_array.data = (int16_t*) malloc(sizeof(int) * 8);

which will compile, and the rosserial node will declare the published topic (my_array_topic in my case) - but unfortunately, rostopic echo /my_array_topic will not display anything.

Also I have not been able to find good documentation and examples about these MultiArray messages, so it would be great if someone could point me out in the right direction for learning more about them.

Best Regards, C.


Originally posted by wintermute on ROS Answers with karma: 180 on 2016-03-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You also need to set the length of your array in the message you're publishing. I don't recall if there is an explicit rosserial tutorial with this information. But you can check a ros_lib message definition, e.g.: build/rosserial_tivac_tutorials/ros_lib/std_msgs/Int16MultiArray.h

There's a data_lengthfield in the message definition. It doesn't publish the data, because your data_length==0.

You're missing my_array.data_length = 8; before publishing.


Originally posted by vmatos with karma: 124 on 2017-03-20

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.