Failed to create a ROS2 publisher

15 ビュー (過去 30 日間)
Abhishek Bhagwat
Abhishek Bhagwat 2021 年 1 月 16 日
コメント済み: Cam Salzberger 2021 年 2 月 12 日
Hello everyone,
I am trying to follow this example to create custom ROS2 messages: openExample('ros/ROS2CustomMessagesExample')
I ran the code in steps and it is successfully able to create a custom message using the command ros2genmsg.
After this, when I run the part of the code to create a ROS2 publisher, it gives me an error as seen in the image below
I have installed python 3.7 and the cmake version is 3.10.2. Any help is appreciated. Thank you for your time.
Regards,
Abhishek

回答 (1 件)

Hari Krishna Kakarla
Hari Krishna Kakarla 2021 年 1 月 18 日
Hi Abhishek,
You will not encounter this issue if use MATLAB R2020b or later. As a workaround, this can be resolved by specifying the LD_LIBRARY_PATH before creating the node:
setenv LD_LIBRARY_PATH <matlabroot>/extern/bin/glnxa64:<matlabroot>/sys/os/glnxa64
It should work fine after doing the above step and should be able to create publisher and subscriber. If you still see the same error, try doing this worksround:
Create a publisher on a default topic :
pub = ros2publisher(node,"/paramete_events")
Then create your publisher:
pub = ros2publisher(node,"/example_topic")
This should work, Hope this helps!
-Hari
  6 件のコメント
Abhishek Bhagwat
Abhishek Bhagwat 2021 年 2 月 12 日
Hello,
Thank you for replying. So I tried the following things and its still throwing the same error
  1. From Ubuntu terminal used - export LD_LIBRARY_PATH=/usr/bin to set the LD_LIBRARY_PATH to /usr/bin and then started MATLAB from the same terminal. Ran simulink it showed the same error.
  2. Also used setenv to set the LD_LIBRARY_PATH in MATLAB to /usr/bin.
  3. I was running MATLAB as root (sudo -i). Tried the non root way and my custom messages didn't appear in ros2 msg list (I had installed them starting Matlab as root). I installed them again properly and the simulink file still gave me the same error.
Is there any way I can schedule a zoom call to get this resolved. It would help me greatly.
Regards,
Abhishek Bhagwat
Cam Salzberger
Cam Salzberger 2021 年 2 月 12 日
You are always welcome to contact Technical Support to get direct assistance. It can certainly help in instances where the issue seems to be specific to your system's setup.
-Cam

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeROS 2 Network Connection and Exploration についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by