Now that we have the software environment set up, the next step is to create a model for the system.

The curved trajectory along which the Zumo Robot moves can be defined by the angle 'omega' at which the Zumo Robot is turning at an instant and the velocity 'v' at which the robot is moving forward.

Using simple kinematic equations, the mathematical relation is given by the following equations:

The ZumoBot simulation library includes an example Simulink model for this tutorial. To open the example model navigate to the '**examples**' folder, and type **Motors**** **in the MATLAB command window.

The model accepts velocity '**v**' and turning angle '**omega**' as inputs and using the subsystem named '**motor command conversion**' converts the two inputs into left and right wheel velocities.

A subsystem is a collection of Simulink blocks and is a neat way to organize blocks for complex models. It is the block diagram equivalent of writing functions for your code.

The '**model command conversion**' subsystem implements the math we just saw above in Simulink. To look at the implementation, double click on the subsystem block.

The first block named '**change parameters**' performs the matrix multiplication operation we saw in the equations above. To look at the block properties, double click on the block.

The second block named '**symmetrize motors**' accounts for the fact that not all motors are identical. This block multiplies the one of the wheel velocities with a scaling factor called '**symmetrizeMotors**' which can be tuned depending on the differences between the motors.

Up till this point, we were dealing with real world units, however the Zumo Robot understands commands in integer values ranging from -256 to 255 for motor control. The third block named '**change units**' performs this conversion.

The parameters **axleLength, symmetrizeMotors, **and** commandPercmPerSecond** are all model parameters and can differ slightly from Zumo Robot to Zumo Robot. Thus even though the model currently has some default values, these can be tuned to fit your specific needs. These parameters can be modified through the model workspace which can be accessed through the button highlighted below.

The outputs of the motor command conversion subsystem which are the left and right wheel velocities are fed to the '**ZumoMotors**' block. The '**ZumoMotors**' block represents the motors on the assembled Zumo Robot.

Now that we have understood the model, let us download it to the robot and see it in action.

Open the Motors model from the examples directory that came with the ZumoBot library. To start off, use the default values in the model for velocity 'v' (20 cm/s) and angle of turn 'omega' (0.1 rad/s).

To build and download the model on the ZumoBot, click on the Deploy on hardware button in the right top corner of the model.

Read the messages at the bottom status bar of the model to confirm that the model is successfully downloaded to the target. See the robot moving in the input trajectory.

In this case, the radius of curvature is quite large, and for short distances, the Zumo Robot almost appears to move in a straight line.

Now let us modify the input velocity 'v' to 10 cm/s and 'omega' to 1.5 rad/s. Note that you can change the value of 'v' and 'omega' by double clicking on the respective blocks and modifying the constant value parameter. Generate and download the code for the modified model into the Arduino once again.

In this situation the radius of curvature is comparatively smaller, and the Zumo Robot appears to constantly make a sharp turn.