Why does ROS 2 code generation ignore remote device connection parameters in MATLAB R2024b?

I'm building for a ROS 2 target using MATLAB, and have set the hardware connection parameters, such as device address, username, and password in the configuration. However, these settings do not seem to take effect. During the build process, the system attempts to connect to a device with an empty hostname, resulting in the following error:
Connecting to ROS 2 device at ''.
Expected hostname to be nonempty.
Do you know how I can resolve this?

 채택된 답변

The problem occurs because during deployment of a custom message package to a remote device, it is using credentials from MATLAB preferences instead of the credentials set in the coder configuration (cfg). 
To resolve this set the ROS Toolbox device preferences to match your configuration:
setpref('ROS_Toolbox_ROS_Device', 'Hostname', cfg.Hardware.RemoteDeviceAddress);
setpref('ROS_Toolbox_ROS_Device', 'Username', cfg.Hardware.RemoteDeviceUsername);
setpref('ROS_Toolbox_ROS_Device', 'Password', cfg.Hardware.RemoteDevicePassword);
setpref('ROS_Toolbox_ROS_Device', 'ROS2Workspace', cfg.Hardware.ROS2Workspace);
setpref('ROS_Toolbox_ROS_Device', 'ROS2Install', cfg.Hardware.ROS2Folder);
If the following error appears in the MATLAB Command Window:
The following custom messages are not present on target machine: Allow deploying custom message package into specified workspace '/home/user/ros2_ws' on target machine.
Do the following:
  1. Please click the hyperlink in the MATLAB Command Window 'Allow deploying custom message package'.
  2. Wait for the prompt or confirmation.
  3. Then, run the command 'codegen' in the MATLAB Command Window.
The custom message package will be copied to the remote device and the deployment should be successful. 

추가 답변 (0개)

제품

릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by