Differential Drive Robot Model A robot model can describe the relations between control inputs and the robot state, in the case of differential drive mobile robot, it tells us how robot moves based on the given wheel speed.
Below is a diagram of a differential drive robot
L R r vR vL ICC Xr Yr Xw Yw
Symbol Description L wheel separation (axle length) r wheel radius ϕ wheel angular velocity v L , v R the linear velocity of the left/right wheel ω robot angular velocity ICC instantaneous center of curvature R instantaneous curvature radius of the robot trajectory \begin{array}{l|l}
\text{Symbol} & \text{Description} \\
\hline
L & \text{wheel separation (axle length)} \\
r & \text{wheel radius} \\
\phi & \text{wheel angular velocity} \\
v_L, v_R & \text{the linear velocity of the left/right wheel} \\
\omega & \text{robot angular velocity} \\
\text{ICC} & \text{instantaneous center of curvature} \\
R & \text{instantaneous curvature radius of the robot trajectory} \\
\end{array} Symbol L r ϕ v L , v R ω ICC R Description wheel separation (axle length) wheel radius wheel angular velocity the linear velocity of the left/right wheel robot angular velocity instantaneous center of curvature instantaneous curvature radius of the robot trajectory
From the above diagram, we have
{ v R = ω ( R + L 2 ) v L = ω ( R − L 2 ) ⟹ { ω = v R − v L L R = L 2 v R + v L v R − v L and v = ω R = v R + v L 2 \begin{cases}
\begin{aligned}
v_R &= \omega (R + \frac{L}{2}) \\[2ex]
v_L &= \omega (R - \frac{L}{2})
\end{aligned}
\end{cases}
\implies
\begin{cases}
\begin{aligned}
\omega &= \frac{v_R - v_L}{L} \\[2ex]
R &= \frac{L}{2} \frac{v_R + v_L}{v_R - v_L}
\end{aligned}
\end{cases}
\quad\text{and}\quad v = \omega R = \frac{v_R + v_L}{2} ⎩ ⎨ ⎧ v R v L = ω ( R + 2 L ) = ω ( R − 2 L ) ⟹ ⎩ ⎨ ⎧ ω R = L v R − v L = 2 L v R − v L v R + v L and v = ω R = 2 v R + v L
The unicycle model uses v v v and ω \omega ω as the control inputs. The state of the robot can be described by [ x , y , θ ] T ∈ R 3 [x, y, \theta]^\mathsf{T} \in \mathbb{R}^3 [ x , y , θ ] T ∈ R 3 , how it changes over time can be written as
{ x ˙ = v cos θ y ˙ = v sin θ θ ˙ = ω ⟹ [ x ˙ ( t ) y ˙ ( t ) θ ˙ ( t ) ] = [ cos ( θ ( t ) ) 0 sin ( θ ( t ) ) 0 0 1 ] [ v ( t ) ω ( t ) ] \begin{cases}
\begin{aligned}
\dot{x} &= v\cos{\theta} \\
\dot{y} &= v\sin{\theta} \\[0.2ex]
\dot{\theta} &= \omega
\end{aligned}
\end{cases}
\implies
\begin{bmatrix}
\dot{x}(t) \\[1ex]
\dot{y}(t) \\[1.2ex]
\dot{\theta}(t)
\end{bmatrix}
=
\begin{bmatrix}
\cos{\big(\theta(t)\big)} & 0 \\[1ex]
\sin{\big(\theta(t)\big)} & 0 \\[1ex]
0 & 1
\end{bmatrix}
\begin{bmatrix}
v(t) \\[1ex]
\omega(t)
\end{bmatrix} ⎩ ⎨ ⎧ x ˙ y ˙ θ ˙ = v cos θ = v sin θ = ω ⟹ x ˙ ( t ) y ˙ ( t ) θ ˙ ( t ) = cos ( θ ( t ) ) sin ( θ ( t ) ) 0 0 0 1 [ v ( t ) ω ( t ) ]
The controls have correspondence with geometry_msgs/Twist
message type used for velocity commands
/opt/ros/melodic/share/geometry_msgs/msg/Twist.msg
# This expresses velocity in free space broken into its linear and angular parts.
Eventually we can only send wheel velocities to the driver, since v R = r ϕ R v_R = r\phi_R v R = r ϕ R and v L = r ϕ L v_L = r\phi_L v L = r ϕ L , we have
{ v = v R + v L 2 = r 2 ( ϕ R + ϕ L ) ω = v R − v L L = r L ( ϕ R − ϕ L ) ⟹ { ϕ R = 2 v + ω L 2 r ϕ L = 2 v − ω L 2 r \begin{cases}
\begin{aligned}
v &= \frac{v_R + v_L}{2} = \frac{r}{2}(\phi_R + \phi_L) \\[2ex]
\omega &= \frac{v_R - v_L}{L} = \frac{r}{L}(\phi_R - \phi_L)
\end{aligned}
\end{cases}
\implies
\begin{cases}
\begin{aligned}
\phi_R &= \frac{2v + \omega L}{2r} \\[2ex]
\phi_L &= \frac{2v - \omega L}{2r}
\end{aligned}
\end{cases} ⎩ ⎨ ⎧ v ω = 2 v R + v L = 2 r ( ϕ R + ϕ L ) = L v R − v L = L r ( ϕ R − ϕ L ) ⟹ ⎩ ⎨ ⎧ ϕ R ϕ L = 2 r 2 v + ω L = 2 r 2 v − ω L
So control inputs ϕ R \phi_R ϕ R , ϕ L \phi_L ϕ L and control inputs v v v , ω \omega ω are actually equivalent
[ x ˙ ( t ) y ˙ ( t ) θ ˙ ( t ) ] = [ cos ( θ ( t ) ) 0 sin ( θ ( t ) ) 0 0 1 ] [ v ( t ) ω ( t ) ] = [ cos ( θ ( t ) ) 0 sin ( θ ( t ) ) 0 0 1 ] [ r 2 r 2 − r L r L ] [ ϕ L ( t ) ϕ R ( t ) ] \begin{bmatrix}
\dot{x}(t) \\[1ex]
\dot{y}(t) \\[1.2ex]
\dot{\theta}(t)
\end{bmatrix}
=
\begin{bmatrix}
\cos{\big(\theta(t)\big)} & 0 \\[1ex]
\sin{\big(\theta(t)\big)} & 0 \\[1ex]
0 & 1
\end{bmatrix}
\begin{bmatrix}
v(t) \\[1ex]
\omega(t)
\end{bmatrix}
=
\begin{bmatrix}
\cos{\big(\theta(t)\big)} & 0 \\[1ex]
\sin{\big(\theta(t)\big)} & 0 \\[1ex]
0 & 1
\end{bmatrix}
\begin{bmatrix}
\frac{r}{2} & \frac{r}{2} \\[1ex]
-\frac{r}{L} & \frac{r}{L}
\end{bmatrix}
\begin{bmatrix}
\phi_L(t) \\[1ex]
\phi_R(t)
\end{bmatrix} x ˙ ( t ) y ˙ ( t ) θ ˙ ( t ) = cos ( θ ( t ) ) sin ( θ ( t ) ) 0 0 0 1 [ v ( t ) ω ( t ) ] = cos ( θ ( t ) ) sin ( θ ( t ) ) 0 0 0 1 [ 2 r − L r 2 r L r ] [ ϕ L ( t ) ϕ R ( t ) ]