0
$\begingroup$

Rosanswers logo

hello reader,

do i need a msg-file when i want to write a publisher and a subscriber? and if yes, how do i have to integrate the file into the publisher-code and the subscriber-code?

thx in advance


Originally posted by shane on ROS Answers with karma: 1 on 2012-08-28

Post score: 0


Original comments

Comment by shane on 2012-08-28:
and what if i want to publish an 1 dimensional array? do i just need to include "std_msgs/Float64MultiArray.h" or do i need something else?

Comment by Lorenz on 2012-08-28:
You can use Float64MultiArray but it might be a bit tricky because you need to give a layout definition. Have a look at the message definitions for more info. They contain some documentation. I personally think that Float64MultiArray doesn't provide enough semantics and I'd define my own message.

Comment by shane on 2012-08-28:
hm, i see. and what do i write into my own defined message? double arrayname[4]?

Comment by Lorenz on 2012-08-28:
Depends on what you want to send around. Have a look at this page for data types you can use.

Comment by shane on 2012-08-28:
i want to send a 1-dim double array with the size of 4

Comment by joq on 2012-08-29:
It would be float64 arrayname[4]

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The tutorials and the wiki are always a good starting point. Have a look at this wiki page and this, this and this tutorial.

You always need a message file to generate the C++ files that define the types you need for subscribing and publishing. For instance std_msgs/msg/String.msg is used to generate std_msgs/String.h which is for instance used in the above tutorials. ROS provides a lot of pre-defined messages and if you can, you should use them. If you cannot find a matching message, you need to define it yourself.


Originally posted by Lorenz with karma: 22731 on 2012-08-28

This answer was ACCEPTED on the original site

Post score: 5

$\endgroup$

Your Answer

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