# create2 angle (packet ID 20)

how to convert the value you get for the angle (packet ID 20) into degrees? i am using the create2 robot and when I did not understand the data I am getting back. The documentation it says it's in degrees but what I get back is a huge number like 4864 when I turned the robot just 45 degrees.

Well, the Distance opcode (packet ID 19) has a known bug in it. So I wouldn't be surprised if this also affects the Angle packet. I would recommend using the Left Encoder Counts and Right Encoder Counts opcodes (packets 43 and 44) and compute the angle yourself.

The angle is pretty easy to calculate from the distances traveled by each wheel. This document has a good introduction to mobile robot kinematics. But simply:

$$\theta = \frac{d_r - d_l}{l}$$

Where $d_r$ and $d_l$ are the distances traveled by the right and left wheels respectively since the last time step. And $l$ is the wheel base of the robot. The wheel base, number of encoder ticks per revolution, and wheel diameter can be found in the OI Spec.

Regarding units, the units for $d_r$, $d_l$, and $l$ shouldn't matter as long as they are all the same. $\theta$ is in radians. Picking mm for the lengths is easy because that is what is specified in the spec. The wheel base is 235.0 mm. To determine mm traveled from encoder ticks, I find it easiest to think about as a unit conversion using the equation for circle circumference. If you have $X$ ticks:

$$d \text{ (mm)} = X \text{ (ticks)} \begin{bmatrix} \frac{1 \text{ (revolution)}}{508.8 \text{ (ticks)}} \end{bmatrix} \begin{bmatrix} \frac{\pi 72.0 \text{ (mm)}} {1 \text{ (revolution)}} \end{bmatrix}$$

• Thanks for the reply. packet 43&44 give you raw encoder counts does the equation above cares about units? also I am not sure how to calculate the wheel base give the encoder ticks /rev and wheel diameter. can you please shed more light on this? thanks a million
– Jack
Apr 23, 2015 at 20:34