TL;DR
Forward Velocity Kinematics
Inverse Velocity Kinematics
Introduction
A mobile robot operating in 3D space has 6 degrees of freedom expressed in terms of it’s pose: (x, y, z, roll, pitch, yaw). It is composed of two parts, the position (x, y, z) and the rotation (roll, pitch, yaw). Where roll, pitch and yaw are the rotations about the x, y and z axes, respectively.
For a planar mobile robot, the pose can be expressed as , where the position is given by and the heading is defined by . These three parameters are sufficient to describe the motion of a robot operating on a 2D surface.
A differential drive robot has wheels on either side of it’s body that can rotate independent of one another. The individual velocities of these wheels control the motion of the robot body on a planar surface. However, in order to accurately control the robot motion a mathematical model of the robot is required that calculates the resulting planar motion for given rotational wheel velocities, and vice versa.
The Kinematics Model
The kinematics model of a differential drive robot relates the rotational wheel velocities, and , to the planar robot motion, (, , ). Where:
A typical differential drive robot is shown in the figure below. The robot pose is , the robot wheels have rotational velocities and and the distance between the wheels is .
The robot wheels have a radius of and they rotate with a rotational velocity .
The resulting linear velocity from rotational velocity of the wheel is given by:
It should be noted that when deriving the kinematics model we make the following assumptions:
- The robot can only move in the direction of it’s x axis ().
- The wheels do not slide on the floor, all the movement is a result of the wheels rolling on the ground.
The robot motion is a combination of it’s translational movement () and it’s rotational movement (). Therefore, we will study how the robot pose changes when we look into two extreme cases i.e., when the robot movement is purely translational and when the robot movement is purely roational.
Translational Movement
In this case both of the robot wheels spin with the same rotational speed and in the same direction, which causes the robot to move in the x axis.
The rotaional velocity of each of the wheels can be converted into linear velocity as follows:
Where and are the linear wheel velocities of the left and right wheel, respectively.
Since both wheels have the same linear velocity, it causes the robot to move in the x directions with no rotational speed. The velocity of the robot in the x axis is equal to the linear wheel velocities:
Using this information we can derive the rotational velocities of the wheels as shown:
Rotational Movement
In this case the rotational wheel velocities have the same magnitude but their direction is opposite. This causes the robot to rotate in one place i.e., the robot does not have any translational velocity but it has rotational velocity .
If we use the rotational velocity of the body to calculate the linear speed of the wheels, we get:
Which gives us:
We have considered the purely rotational and purely translational cases, we can get all the possible velocities in between by controlling the rotation speed of the wheels and getting the linear combination of the two cases discussed above. After adding the equations we get:
The equations above defines the inverse velocity kinematics (IK) for the differential drive robot.
The forward velocity kinematics (FK) are as follows:
In matrix notation, the IK can be written as:
and the FK:
Code
def FK():
A = np.array([
[r/2, r/2],
[0, 0],
[r/L, -r/L]
])
B = np.array([
[w_l],
[w_r]
])
return np.dot(A, B)
def IK():
A = np.array([
[1/r, 0, L/(2*r)],
[1/r, 0, -L/(2*r)],
])
B = np.array([
[x_dot],
[y_dot],
[theta_dot]
])
return np.dot(A, B)