Add Custom ROS Message Definitions to MATLAB
A set of standard messages are included in the default ROS message catalog of
ROS Toolbox. However, you can create your own ROS custom messages and use them in
MATLAB® and Simulink® with ROS networks to transmit information. For this,
rosgenmsg function is used. For more information on this,
refer to ROS Custom Message
Support and rosgenmsg.
ur_dashboard_msgs ROS package from Universal Robots contains
several custom ROS messages and services. In order to access the POLYSCOPE GUI using
dashboard server and ROS, these message definitions need to be added to the MATLAB ROS message catalog. One option to do this is to use rosgenmsg. As mentioned in the ROS System Requirements,
generating custom messages for ROS, you must build the ROS packages. This requires you
to have Python®, CMake, and a C++ compiler for your platform.
To make the process of adding custom ROS message definitions to MATLAB easy, the definitions for Universal Robots are included in the support
package and the hardware setup process consists of a step to register these
pre-generated message definitions with the MATLAB. This workflow is ideal for the use-cases where the custom messages and
ur_dashboard_msgs package are not modified.
The custom ROS message definitions have to be regenerated in anyone of these cases:
If the ROS messages from Universal Robots are modified and are used to communicate with and control the robot
A new ROS package is being created, which is dependent on the ROS packages supplied by Universal Robots, to communicate with and control the robot.
A new message definition for Windows® needs to be added to the existing set of definitions supplied with the support package.
Generate Custom ROS Message Definitions
To generate Custom ROS message definitions:
Navigate to the custom messages folder by executing the following command in the MATLAB command window.
Based on the operating system platform, there should be a folder with a name starting with
custommsgin the resources folder. Remove
custommsgfolder from the MATLAB path and save the current path by executing
savepathcommand in the MATLAB command window.
Verify that output of the MATLAB command
rosmsg listdoes not contain any ROS messages from the
Refer the ROS Custom Message Support to know more about the requirement to generate custom ROS message definitions using rosgenmsg. Also refer to ROS System Requirements to know more about the prerequisite additional software.
Navigate to the folder which contains the custom ROS package and execute
rosgenmsgin MATLAB command window.
Wait for the process to complete, and once it is completed, execute the commands to modify MATLAB path, clear classes and rehash toolboxcache.
Check the output of MATLAB command
rosmsg listfor the messages from the group
ur_dashboard_msgsor the name of your custom ROS package.