Robot System Toolbox doesn't support the message type: mavros_msg​s/Position​Target?

Steps for reproducing the problem:
  • Open the attached Simulink model file.
  • Double click the Publish block.
Is there a simple method that can let MATLAB support the ROS message type of mavros_msgs/PositionTarget? Otherwise, I will need to use another message type to send a topic and the write a node to convert the message to mavros_msgs/PositionTarget. Any ideas on this? Thanks, Bo

1 Comment

I am changing to another computer. When I try to run my old Simulink model containing my custom message, I got this error:
Error evaluating 'InitFcn' callback of Constant block 'iopid_clamping/Blank Message/Constant'.
Callback string is 'robotics.slros.internal.block.MessageBlockMask.dispatch('constantBlkInitFcn', gcb);'
Caused by:
Cannot find a MATLAB message class for type mavros_msgs/PositionTarget.
I put them here to let search engine able to find this page by the error message.

Sign in to comment.

 Accepted Answer

I got the solution from MATLAB support.
Please see the following documentation page about the Custom Message Support Package: https://www.mathworks.com/help/robotics/ug/ros-custom-message-support.html?requestedDomain=www.mathworks.com
As mentioned in the page above, to download this support package please enter the following command: roboticsAddons
into the MATLAB Command Window and select to download the "Robotics System Toolbox Interface for ROS Custom Messages"
Afterwards, please use the following example to learn how to add a custom message type: https://www.mathworks.com/help/robotics/ug/create-custom-messages-from-ros-package.html
My attachment "mavros_msgs.zip" contains an example of the ROS package needed to create a msg type called "mavros_msgs/PositionTarget".
Extract the zip file to Desktop and run:
>> folderpath = '/Users/boshang/Desktop/mavros_msgs/'
>> rosgenmsg(folderpath)
Q&A:
If you see messages like this:
>> folderpath = '/Users/boshang/Desktop/mavros_msgs/mavros_msgs/'
>> rosgenmsg(folderpath)
Checking subfolder "msg" for custom messages. Warning: The folder name 'msg' does not match the package name 'mavros_msgs' specified in 'package.xml'. Rename the folder 'msg' to 'mavros_msgs'. > In robotics.ros.custommsg.internal.CustomMessageJAR/buildFolders (line 93) In rosgenmsg (line 42)
Checking subfolder "srv" for custom messages. Warning: The folder /Users/boshang/Desktop/mavros_msgs/mavros_msgs/srv does not contain a valid ROS package, because the 'package.xml' file is missing. Create the 'package.xml' file in this folder. > In robotics.ros.custommsg.internal.CustomMessageJAR/buildFolders (line 93) In rosgenmsg (line 42) No message packages were found in folder /Users/boshang/Desktop/mavros_msgs/mavros_msgs. Check to make sure the path to your folder is correct.
You'll need to run command: "cd .." to go back and run "rosgenmsg(folderpath)" again.

5 Comments

The generated file is attached for your reference.
I suggest to regenerate using the ROS package since there're so many path to deal with.
If you still want to use my file, you'll need to
  • Unzip it.
  • Add the jar file path to /home/username/.matlab/R2017a/javaclasspath.txt (for Ubuntu);
OR
/Users/username/Library/Application Support/MathWorks/MATLAB/R2017b/javaclasspath.txt(MAC OS)
  • Start MATLAB with Administrator.
  • Run command in MATLAB:
addpath('/path to the folder of msggen')
savepath
eg:
addpath('/Users/boshang/Desktop/mavros_msgs/matlab_gen/msggen')
savepath
  • Restart MATLAB
  • Run command in MATLAB to check:
rosmsg list
Thanks for your share! I am looking for it now.
I had created a rosmsg and the custom msg can be found in the rosmsg list,but can't be selected in simulink,.How come like this?How am I supposed to do?thank you!
Have you restarted MATLAB? @lily liu
I had the same issue and discovered a typing error in the javaclasspath.txt file...

Sign in to comment.

More Answers (3)

2-d question is
How do you stabilize drone? when arm &takeoff 2
My drone flies chaotically

1 Comment

Sorry for the late response. I had the same issue before. Check if the time on your window is slower than real time. If so, you need a faster computer.

Sign in to comment.

Categories

Asked:

Bo
on 7 Sep 2017

Commented:

on 23 Jan 2019

Community Treasure Hunt

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

Start Hunting!