Deploying ROS2 Node with Custom Messages
15 views (last 30 days)
Show older comments
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 (1)
Nupur
on 22 Nov 2023
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 Comments
Jagadeesh Konakalla
on 23 Nov 2023
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
on 24 Nov 2023
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.
See Also
Categories
Find more on Network Access 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!