MATLAB Answers

"rosgenmsg": folder does not contain a valid ROS package, because the 'package.xml' file is missing.

30 views (last 30 days)
I am attempting to use MATLAB to read from a bagfile and that works fine for most topics, except for any regarding /mavros/. I have installed the Robotics System Toolbox Interface for ROS Custom Messages and attempted to use the rosgenmsg function with the mavros_msgs folder located at /opt/ros/kinetic/share/mavros_msgs. These are all default locations when installing ROS kinetic.
When running rosgenmsg('/opt/ros/kinetic/share/mavros_msgs') I get returned an error saying that this location is not a real ROS pkg complaining that there might not be a package.xml even though there is.
I get the following error:
>> rosgenmsg('/opt/ros/kinetic/share/mavros_msgs')
Checking subfolder "cmake" for custom messages.
Warning: The folder /opt/ros/kinetic/share/mavros_msgs/cmake does not contain a valid ROS
package, because the 'package.xml' file is missing. Create the 'package.xml' file in this
folder.
> In robotics.ros.custommsg.internal.CustomMessageJAR/buildFolders (line 93)
In rosgenmsg (line 42)
No message packages were found in folder /opt/ros/kinetic/share/mavros_msgs. Check to
make sure the path to your folder is correct.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 Jul 2020
Edited: MathWorks Support Team on 28 Jul 2020
The folder supplied to "rosgenmsg" is supposed to be the parent folder of the one that is being provided. I recommend that you check the example provided in the following link:
As you can see, the file structure looks like:
In this case, you would be providing the "packages" folder to "rosgenmsg". In a more typical ROS file structure, you might provide the common_msgs folder. For this folder, please check the link below:
It contains all the individual message packages. In this case, you would need to provide the "share" folder. On the other hand, this might have a bunch of other message packages that may or may not be useful to you, so you may or not want to use them in MATLAB. So it may be better to copy the mavros_msgs folder to another location, and provide that location as the path.

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!