matlab error on Ros custom message
5 views (last 30 days)
Show older comments
Matteo Paiano
on 25 Mar 2020
Answered: Cam Salzberger
on 25 Mar 2020
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
<build_depend>message_generation</build_depend>
<build_export_depend>message_generation</build_export_depend>
<exec_depend>message_runtime</exec_depend>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>rospy</exec_depend>
<build_depend>message_generation</build_depend>
<depend>geometry_msgs</depend>
<depend>std_msgs</depend>
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:
rosgenmsg('~/Scrivania/catkin_ws/src/')
Checking subfolder "gcode_pkg" for custom messages.
Checking subfolder "joint_pkg" for custom messages.
Building custom message files for the following packages:
gcode_pkg
joint_pkg
: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 http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html 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:bugfixtask
:gcode_pkg:generateSources
: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/Position_EE.java:8: 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/Position_EE.java:9: 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/Position_EE.java:10: 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/Position_EE.java:11: error: package geometry_msgs does not exist
void setP(geometry_msgs.Point value);
^
4 errors
1 warning
FAILED
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.
BUILD FAILED
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
package.xml.
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
0 Comments
Accepted Answer
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.
-Cam
0 Comments
More Answers (0)
See Also
Categories
Find more on Custom Message Support in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!