File Exchange

image thumbnail

Robotics System Toolbox Interface for ROS Custom Messages

Use custom ROS message and service types in MATLAB and Simulink.


Updated 18 Mar 2020

Editor's Note:

This support package is currently unable to download third-party software for MATLAB R2017a and earlier versions. For details and workaround, see this Bug Report.

MATLAB R2017b and later versions are unaffected.

Using the ROS Custom Messages Interface, you can extend the set of ROS messages supported by Robotics System Toolbox. You can define your own custom ROS message and service types, and use them in MATLAB and Simulink to communicate with other nodes in the ROS network.
This Interface allows you to:
- Generate MATLAB interfaces for custom messages and services from ROS msg and srv descriptions
- Send and receive custom messages just like any other ROS message
- Interface with any ROS-enabled robot or simulator that uses custom messages
- Share generated custom message interfaces with other MATLAB users
To install the ROS Custom Messages Interface:
* You must have a version of MATLAB R2015a with ROS Toolbox already installed
* Download the submission (roscustommsg.mlpkginstall)
* Double-click on roscustommsg.mlpkginstall from either inside MATLAB or from your OS
* When the install process is finished, you can type "help rosgenmsg" on the MATLAB command-line to learn more about the custom message functionality. The documentation will open automatically after the install and can be accessed later through a shortcut.

For more information

Comments and Ratings (84)



snow John


he tong

SOLVED !! Failed to download 3rd party package (in ubuntu)
due to the jdk is not download completely!!
you need download the "" to the support package. for me the path is "/home/user/Downloads/MathWorks/SupportPackages/R2017b/archives/3p/"

just copy it, then you can install it!

sq Zhong

I tried to download but fail at 3 version : r2014b,r2016b,r2018a. And the solution in "Bug Report." also didn't work.


Yunbo Sun

Failed to download 3rd party package


Abhishek GS

roc justin


Mark Tappe

Ok I resolved my problem - I just can give the advice to double check your dependencies and add <depend> and <build_depend> in your xml-file.
So please update the documentation:
because there is only the <build_depend> mentioned.

Once the jar's are build, they could be added without problems.

So yeah lets say this package works fine, if you get it to running - else it might be a bit frustrating.
(Runs on Ubuntu 16.04 with Matlab 2019b fine)

Mark Tappe

Sadly it is currently not working under M2019b on Ubuntu 16.04.
Errors while running the rosmsggen(folderpath) command ... Matlab can not link the mavros_msgs with std_msgs or geometry_msgs content... but these are known to matlab.
Maybe a problem with java?
--> :mavros_msgs:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6

I created following question about my problem - any help is appreciated:

lingyun hu

hello, i cant download this package anymore :
Failed to download the third-party software:
Gradle for ROS Custom Messages

This is required by:
Robotics System Toolbox Interface for ROS Custom Messages

To resolve this issue, see this MATLAB Answer.
I trierd the fix, it did not work
please help on this

Anyone having trouble with getting the message type in rosmsg list can refer to:

If you have a msg directory in your ros package, the function rosgenmsg will generate a matlab_gen folder inside the package and the message type will be available after adding the path to the .jar files in javaclasspath.txt under your prefdir.

I can't get custom messages work with linux, any ideas? I followed the instructions but the message is not listed in "rosmsg list".


Is there a way to automate the installation of this package? Usually i am installing the current version of Matlab on several machines, therefor using the 'installer_input.txt' to automate this task. Is it possible to include the package?

I am using Matlab 2017a - I went through the instructions in the bugreport, those enabled me to atleast download the file. However, if i start the installation, I get a loading screen for a long time and it does not seem to work. Has anyone has these issues in the past? Is there an easy fix to this?

I'm using Simulink to validate a control system for a quadrotor aircraft. Now I want to simulate my control in ROS/Gazebo enviroment using an Erle Copter model but, matlab doesn't support the "mav_msgs/ " message type. I tryed to create a custom message whit this tool but it doesn't work.
Any ideas to solve my issue ?

"There was a problem installing the support package. To resolve this issue, contact Technical Support"
I use 2017B, the download works fine but I always get this error when I try to install the Support Package has anyone else experiened this and worked around it?

Hi, what is the status on support of <package format="2">? Must say it is pretty annoying that the "package.xml" must be downgraded in order to allow rosgenmsg to be run.

Hi, i has a problem with custom msgs, when using rosgenmsg. here's my custom msg defination: raw_imu.msg
int32 week
float64 second
uint32 imu_status
int32 z_acc
int32 y__acc
int32 x_acc
int32 z_gyro
int32 y__gyro
int32 x_gyro
rosgenmsg can't generate matlab code for this msg, but it works for other custom msgs, i found it has problem with "int32 y__acc " and "int32 y__gyro", if i change this two fields into "int32 y_acc " and "int32 y_gyro", rosgenmsg works.

Vinay Reddy

Something unexpected happened error is occuring. how to correct is?

lily liu

Having a download question,when I tried to install this toolbox work on custom message.Could any guys of you please give another download link like baidu yunpan,thank you?


I am using MATLAB R2017b, but get this error message

Failed to download the third-party software

Worked well in prior version. Now I got the same error as Jan Verhaegh. One star for the actual version, five stars for the working version...

I am using MATLAB R2017b, but get this error message

Failed to download the third-party software:
Rosjava Gradle Plugins

Is there any fix?

ruan zh

Tarun Uday

I'm having the same problem as Andre (Undefined variable "hwconnectinstaller" or class "hwconnectinstaller.PackageInfo", etc.) - is this a recent bug or something, and are there any fixes yet?

I am working on OS X, I tried the sample packages, and followed the instructions. I get this error message, any ideas?

Undefined variable "hwconnectinstaller" or class "hwconnectinstaller.PackageInfo".
Error in robotics.ros.custommsg.internal.SupportPackage
Error in robotics.ros.custommsg.internal.setup.registerMessageCatalog (line 9)
spPkg = robotics.ros.custommsg.internal.SupportPackage;
Error in rosgenmsg (line 33)


Ilya Boyur

Hello, creators,
are there any plans to develop action .msg / .srv file generation support? And if you are interested in it, what timelines can we expect?

Liviu Voicu

I am trying to build a custom message and I'm getting the error:

Output argument "msgFolder" (and maybe others) not assigned
during call to

posted by an exception in rosgenmsg(). Any ideas?

Is it planned to support Format 2 package.xml files anytime soon?

@Richard. The download through MATLAB is the most convenient way to get the add-on, but we realize that some network / internet configurations can cause the installation to fail. Please contact our customer support ( and one of our installation technicians can walk you through some alternatives.

Is there any other way to download this add on? Every time I try to download it through the MATLAB interface it hangs. A simple download through a web browser would be preferable for those of us who routinely work with computers which are not permitted to access the internet directly.


I am having the same issue as @Alexandre. It works great, but then after a few days it stops working and retyping rosgenmsg(folderpath) gives me an "undefined function or variable 'rosgenmsg'" as if the plug in is gone. I've had to uninstall, re-install and follow the same procedure a couple of times already.

For the linux install script: The matlab root must be specified without trailing slash

@Sudipta. Thanks for trying out this add-on.
If you already have an existing ROS package, you can use that directly with rosgenmsg. If you want to create a new package from scratch, I suggest that you look at the following example: You can also take a look at the example package we ship with the add-on: cd(fullfile(fileparts(which('rosgenmsg')), 'examples', 'packages')). Lastly, please take a look at the ROS tutorials that describe the package.xml, msg, and srv file structure:


I want to prepare some custom msgs. I have installed this addon. However, the steps for creating new msg is not clear to me. Can anyone provide me some details on how and what to put in the package.xml, in the *.srv flie and *.msg file? and what is the relation between all of them. It would be really helpful, if you can share any demo custom message. Thanks in advance.

@Usman, I am sorry to hear about your problems with the custom message generation. The add-on should work in all versions of MATLAB from 15a to 17a, including your 16b version. Since the custom message folder is empty, it seems that there was a problem that prevented the files from being generated. Please double-check that the package folder name matches the <name> tag in package.xml and make sure that the message and service files are in the “msg” and “srv” subfolders. Did you see any error messages when calling rosgenmsg? What ROS package are you using?

usman arif

The is happening to me, i am using 2016b version of matlab and this add on is not working

Sorry, I meant @James, not @Daniel in my last post.

I have the same problem as @Umer and @Daniel. I'm using version 2016b. Is it possible that this Toolbox Interface is not compatible with version later than 2015a? Or am I missing something?

Thanks, Erich


Worked Great for me create a custom message. However, once I came back to work on it, rosgenmsg is gone missing. I see the toolbox installed but all it related documentation is lost. Did anyone have the same issue?

I am trying to install custom message support for naoqi_driver_msgs. My problem is the same as with @James. As I go through all the steps following rosgenmsg, my ../matlab_gen/msggn/+ros/.../+msggen stays empty.
Any clues as to what I could be missing.

@Dennis, right now only package format 1 is parsed, but we are actively working on adding package format 2 support. We will post an update to this FileExchange entry once that support exists.

I know this is not ideal, but as a temporary workaround, you can change the <depend> tags to <build_depends> in the XML file and the custom message generation should run through (the package XML file is not needed after the custom message generation finishes).

I ran into an error that using a package.xml that is written in <package format="2">,
the toolbox doesn't build it's dependency messages.

For example.
A custom message is written that uses a std/msg Vector3 as part of it.

In format 1 it is declared in package.xml as:

While in format 2 it's:

Here the tool will not build an so also not find the std_msgs.

Will this be implemented / fixed ??

(Running Ubuntu 14.04 with R2015b - student)

Dennis Ellery

Not sure what happened there... Let me try again.

I'm having difficulty getting custom messages and services to generate. I follow the instructions precisely (and have done so numerous times). My .../matlab_gen/msggen/+robotics/+ros/+custom/+msggen folder is empty, I'm assuming there are supposed to be some files here? When I run rosmsg list my messages do not appear. I'm using Ubuntu 14.04 64 bit with R2016a. Thanks, James

Sorry, I should have mentioned in the below post that I am using Ubuntu 14.04 64 bit with R2016a.

This MATLAB Answers article describes how to update the version of a builtin ROS message type (this solves Daniel's problem):

@Daniel, sorry that you are having trouble updating the message definition for the leap_motion package. You should be able to do this and we will reach out to you to work on a solution.

I am trying to update a message type for the leap_motion controller but cannot figure it out. The robotics toolbox came loaded with message types for this controller, but they are outdated by the newer files published by ROS.

I downloaded the files from git and created the matlab_gen stuff using the rosgenmsg tool. When I look in the folder created, the messages follow the format of the older files, not the new ones.

I then found where matlab stored its message information and removed the folder for leap_motion. I re-ran the rosgenmsg tool and the message types still referred back to the older message type.

I then renamed the folder leap_motion_test and changed the package.xml to reflect this. When I ran the rosgenmsg tool this time, the message information was correct. I then went through the matlab_gen folder and changed all references of leap_motion_test to leap_motion and imported the jar file and updated the matlab path info to reflect this change. When I loaded matlab and checked the message info, it again reverted back to the older message type.

Why is this? How do I update a message type that came preloaded in the robotics toolbox. This has become very frustrating and is wasting hours of my time as I try every solution I can think of.

Thanks is advance for the help

I have installed the custom message package completely. Then tried to create my custom service server message, so I created a folder contains : package.xml and srv folder with x.srv file comprise:
int32 robotid
int32 r1np
int32 r2np
int32 r3np
int32 response

After applying the command >>rosgenmsg(folderpath)..., it creates the new message type, I can see it in >>rosmsg list.
But when I want to use it in :
>>custommsg = rosmessage('newmessagetype');
>>server = rossvcserver('/call_matlab', custommsg, @servercallback)

An error says this type is not valid. It seems the new message type should be in "rostype.getServiceList", but it is in "rosmsg list" instead, which is for normal message for publishing and subscribing, and differes from service type message.
How I can solve the problem?


It works well with the old "package manifest format 1", but it does not support the new "format 2", which is the current standard: Fix it for 5 stars.

The files generated within the catkin_ws make it such that you can't 'catkin_make' your directory without patching up the autogen files significantly. Also, it would be nice to use a custom message as a message type, as in the context of initializing a subscriber to recieve messages of type 'custom_msg'. Otherwise great add-on.

@QUT HPC. Yes, it is possible to install the interface without internet access.

Please contact us through and we can send the steps to you.

@Tobias. Sorry if the capitalization difference causes you problems. In general we are trying to keep all property names in objects in MixedCase, so that causes a slight difference to the message variables in ROS. Please let us know if this is blocking you from using our tools.


What is the download/install method for Linux hosts without internet access?

Why forces the Toolbox variables in custom messages to start with a capital letter, e.g. 'test' in custom.msg leads to a variable name 'Test' in Matlab? Would prefer to keep the varible name as it is to prevent confusion.

Installed okular and the package got installed smoothly!
Thank you!

Thank you for the reply.
On executing the command it gives an error:
evince: error while loading shared libraries: failed to map segment from shared object: Permission denied

@Rachana, it is possible that the evince executable is not visible by MATLAB. You can try a different PDF reader, since the installation checks for evince, okular, kpdf, and xpdf.

Before installation, you can verify if the PDF reader is visible by executing the following command in MATLAB:

!evince --help

If MATLAB can use evince, you should see the help text explaining evince usage. If it's not available, you should see an error message that the command was not found. You can try the same verification step for kpdf, okular, or xpdf.

Sorry for any inconvenience this is causing.

I faced the same error as @Inkyu Sa while installation. I am using 64 bits Ubuntu 14.04, Matlab 2015a trial version (All toolboxes are not installed, want to try the Robotics Systems Toolbox).Envice is installed and updated. But it does not solve the problem. Matlab is not installed in default folder.
I tried installing with adobe reader as default pdf reader but that didn't work either.

@Inkyu, sorry for the error you are encountering. It seems that no PDF reader was found on your system. At the end of the installation, the documentation is displayed and that causes the error you are seeing.

Could you try to install a PDF reader? In Ubuntu, the default reader is "evince" and you can install it with

sudo apt-get install evince

After that, please try to re-install the custom message interface.

Inkyu Sa

I am using 64bits Ubuntu 14.04.02, MATLAB R2015a.

Inkyu Sa

I faced an error while installantion.
Error with post-install command for package roscustommsg: Error executing command "robotics.ros.custommsg.internal.setup.postInstallCmd;"
Output argument "reader" (and maybe others) not assigned during call to ">GetPDFReader"..

@Gerold, did you have a previous version of the support package installed? If so, please uninstall it (by calling "roboticsSupportPackages") and then try the installation again.

I run into an error while the Support Package Installer tries to download the toolbox interface:
"error in opening zip file"

anyone else having problems?

The previous comment was my mistake, this package works great in 64-biy Ubuntu 14.04 with R2015a

When I try to install the interface in 64-bit Ubuntu 14.04 running R2015a, I get the error message (the output of 'computer' is GLNXA64):

Robotics System Toolbox Interface for ROS Custom Messages cannot be installed on this system.
It requires:

Base Product: Robotics System Toolbox
Host Platforms: Win32,Win64,Mac64,Linux64

@Brian and @Rajan: We just released an update that extends the custom message support to Linux and Mac systems. Let me know if you run into any issues.

My research lab is also interested in a Linux version of this interface. Is there any updated information on Linux availability?

@Rajan: We are actively investigating how the custom message support can be extended to other platforms, including Linux and Mac. Any future updates will be posted here.

Ahmed Saber

works great. but I think you need to add to the documentation that the .srv files should be under srv subdirectory else it won't read any messages from it.


Will a Linux version be released soon?

MATLAB Release Compatibility
Created with R2017a
Compatible with R2017a to R2020a
Platform Compatibility
Windows macOS Linux