ros2.Crystal embedding Header.msg to custom message
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?
Asked by Obeseturtle on 2019-02-07 04:42:38 UTC
Answers
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.
Asked by revida on 2023-07-06 05:52:44 UTC
Comments