General Odometry Logic
Last updated
Last updated
The foundation of any autonomous movement system in a robot is the implementation of an accurate odometry localization algorithm. It allows the robot to accurately keep track of the its current position on the field.
On the surface the current position of the robot may seem to have little value, however, it is actually a key value in many navigation algorithms which allows the robot to traverse any point of the field.
General Logic As mentioned above, odometry allows the robot to keep track of its current position, relative to its origin. The algorithm starts by storing the robot’s initial position on the field which can be represented mathematically using a simple pose matrix:
After the origin point is known, odometry then returns the amount that it has moved from its current position, also known as displacement.
We then add the displacement value to the robot's origin position to find the current position. This process is repeated every few milliseconds to ensure the position that is stored is as accurate as possible to the true position of the robot. The equation used to update the position continuously can be mathematically represented below:
Simply explained, the current position of the robot is equal to the origin of the robot, the matrix, plus the displacement of the robot, the matrix. The , , and symbols in the matrix represent the amount that the robot has strafed (sideways movement), moved forward, and turned, respective to the robot's origin.
Now that we know that odometry works by updating its position by using the robot’s origin or previously found position value and summing it by the robot’s displacement, a key question may be asked: How is the displacement value of the robot calculated?
Teams use odometry input sources, essentially specialized sensors, that return raw position data, and when processed, the displacement of the robot can be calculated. These sensors used as well as their implementations in code will be covered in the following sections.
When implementing this process practically, the logic from the theoretical explanation above mostly carries over, however, in the code, there are a few small changes to the equation. At the beginning of the program, a current-position variable is initialized to the robot's starting point.
Then in every other iteration of the code, this value is updated continuously by adding the displacement values, or the matrix, received from the odometry input sources. This means that the current-position matrix is set to the matrix to store the origin, and as the program starts it updates itself by summing itself by the displacement from the previously calculated position. This in turn leaves us with a modified equation, which is displayed in the pseudocode below: