ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

msg file needed?

asked 2012-08-28 21:45:56 -0600

shane gravatar image

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

edit retag flag offensive close merge delete

Comments

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?

shane gravatar image shane  ( 2012-08-28 23:00:38 -0600 )edit

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.

Lorenz gravatar image Lorenz  ( 2012-08-28 23:11:46 -0600 )edit

hm, i see. and what do i write into my own defined message? double arrayname[4]?

shane gravatar image shane  ( 2012-08-28 23:22:05 -0600 )edit

Depends on what you want to send around. Have a look at this page for data types you can use.

Lorenz gravatar image Lorenz  ( 2012-08-28 23:24:56 -0600 )edit

i want to send a 1-dim double array with the size of 4

shane gravatar image shane  ( 2012-08-28 23:35:08 -0600 )edit
1

It would be float64 arrayname[4]

joq gravatar image joq  ( 2012-08-29 06:36:47 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2012-08-28 22:26:42 -0600

Lorenz gravatar image

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-28 21:45:56 -0600

Seen: 433 times

Last updated: Aug 28 '12