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.

This guide was first published on May 12, 2014. It was last updated on May 12, 2014.