Cannot create publisher or subscriber of custom message
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Josh Chen
2024-3-25
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Custom Message Support 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!