Compiling ROS2 messages with comments fails when using special characters

2 ビュー (過去 30 日間)
Eric Nickel
Eric Nickel 2021 年 12 月 7 日
I'm trying to compile custom ROS2 messages in Matlab using the ros2genmsg(path) command. I was getting errors in a certain custom message file which contains comments, and have narrowed down the issue to comments which contain a square bracket immediately after the hashtag.
For example:
This works -> float32 var_name_here #0[units in comment]
This causes an error when running ros2genmsg -> float32 var_name_here #[units in comment]
It seems that putting most any character (e.g. zero or a period) between the # and the square bracket makes things work. However, I haven't found anything in the ROS message formatting notes that shows this limitation on comments, and these custom message files seem to compile fine using ROS2 Foxy running on WSL2 (Ubuntu 20). Is this limitation in ROS2 comments that I'm unaware of, or is this something specific to Matlab? Are there any other workarounds or fixes for this problem that anyone knows about?
  2 件のコメント
Hari Krishna Kakarla
Hari Krishna Kakarla 2022 年 5 月 18 日
Hi Eric,
I have created a custom message with a field name "float32 var_name_here #[units in comment]" (same as what you mentioned above). I am able to successfully generate the custom messages without any error. I verified this workflow in the latest release R2022b. I am able to successfully generate custom messages for both the cases you mentioned.
Can you please let me know which release of MATLAB you are using?
Also, please copy the message field that you are facing this issue or may be the entire content of the msg file.
Yes, I agree with you that ROS message formatting notes doesn't have this kind of limitation anywhere. May be, this was a bug in our older release of MATLAB.
So, I suggest you to update to latest version of MATLAB (R2022b) if that works for you. Else, please add the comments of the field names at the top of it instead of next to the field names. Please see the example below.
Example:
#[units in comment]
float32 var_name_here
Thanks
Hari
Eric Nickel
Eric Nickel 2022 年 5 月 24 日
Thanks for looking into this.
I've narrowed it down so I can reproduce the problem in Matlab 2021a using just a single message file. I've included the ROS2 project as an attachment so you can try it and see if it errors out on your computer.
the message file has only a single line in it:
float32 osd_loggeronoff #[0 ... 1] <- This fails to compile
float32 osd_loggeronoff #0 ... 1 <- This compiles
Also, if I put the comments into a 2nd line as you suggested then it compiles properly.
I don't have Matlab 2022b yet, so if you're able to test using the attached package I'd appreciate it.
I've also attached the stdout_stderr.log file (converted to .txt) in case it's relevant

サインインしてコメントする。

回答 (1 件)

Karthik Reddy Vennapureddy
Karthik Reddy Vennapureddy 2023 年 4 月 6 日
Hi Eric,
Thank you for narrowing down the issue and sharing the message package with error logs. I am able to reproduce this issue on MATLAB R2021a and R2021b, as it uses ROS 2 Dashing Distribution. However, this issue is addressed in MATLAB R2022a with update in ROS 2 distribution from Dashing to Foxy.
So, I recommend you to update to latest version of MATLAB. Version >= R2022a should fix the issue.
Thanks,
Karthik Reddy

カテゴリ

Help Center および File ExchangeCustom Message Support についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by