Ask Your Question
0

Int16MultiArray messages with rosserial_tivac

asked 2016-03-19 19:54:03 -0500

wintermute gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-20 06:32:29 -0500

vmatos gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-03-19 19:54:03 -0500

Seen: 784 times

Last updated: Mar 20 '17