Failed to create custom ROS2 message

19 ビュー (過去 30 日間)
JLepers
JLepers 2019 年 11 月 20 日
回答済み: Cam Salzberger 2019 年 12 月 5 日
But I have an error with: ros2genmsg(folderPath)
Error using ros.ros2.internal.validateMsg (line 17)
Invalid message format, package, or structure found during validation.
Ensure that custom message packages follow structure and
naming rules.
Error in ros2genmsg (line 72)
ros.ros2.internal.validateMsg(folderPath);
If I test my custom message in a ROS2 environment it works fine so I assume that my CMakeLists.txt and package.xml are setup correctly.
How can I know if the setup of my message package is correct. Is there an example available to show what I need to add to my CMakeLists.txt and package.xml file so that Matlab can create my custom message.
Thanks!
  2 件のコメント
Alessandro Melino
Alessandro Melino 2019 年 11 月 27 日
Hello.
I got the same error trying to add this custom message:
#Name of file: CAN.msg
time timestamp
uint16 stdId
int32 extId
uint8[] data
It currently works on ROS as yours, so we have the same problem.
Did you find any solution?
Best regards.
Alessandro
JLepers
JLepers 2019 年 11 月 27 日
Be sure to have a correct workfolder layout.
I would use something like : project > model > custom_msgs > CAN.msg
Be sure to use lower case letters in your path (only the msg file can have a capital letter).
In matlab open the project workspace and use following code:
folderPath = fullfile(pwd,"model");
ros2genmsg(folderPath)
My mistake was that I used capital letters.
Good luck!

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

回答 (1 件)

Cam Salzberger
Cam Salzberger 2019 年 12 月 5 日
ROS 2 has more strict rules about package, message, and field names than ROS did. Relevant here, fieldnames need to be all lowercase, except constants, message packages must be lowercase, message names must start with upper case, among other rules.
You also don't need to write your own package.xml and CMakeLists.txt files. MATLAB will generate those for you based on the message definitions.
If you check out the example here, it shows example custom message packages and the workflow. You can also look at the built-in message definitions for more extensive examples of message files.
-Cam

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by