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

ros2.Crystal embedding Header.msg to custom message

asked 2019-02-07 03:42:38 -0600

Obeseturtle gravatar image

Hi,

If I embed a msgs as field in my custom message, I am able to use the embedded message and build the project without issue. When using ros2 topic echo I am only able to view the originally defined message but not the embedded one.

std_msgs/Header header   
int32 count
int32 nch
int32 lenght

After echo:

count: 721
nch: 1
length: 0

Using ros2 msg show also shows that the message has the std_msgs/Header header field on it:

std_msgs/Header header   
int32 count
int32 nch
int32 lenght

Is there an example on how to use the common_interfaces/Header.msg? Or is there a circumstance where the message would not be displayed?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-06 05:52:44 -0600

When embedding a message, such as std_msgs/Header, as a field in a custom message, it should be visible when using ros2 topic echo. However, based on the output you provided, it seems that only the fields defined in your custom message (count, nch, and length) are being displayed.

To use the common_interfaces/Header.msg, you can include it in your custom message definition and use it as a field in your message. Here's an example:

    # MyCustomMessage.msg

    #include "std_msgs/Header.msg"

MyCustomMessage:
std_msgs/Header header
int32 count
int32 nch
int32 length

By including std_msgs/Header.msg and using header as a field in your custom message, you should be able to access and display the embedded message when using ros2 topic echo.

If the embedded message is still not being displayed, please ensure that your custom message is correctly built and sourced in your ROS 2 workspace.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-02-07 03:42:38 -0600

Seen: 514 times

Last updated: Jul 06 '23