Deploying ROS2 Node with Custom Messages

조회 수: 14 (최근 30일)
Michael
Michael 2022년 6월 23일
댓글: Nupur 2023년 11월 24일
I have Matlab code that includes a ROS2 node/publisher. I want to publish custom messages. This works when I run it natively in Matlab after running ros2genmsg. I now want to deploy me code to a remote Linux machine. This worked before I added the custom ROS2 message type, but now it appears that CMake can't find my custom message definitions (see below). How to do provide this to coder/CMake? The message output below suggests that I need to provide something to CMAKE_MODULE_PATH, should I do that as a environmental variable on my system like
$export CMAKE_MODULE_PATH="$CMAKE_MODULE_PATH:<path_to_my_custom_message_directory>"
or do I need to set it in MATLAB somehow?
Here are the commands I ran in the Matlab terminal to run coder.
(Note that I have omitted my IP, username and password. )
>> cfg = coder.config('exe');
cfg.Hardware = coder.hardware('Robot Operating System 2 (ROS 2)');
cfg.Hardware.BuildAction = 'Build and run';
cfg.Hardware.RemoteDeviceAddress = '[OMITTED]';
cfg.Hardware.RemoteDeviceUsername = '[OMITTED]';
cfg.Hardware.RemoteDevicePassword = '[OMITTED]';
cfg.Hardware.DeployTo = 'Remote Device';
cfg.Hardware.ROS2Folder = '/opt/ros/galactic';
cfg.Hardware.ROS2Workspace = '~/detector_ws2';
cfg.HardwareImplementation.ProdHWDeviceType = 'Intel->x86-64 (Linux 64)';
codegen detectstreaming -args {} -config cfg
Here is the result
Connecting to ROS 2 device at '134.114.64.127'.
Using ROS 2 workspace '~/detector_ws2' to build ROS 2 node.
---
Transferring generated code for 'detectstreaming' to ROS device.
Starting build for ROS node.
---
ROS 2 project directory: /home/dasl/detector_ws2/src
Starting >>> detectstreaming
--- stderr: detectstreaming
CMake Error at CMakeLists.txt:19 (find_package):
By not providing "Finduavrt_interfaces.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"uavrt_interfaces", but CMake did not find one.
Could not find a package configuration file provided by "uavrt_interfaces"
with any of the following names:
uavrt_interfacesConfig.cmake
uavrt_interfaces-config.cmake
Add the installation prefix of "uavrt_interfaces" to CMAKE_PREFIX_PATH or
set "uavrt_interfaces_DIR" to a directory containing one of the above
files. If "uavrt_interfaces" provides a separate development package or
SDK, be sure it has been installed.
make: *** [Makefile:959: cmake_check_build_system] Error 1
---
Failed <<< detectstreaming [0.83s, exited with code 2]
Summary: 0 packages finished [1.12s]
1 package failed: detectstreaming
1 package had stderr output: detectstreaming
??? The following error occurred during deployment to your hardware board:
Build unsuccessful for model 'detectstreaming'. Check the build log in the diagnostics viewer
for error messages.
Code generation failed: View Error Report

채택된 답변

Jagadeesh Konakalla
Jagadeesh Konakalla 2022년 6월 24일
Hi Michael,
You have build the custom messages using ros2genmsg are visible only by MATLAB on your host machine. You need to build custom messages uavrt_interfaces in ~/detector_ws2.
You can follow the following tutorial to create custom messages in ROS2.
Once you build the custom messages on target machine, you can try the above procedure. It should work.
This limitation is captured in the following page under limitations section.
Thanks,
Jagadeesh K
  댓글 수: 8
Michael
Michael 2022년 6월 28일
That did it. @Jagadeesh Konakalla tell your boss I said you deserve a pay raise. Without your help on this and other issues you've helped me with I'd never have been able to overcome these ROS2/Coder nuances. Thank you so much!
Can you comment on how issues like this get bubbled up to the folks at Mathworks that do documentation? It seems like if a regular install of Python3.9 is insufficient, then it should be documented. Did I miss it somewhere?
Again, that you so much!
Jagadeesh Konakalla
Jagadeesh Konakalla 2022년 6월 29일
Hi Michael,
I happy to know that your problem is resolved.
The challenge here is that ROS is open source. The backend of ROS Toolbox uses the ROS API's. As per my understanding, the ROS 2 is maturing. We have seen different kind of install/setup issues with different OS platforms such as windows/mac/linux platforms. It is challening for us to test on different variants and versions of linux distributions.
But, I agree that in this case, documentation can capture the required python package installation steps.I will pass this information to my developement team. You should see the updated documentation for the future releases of MATLAB.
Thanks,
Jagadeesh K

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Nupur
Nupur 2023년 11월 22일
Hello @Jagadeesh Konakalla @Michael I am trying to subscribe from Matlab to the topic which is inside the container. The topic has 'ackermann_msgs/AckermannDrive' message type.
I installed this ros2 message type on my host PC and gave the path through ros2genmsg inside the Matlab. I then try to subscribe to the topic from container however, it is not subscribing to the topic.
I did check the 'ros2 topic list' on my host terminal and i could see my topic there but not in matlab.
I am new to this feild, please help me out if I am missing here something.
Host Machine: Ubuntu 22.04
Matlab/Simulink 2022b: Host Machine (Subscriber node)
ROS2 : Container (Publisher node)
  댓글 수: 2
Jagadeesh Konakalla
Jagadeesh Konakalla 2023년 11월 23일
Hi Nupur,
Can you please ensure that ROS_DOMAIN_ID environement variable is same on Docker container and Host mahcine MATLAB ?
Thanks,
Jagadeesh K.
Nupur
Nupur 2023년 11월 24일
Hello Jagadeesh,
Yes i made sure that the ROS_DOMAIN_ID is same however, Matlab not been able to see the topic. In my host terminal i can see my topic from container.
I also did try to communicate from my Host terminal to the Matlab and it does work but with the container, matlab is not been able to see the topic.
Please guide me through this.
Thank you.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Network Access에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by