---
slideOptions:
transition: slide
---
<style>
.reveal {
font-size: 24px;
}
</style>
# Dynamic model of Differential Drive Mobile Robot
"Dynamic model of Differential Drive Mobile Robot using simulink"
For better look check this note, please visit [HackMD.io](https://hackmd.io/@libernormous/dynamic_ddmr)
by:
[Liber Normous](https://hackmd.io/@libernormous)
---
# Dynamic model of the robot

The input of the system is torque of left ($\tau_L$) and right ($\tau_R$) motor. The output is translation speed ($v_u$) and angular speed ($\omega$).
----
$$
\ddot{\theta} = \frac{L}{Md^2+J}\frac{(\tau_R-\tau_L)}{R}-\frac{Md}{Md^2+J}(v_u\dot{\theta})
\\
\dot{v_u}=d\dot{\theta}^2 + \frac{(\tau_R+\tau_L)}{MR}
$$
---
# Kinematic model of the wheels

The input of the system is translation speed ($v_u$) and angular speed ($\omega$) of the robot. The output is angular velocity of the left wheel ($\dot{\phi}_L$) and the right wheel ($\dot{\phi}_R$).
----
$$
\dot{\phi}_R = \frac{v_u + L\dot{\theta}}{R}
\\
{\phi}_L = \frac{v_u - L\dot{\theta}}{R}
$$
---
# Actuator modeling

The input of the system is armature voltage of right and left wheel ($v_a$) and angular of the rotor ($\omega_m$). The output is motor torque ($\tau$).
----
$$
i_a = (v_a-K_b\omega_m)\frac{1}{R_a+L_aS}\\
\tau = NK_ti_a
$$
---
# Calculating the pose

To calculate the pose we must know the angular velocity ($\omega$) and translation velocity ($v_u$) of the robot body. The pose of the robot is the position ($x_a, y_a$) and its orientation ($\theta$).
----
$$
\left(\begin{matrix}
\dot{x_a}\\ \dot{y_a} \\ \dot{\theta}
\end{matrix}\right)=
\left(\begin{matrix}
\cos \theta & 0\\ \sin{\theta} & 0 \\ 0 & 1
\end{matrix}\right)
\left(\begin{matrix}
v_u \\ \omega
\end{matrix}\right)
$$
---
# Dynamic model of the whole robot

The input of the system is armature voltage of right ($v_{aR}$) and left wheel ($v_{aL}$). The output is angular velocity of the left wheel ($\dot{\phi}_L$) and the right wheel ($\dot{\phi}_R$).
---
# Parameters
To input the parameters, we need to create a `*.m` file. We run our simulink simulation from this file using command `sim()`.
```c=
clear;
%% Parameters
La=3; %H, inductance of the armature winding
Ra=6; %Ohm, resistance of the armature winding
Kb=3; %V/rad/s the back emf constant
N=2; %the gear ratio
Kt=2; %Nm/Amp the torque constant
J = 2; % Moment inertia of robot KG*m^2
M = 5; % Robot mass in KG
d = 0.02; % Location of center of gravity of robot. x=d y=o in robot frame
R = 0.02;%radius of wheel in meter
L = 0.1;%distance between wheel in meter
%% Input
V_r = 0; % right motor voltage
V_l = 7; % right motor voltage
%% Run simulation
simout = sim('func1_v3');
figure(2);
subplot(2,2,1),plot(simout.tout, simout.ya), xlabel('t(s)'), ylabel('ya(m)');
subplot(2,2,2),plot(simout.tout, simout.xa), xlabel('t(s)'), ylabel('xa(m)');
subplot(2,2,3),plot(simout.xa, simout.ya), xlabel('xa(m)'), ylabel('ya(m)');
subplot(2,2,4),plot(simout.tout, simout.theta), xlabel('t(s)'), ylabel('theta(rad)');
```
The code are divided into 3 parts.
1. Parameters input
2. Left and right motor voltage input
3. Running the simulation and plotting the results
---
# Result 1
----
If we input $V_r=0V$ and $V_l=7V$.

From the image can be inferred that the robot is turning to the right
----
If we input $V_r=7V$ and $V_l=0V$.

From the image can be inferred that the robot is turning to the left
---

This is what happened if we input 5 volts in 5 seconds to the right motor, then turn it to 0 volts for the rest of simulation. The left wheel input remain 0 volts for in the simulation.

The robot will stop at 5 seconds. It depends on the parameter of the motor.
---
# Result 2 (Using real motor parameter)
This is the parameter. It is model C-23-L33-W20 (winding code 20) from Ref. [[2]](https://www.moog.com/content/dam/moog/literature/MCG/moc23series.pdf).
```c=
clear;
%% Parameters
La=0.94; %H, inductance of the armature winding
Ra=1; %Ohm, resistance of the armature winding
Kb=0.0301; %V/rad/s the back emf constant
N=1; %the gear ratio
Kt=0.0300; %Nm/Amp the torque constant
J = 2; % Moment inertia of robot KG*m^2
M = 5; % Robot mass in KG
d = 0.02; % Location of center of gravity of robot. x=d y=o in robot frame
R = 0.02;%radius of wheel in meter
L = 0.1;%distance between wheel in meter
```
----
If we input $V_r=1V$ and $V_l=0V$.

From the image can be inferred that the robot is turning to the right
----
This is what happened if we input 1 volts in 5 seconds to the right motor, then turn it to 0 volts for the rest of simulation. The left wheel input remain 0 volts for in the simulation.

The robot will stop after 10 seconds. It depends on the parameter of the motor. NOTE that we have more realistic value. The robot moves $1m$ after $10s$.
---
# Simulation
Simulation of this model in MATLAB can be found in [here].
---
# References
[1] Dhaouadi, Rached, and A. Abu Hatab. "Dynamic modelling of differential-drive mobile robots using lagrange and newton-euler methodologies: A unified framework." Advances in Robotics & Automation 2.2 (2013): 1-7.
[2] [Moog Components Group, "Permanent Magnet DC Motors datasheet"](https://www.moog.com/content/dam/moog/literature/MCG/moc23series.pdf)
[3] Li, Kai Way, et al. "Floor slipperiness measurement: friction coefficient, roughness of floors, and subjective perception under spillage conditions." Safety Science 42.6 (2004): 547-565.
[4]
###### tags: `matlab` `robot`
---
# Special thanks to
1. Professor Hsiu-Ming Wu of Taipei Tech