matlab error on Ros custom message

15 views (last 30 days)
I want Matlab to subscribe to a ros custom message, called Position_EE.msg and defined in a msg folder simply as
string convergence
geometry_msgs/Point p
The package.xml (on the same level of msg folder) contains the following lines
When subscribing to a standard msg (such as sensor_msgs::JointState) I find no problem. I think it is because Matlab has first to convert the message with rosgenmsg, but when I run it the following error occurs:
Checking subfolder "gcode_pkg" for custom messages.
Checking subfolder "joint_pkg" for custom messages.
Building custom message files for the following packages:
:rosjava_messages is spawning subprojects: [gcode_pkg, joint_pkg]
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read for information on the replacement for dynamic properties.
Deprecated dynamic property: "mavenRepository" on "org.ros.gradle_plugins.RosPluginExtension_Decorated@31edeac", value: "".
Deprecated dynamic property "mavenRepository" created in multiple locations.
:gcode_pkg:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6
/home/matteo/Scrivania/catkin_ws/src/matlab_gen/build/rosjava_build/gcode_pkg/build/generated-src/gcode_pkg/ error: package std_msgs does not exist
std_msgs.String getConvergence();
/home/matteo/Scrivania/catkin_ws/src/matlab_gen/build/rosjava_build/gcode_pkg/build/generated-src/gcode_pkg/ error: package std_msgs does not exist
void setConvergence(std_msgs.String value);
/home/matteo/Scrivania/catkin_ws/src/matlab_gen/build/rosjava_build/gcode_pkg/build/generated-src/gcode_pkg/ error: package geometry_msgs does not exist
geometry_msgs.Point getP();
/home/matteo/Scrivania/catkin_ws/src/matlab_gen/build/rosjava_build/gcode_pkg/build/generated-src/gcode_pkg/ error: package geometry_msgs does not exist
void setP(geometry_msgs.Point value);
4 errors
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gcode_pkg:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Total time: 15.309 secs
An error occurred while building custom messages. See the full error message above.
Possible reasons for the error:
1. The msg or srv files may have syntax errors.
2. The dependencies on other message packages may not be declared correctly in the build_depends tags in the
3. Messages packages declared as dependencies may not be available.
4. The custom message packages may be missing a build dependency on "message_generation".
I've been reading some similar question, but no answer would fix my problem. Any suggestions?
Thanks in advance

Accepted Answer

Cam Salzberger
Cam Salzberger on 25 Mar 2020
Hello Matteo,
I believe the issue here has to do with reason number 2 listed. Your package.xml file looks like it uses a mix of format 1 and format 2 for declaring build dependencies, but only format 1 is currently accepted for building custom messages in MATLAB. The "depend" tag for message dependencies needs to be a "build_depend", I believe. Also, rospy will not be available since MATLAB is currently using rosjava for its back-end. I'm not sure if that will cause an issue, so best to remove that dependency as well.
See here and here for similar answers. Also see here for what the expected message package structure looks like, and ensure that yours matches that.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!