Cannot create publisher or subscriber of custom message

20 views (last 30 days)
Hello,
I keep receiving the same error when trying to use a ROS1 custom message to create either a publisher or subscriber.
>> rospublisher('/test', 'nmpc_control/Predictions')
Failed to create a ROS publisher with topic name /test and message type nmpc_control/Predictions.
>> ub = rossubscriber('/predictions', 'nmpc_control/Predictions')
Failed to create a ROS subscriber with topic name /predictions and message type nmpc_control/Predictions.
The message was generated properly using rosgenmsg and the msg type is already used by active ROS nodes without any problem (both publishers and subscribers). MATLAB has no problem creating publishers and subscribers for other built-in message types.
I have also properly updated the MATLAB path as specified here. The msg type appears properly when rosmsg list and rosmsg show are used in MATLAB and it properly matches what is used by ROS.
>> rosmsg show nmpc_control/Predictions
std_msgs/UInt8 Id
std_msgs/Float32MultiArray PredictionsX
std_msgs/Float32MultiArray PredictionsY
std_msgs/Float32MultiArray PredictionsTheta
I am using ROS Noetic on Ubuntu 20.04 and MATLAB R2024a (very recently installed). I have seen previous questions posted here with similar problems, but they all appear to be solved with the latest versions of MATLAB. One other question makes reference to CMake version (3.15.5+) Python 2.7. I have CMake 3.16.3. That said, Python 2.7 is not support beyond Ubuntu 20.04 and I don't think that this would be the issue since it would have been patched already.
$ cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Thanks in advance and I am open to any suggestions that may help.
  2 Comments
Josh Chen
Josh Chen on 25 Mar 2024
Hey George,
Based on what you showed, I did not see any issue either. Unless there is a topic with different type already exist in the network, I am not sure how you can get this error message.
Can you share a ros message definition folder so I can try on my end and see if it is reproducible?
Thanks,
Josh
George Rossides
George Rossides on 26 Mar 2024
Hi Josh,
Many thanks for the response. You can find the complete nmpc_control package and the associated matlab generated folder here.

Sign in to comment.

Answers (0)

Categories

Find more on Custom Message Support in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!