The robot can now spin each of its two wheels using ROS 2 Control. This page is only an introduction to what comes next: how the speed of two wheels makes a robot go straight, turn on the spot or follow a curve, and why it is better to command the robot than each wheel. The equations are left for the next chapter. Every step has a simulator: a two wheel driving arena, a straight line test, an in-place spin, a robot command converter, a puzzle to find the wheel speeds, and a game on the two kinds of kinematics. All numbers on the page are teaching values.
The robot can now be controlled with the ROS 2 Control library. Each of the two wheels is moved separately. To activate a wheel, a velocity command is sent to it. Everything the robot can do, moving forward or backward, turning in place and so on, comes from just two motors. So the only way to make the robot perform any movement is to control these two motors, and to combine their speed and their direction of rotation properly. Play with both wheels below.
To make the robot move on a straight line, the speed of each wheel must be the same. Both wheels cover the same distance, so neither side gets ahead.
To make the robot perform an in-place rotation, the velocity command sent to the two wheels has the same value but opposite sign. The two wheels rotate at the same speed in opposite directions.
In the next chapter, the logic is built that calculates the velocity of the robot from the velocity of its wheels, and also the reverse: the wheel velocities from the overall robot velocity. Then velocity commands can be sent directly to the robot and not to its wheels. For example “move forward at one metre per second” or “rotate clockwise at 0.5 radians per second”. These commands are converted automatically into commands for each wheel. Here is a first look at how that will feel.
Say the robot should start rotating clockwise at 0.5 radians per second. At what speed should the motor of the left wheel rotate, and at what speed the motor of the right wheel? This is a common problem in robotics. Try to solve it by hand here. The next chapter shows how mathematics solves it every time.
The branch of mathematics that helps here is called kinematics. It gives a simple set of equations that relate the rotational speed of the motors to the overall speed of the robot in two dimensional space. Two types of equations will be studied: direct (forward) kinematics, which gives the robot speed from the motor speeds, and inverse kinematics, which gives the motor speeds from the robot speed.
The equations of direct kinematics and inverse kinematics, and the logic that lets a joystick drive the robot. This page showed the idea. The next chapter shows the math behind it.