How to Run a ROS2 Node Executable Generated by Coder?

6 ビュー (過去 30 日間)
Michael
Michael 2022 年 5 月 19 日
コメント済み: Michael 2022 年 5 月 31 日
I have a simple function that publishes to a ROS2 topic and I need this publisher to run as a separate process outside of Matlab. Right now I also have a little function that subscribes to that topic to receive the messages to test if the publisher is running. I used Coder to 'build and run' the publisher per this tutorial. When I run my subscriber function, it received and plots the published data correctly confirming the process for the publisher is running.
My question is this: How do can I run the publisher executable without Matlab now that I have it built? After running codegen, I get the file structure shown in the attached image. I tried running the ros2publisherexample executable via the terminal as I have done in the past with coder generated executables by calling ros2publisherexample but I get the following output in the terminal window:
libc++abi: terminating with uncaught exception of type rclcpp::exceptions::RCLError: failed to initialize rcl init options: failed to find shared library 'rmw_fastrtps_cpp', at /System/Volumes/Data/mathworks/devel/bat/B3p2/build/3p/derived/maci64/ros2/src/ros2/rmw_implementation/rmw_implementation/src/functions.cpp:75, at /System/Volumes/Data/mathworks/devel/bat/B3p2/build/3p/derived/maci64/ros2/src/ros2/rcl/rcl/src/rcl/init_options.c:61
All of the examples I see on the Matlab documentation use 'build and run' in coder config (cfg.Hardware.BuildAction) and don't show how to run the exectuable as a standalone.
Thanks.

採用された回答

Jagadeesh Konakalla
Jagadeesh Konakalla 2022 年 5 月 20 日
編集済み: Jagadeesh Konakalla 2022 年 5 月 20 日
Hi Michael,
The short answer is that you cannot run executable as a standalone from the terminal. You always need a ROS environment ( kind of shell script that you usually run in ROS ) to run the ROS node. This environment is created and used by MATLAB when you created an executable with the Build and Run option and Deploy To is set to Locla Host.
Here is what you can try without MATLAB Installation
• Install ROS 2 Foxy on native mac machine
• Go to ROS2 colcon workspace
• Copy src folder generated from the MATLAB.
• Do colcon_make
• Then launch the node.
Hope this helps. Let me know if you have any questions.
Regards,
Jagadeesh K
  10 件のコメント
Jagadeesh Konakalla
Jagadeesh Konakalla 2022 年 5 月 30 日
Hi Michael,
What you see is a warning and not an error. I see that build is successful and that is you are able to launch the node. For now, this issue is not a blocker for you.
We will fix this warning in future releases
Thanks,
Michael
Michael 2022 年 5 月 31 日
Great. Thanks.
-Michael

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCustom Message Support についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by