Tank (No Deadwheels)

Resources

This particular odometry technique utilizes encoders attached to the drive motors of our robot and employs several trigonometric formulas to convert the encoder values into a representation of the robot's pose. The step-by-step mathematical process is outlined below:

circle-exclamation

Firstly, we determine the distance traveled by the robot by converting the encoder readings for the left and right motors into actual distances.

Encoders provide measurements in ticks, so we need to convert these readings into meaningful units. To do this, we divide the raw encoder measurement by the number of ticks recorded for each complete revolution of the wheel. Then, we multiply this value by the circumference of the wheel to obtain the distance in inches that the wheel has traveled since the last reading of the odometry function.

Δtick=ticktick \Delta{tick} = tick' - tick
D=2πwheelRadiusΔtickticksPerRevolution\begin{equation*} D = 2\pi \cdot wheelRadius \cdot \frac{\Delta{tick}}{ticksPerRevolution} \end{equation*}

Note that this formula must be applied to both the left and right wheels.

We then average the calculated inch displacement from the left and right wheels giving the overall displacement of the robot represented as D_c

Dc=DlDr2\begin{equation*} D_c = \frac{D_l - D_r}{2} \end{equation*}

After determining the total displacement, we proceed to separate it into its x, y, and theta components using the trigonometric formulas provided below. By adding these components to the previously calculated values, we can obtain the current position of the robot.

circle-info

Note that the variable "L" is the track width of the robot (the distance between the front left and right wheels of the robot)

x=x+Dccosθ\begin{equation*} x' = x + D_c \cdot \cos{\theta} \end{equation*}
y=y+Dcsinθ\begin{equation*} y' = y + D_c \cdot \sin{\theta} \end{equation*}
θ=θ+DrDlL\begin{equation*} \theta' = \theta + \frac{D_r - D_l}{L} \end{equation*}

Implementation

Note that the code contains two update position functions:

  • updatePositionWithIMU() - Computes the position with the IMU (recommended)

  • updatePosition() - Computes the position without the IMU as theta.

Last updated