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 theSimulationtab by selectingROS Toolbox > ROS Network.

TheNetwork Addressparameter can be set toDefaultorCustom.

For the ROS master URI, ifNetwork Addressis set toDefault, Simulink®uses the following rules to set the ROS Master URI:

  • UseROS_MASTER_URIenvironment 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 whenrosinitis called.

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

For the Node Host, ifNetwork Addressis set toDefault, Simulink uses the following rules to set the ROS Node Host:

  • UseROS_HOSTNAMEenvironment variable if it is set.

  • UseROS_IPenvironment variable if it is set.

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

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

For both, these are the same rules that MATLAB uses to resolve its ROS network addresses.

Otherwise, if you choseCustom, 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 theTestbutton to ensure you can connect to the ROS master. If you get an error, callrosinitto 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