How to Run a ROS2 Node Executable Generated by Coder?
조회 수: 6 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
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,
추가 답변 (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!