Main Content

Configure ROS Network Addresses

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.

"Configure ROS Network Addresses" dialog with default values.

The Network Address parameter can be set to Default or Custom.

For the ROS master URI, if Network Address is set to Default, Simulink uses the following rules to set the ROS Master URI:

  • Use ROS_MASTER_URI environment variable if it is set.

  • 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.

  • Use address http://localhost:11311 if other two rules do not apply.

For the Node Host, if Network Address is set to Default, Simulink uses the following rules to set the ROS Node Host:

  • Use ROS_HOSTNAME environment variable if it is set.

  • Use ROS_IP environment variable if it is set.

  • Use hostname or IP address of the first network interface on the system if available.

  • Use address http://localhost:11311 if other rules do not apply.

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.

"Configure ROS Network Addresses" dialog configured for a local host ROS master and the IP address that external ROS nodes should use to connect to a Simulink node.

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.

See Also

Related Examples

More About