Deploying ROS2 Node with Custom Messages
30 views (last 30 days)
Show older comments
Michael
on 23 Jun 2022
Commented: Jagadeesh Konakalla
on 29 Jun 2022
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
0 Comments
Accepted Answer
Jagadeesh Konakalla
on 24 Jun 2022
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 Comments
Jagadeesh Konakalla
on 29 Jun 2022
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
More Answers (0)
See Also
Categories
Find more on ROS Custom Message Support in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!