# Mobile Robot Modelling and Simulation in Simulink (Ideal Robot)

The goal of this entry is to learn how to build a simulation model that can be used to obtain the position of a mobile robot moving on a flat surface, knowing its local velocities. Let’s start by introducing this local ideal vehicle model on a two-dimensional world.

Let’s assume that the mobile robot moves over a flat surface (X-Y plane ) with any linear and angular speeds $V_c$ and $W_c$.

if $\{C\}$ is the platform reference frame, it may be natural to consider the vehicle’s local linear and angular speeds $^cV_c$ and $^cW_c$ possibly caused by wheels attached to the same platform. Those velocities are now function of the vehicle’s wheel velocities, however they are not considered yet.

But, How can we know the absolute global position of the robot at any moment?

I’m sorry to say that there’s no analytical closed solution for this. However a numerical solution can be found by using simulation.

The absolute robot position is give by $P_c$ and $\psi$.

The local linear speed $cV_c$ of the robot has to be rotated based on the robot orientation $\psi$ in order to obtain $V_c$. However $cW_c$ remains unchanged by the vehicle orientation.

As a result, the vehicle’s position is the result of the integration of the vehicle’s speed with respect to to the global reference frame.

In every integration process there is an initial value, which in this case is the starting (initial) position of the platform.

This can be very easily summarized in the corresponding *simulink* model:

In this model, the block labeled “Velocidad Local a global” is a 2-dimensional rotation matrix, that rotates the input vector along the z axis. Note that the third component of the input vector is the angular speed and remains unchanged.

$$ R_z(\alpha) = \begin{Bmatrix} cos(\alpha)& -sin(\alpha)& 0 \\ sin(\alpha)& cos(\alpha)& 0 \\ 0& 0& 1 \end{Bmatrix}$$

$$ V_c=R_z(\psi)^cV_c$$

$$ P_c(t)=\int_0^t \! Vc(t) \, \mathrm{d}t $$

The integrator converts the speeds into positions. In this case, a vector with the initial vehicles position has been included. Note also that the angular position is feed-back to the rotation block.

Simulation results can be recorded for later use, but for model verification, two graphical outputs have been added: A robot trajectory (cartesian coordinates over time) by using the *scope* block and a plot of the followed path by using the *XY Graph* block.

In the above example model, with constant local speeds we get the following trajectory for $X$ (yellow), $Y$ (purple) and orientation $\psi$ (turquoise) over a 10 second simulation.

The resulting path for this trajectory is show by double clicking on the XY Chart block after the simulation is complete.

Now we know how to model and simulate the motion of a mobile robot. However our platform needs some actuators like wheels, legs, propellers…

In future posts we´ll learn how to add the actuator’s model to the robot simulation.

See you soon.

## Leave a Reply