During model initialization, Simulink connects to a ROS master and also creates a node associated with the model. The ROS master URI and Node Host are specified in the “Configure ROS Network Addresses” dialog. You can access this in the Simulation tab by selecting ROS Toolbox > ROS Network.
The Network Address parameter can be set to
For the ROS master URI, if Network Address is set to
Default, Simulink® uses the following rules to set the ROS Master URI:
ROS_MASTER_URI environment variable if it is
If a MATLAB® global ROS node exists, use the Master URI associated with the
global node. The global node is created automatically when
rosinit is called.
http://localhost:11311 if other two rules do
For the Node Host, if Network Address is set to
Default, Simulink uses the following rules to set the ROS Node Host:
ROS_HOSTNAME environment variable if it is set.
ROS_IP environment variable if it is set.
Use hostname or IP address of the first network interface on the system if available.
http://localhost:11311 if other rules do not
For both, these are the same rules that MATLAB uses to resolve its ROS network addresses.
Otherwise, if you chose
Custom, you can set all the variables as
shown below. This overrides the environment variables.
Note: These addresses are saved in MATLAB preferences, not the model. Therefore, this information is shared across all Simulink models and multiple MATLAB installs of the same release.
You can also use the Test button to ensure you can connect to the ROS
master. If you get an error, call
rosinit to setup a local ROS network, or if
you specified a remote ROS master, check your settings are correct.
The custom ROS master or node host settings are not used in generated code when deploying a standalone node.