My team is using 3 wheels for odometry. We are trying to use the left and right tracker wheels to track the angle the robot is facing. We followed this guide and the BLRS wiki, but the angle tracking isn’t that accurate. It is sometimes over 50 degrees off. Is there a better algorithm for this or should we stick with using the inertial sensor? We used the inertial sensor last season, but it was often a few degrees off by the end of a skills run.

Here is our code:

```
#define DEG_TO_IN (2.75 * M_PI / 360)
#define sL 5.4
#define sR 5.4
void runOdom(){
float lastLeft = Left.position(deg);
float lastRight = RightEncoder.position(deg);
float xPos = 0;
float yPos = 0;
while(true){
float left = LeftEncoder.position(deg);
float right = RightEncoder.position(deg);
float deltaLeft = (left - lastLeft) * DEG_TO_IN;
float deltaRight = (right - lastRight) * DEG_TO_IN;
angle += (deltaLeft - deltaRight) / (sL + sR);
xPos += (sin(angle * M_PI / 180) * (vertical - lastVertical) +
sin((90 + angle) * M_PI / 180) * (horizontal - lastHorizontal)) *
DEG_TO_IN;
yPos += (cos(angle * M_PI / 180) * (vertical - lastVertical) +
cos((90 + angle) * M_PI / 180) * (horizontal - lastHorizontal)) *
DEG_TO_IN;
lastAngle = angle;
lastLeft = left;
lastRight = right;
wait(20, msec);
}
}
```