Main Content

Tune Parameters and View Signals on Deployed Robot Models Using External Mode

External mode enables Simulink® models on your host computer to communicate with a deployed model on your robot hardware during runtime. Use external mode to view signals or modify block mask parameters on your deployed Simulink model. Parameter tuning with external mode helps you make adjustments to your algorithms as they run on the hardware as opposed to in simulation in Simulink itself. This example shows how to use external mode with the Feedback Control of a ROS-Enabled Robot example when the model is deployed to the robot hardware.

Set Up the Simulink Model

Configure the Simulink model to deploy to the robot hardware and enable external mode.

Open the model.


Set the configuration parameters of the model.

  1. In the Prepare section under ROS tab, click Hardware Settings to open the model configuration parameters dialog box.

  2. On the Solver pane, set Type to Fixed-step and the Fixed-step size to 0.05.

  3. In Target Hardware Resources, set the External mode parameters. To prioritize model execution speed, enable Run external mode in a background thread. Click OK.

  4. Click Deploy under the ROS tab. Then under Deployment, click Build & Run. By default, Simulink always uses Build and run when using external mode.

  5. In the model, set the Simulation mode to External.

In the model, add scope blocks to the signals you want to view. For this example, add an XY Graph (Simulink) scope to the X and Y signals that are exiting the Bus Selector from the ROS subscriber that monitors the robot position. Open the XY Graph block and change the minimum and maximum values for each axis to [-10 10].

Deploy and Run the Model

Now that the model is configured, you can deploy and run the model on the robot hardware.

Connect to the ROS network by setting the network address. The network must be running on your target robotics hardware. This example uses the "Gazebo Empty" simulator environment is used from the Virtual Machine with ROS Hydro and Gazebo example. In the Simulations tab select ROS Network to configure your ROS network address. Specify your device address by selecting Custom under Network Address and specifying the IP address or host name under Hostname/IP Address. For this virtual machine, the IP address is

Run the model. The model is deployed to the robot hardware and runs after the build process is complete. This step might take some time.

Monitor Signals and Tune Parameters

After you deploy the model and the model is running, you can view its signals and modify its parameters.

While the model runs on the hardware, view the XY Graph (Simulink) window to monitor the robot position over time.

The path has a slight wobble, which is due to the high velocity of the robot as it tracks the path.

While the model is still running, you can also tune parameters. Open the Proportional Controller subsystem and change the Linear Velocity slider to 0.25. Back in the main model, change the Desired Position constant block to a new position, [0 -5]. The robot drives to the new position slower.

The lowered velocity reduces the wobble along the path. All these modifications were done while the model was deployed on the hardware.

Related Topics