How to subscribe/publish to custom messages using rosmatlab ?

조회 수: 8 (최근 30일)
I completed the getting started examples and also did some publishing/subscribing from matlab to standard ros nodes, but only for std_msgs. Now I want to use a custom message (foo_msg) from one of my package (foo), if I use rosmsg in the shell I can see it.
But if, in matlab I try to create publsiher, for a matlab node already created, typing : publisher = rosmatlab.publisher('TOPIC', 'foo/foo_msg', node); I get :
Error using rosmatlab.node/addPublisher (line 543)
Java exception occurred:
org.ros.exception.RosMessageRuntimeException:
java.lang.ClassNotFoundException: foo.foo_msg
at
org.ros.internal.message.definition.MessageDefinitionReflectionProvider.get(MessageDefinitionReflectionProvider.java:58)
at
org.ros.internal.message.Md5Generator.generate(Md5Generator.java:44)
at
org.ros.internal.message.topic.TopicDescriptionFactory.newFromType(TopicDescriptionFactory.java:36)
at
org.ros.internal.node.DefaultNode.newPublisher(DefaultNode.java:270)
at
org.ros.internal.node.DefaultNode.newPublisher(DefaultNode.java:280)
Caused by: java.lang.ClassNotFoundException:
foo.foo_msg
at java.net.URLClassLoader$1.run(Unknown Source)
at
java.security.AccessController.doPrivileged(Native
Method)
at java.net.URLClassLoader.findClass(Unknown
Source)
at java.lang.ClassLoader.loadClass(Unknown
Source)
at
sun.misc.Launcher$AppClassLoader.loadClass(Unknown
Source)
at java.lang.ClassLoader.loadClass(Unknown
Source)
at
org.ros.internal.message.definition.MessageDefinitionReflectionProvider.get(MessageDefinitionReflectionProvider.java:54)
... 4 more
Therefore the publsiher is not created, the same appends for the subscriber.
Does anyone know how to add customs messages ?
Thanks, Nicolas
  댓글 수: 2
Ryan
Ryan 2014년 5월 28일
I am also having roughly the same problem,
Is it possible to define a new ros message type in matlab?
That way I could create the same message type to use it in matlab and still be able to subscribe and publish to that topic where the rest of the ros nodes would use it,
Thank you
Nstaub
Nstaub 2014년 6월 15일
Hi Ryan,
I already had a ROS-Matlab bridge working so I didn't try. Let me know if it solve the issue.
Cheers, Nicolas

댓글을 달려면 로그인하십시오.

채택된 답변

MathWorks Robotics and Autonomous Systems Team
In 2015a, MathWorks released the ( Robotics System Toolbox ), which provides an interface from MATLAB and Simulink to ROS. You can also generate C++ code for a standalone ROS node from Simulink.
The toolbox natively supports custom messages once you install the Robotics System Toolbox Interface for ROS Custom Messages. This allows you to take arbitrary MSG and SRV files and generate the corresponding MATLAB message and service interfaces.

추가 답변 (1개)

Jnk
Jnk 2014년 6월 24일
I have the same problem. I would like to use brics_actuator messages. Hope that there is a solution for that.
  댓글 수: 2
Jnk
Jnk 2014년 6월 24일
Found something interesting. In the directory
$matlabroot/toolbox/psp/rootmatlab/jars
there are bunch of jar files, like
geometry_msgs_1.10.2.jar, gazebo_msgs_2.3.3.jar
etc. However I do not have brics_actuator_msgs.jar. I guess that if had it, I could probably use this type of messages. Where should I look for it, I wonder.
Jnk
Jnk 2014년 6월 27일
I managed to solve the problem. First I installed the package ros-hydro-rosjava-messages on my Linux machine. This package contains the file
/opt/ros/hydro/share/maven/org/ros/rosjava_messages/brics_actuator/0.5.3/brics_actuator-0.5.3.jar
which I copied to $matlabroot/toolbox/psp/rootmatlab/jars directory on my Windows machine. I had to run rosmatlab_AddClassPath command at the beginning of Matlab session and voilà now I can use brics_actuator messages.

댓글을 달려면 로그인하십시오.

카테고리

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