JAR Template Odom

Hello, we have one tracker odom on our robot (just the forward tracker) and I was looking through the odom code in the JAR template and got confused on the part of the code shown in the screenshot.


Why is it being converted to polar coordinates and then back to cartesian coordinates? I noticed that it does make one tracker odom work, but I don’t quite understand why that is.

atan2(y_position, 0) always returns 90 degrees, and the local_polar_length is always just equal to local_Y_position. How are these values used then to get the X coordinate of the robot with just a tracker on the Y axis?

Also, is the global_polar_angle variable meant to just get the angle of the vector from (1, 0) as shown below?

Thank you for the help.

The odom class is based completely on 5225A’s intro to position tracking document.

When the robot drives forward at some angle, the local displacement is only in the Y direction, but the global displacement is in the direction the robot is facing, so when the robot turns, “forward” means something else, essentially.

Yes, global polar angle is counterclockwise from positive x.

3 Likes