Failed to create custom ROS2 message

18 visualizaciones (últimos 30 días)
JLepers
JLepers el 20 de Nov. de 2019
Respondida: Cam Salzberger el 5 de Dic. de 2019
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 comentarios
Alessandro Melino
Alessandro Melino el 27 de Nov. de 2019
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 el 27 de Nov. de 2019
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!

Iniciar sesión para comentar.

Respuestas (1)

Cam Salzberger
Cam Salzberger el 5 de Dic. de 2019
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

Categorías

Más información sobre Custom Message Support en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by