Failed to create custom ROS2 message

조회 수: 18 (최근 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 CenterFile Exchange에서 Custom Message Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by