GPS Yaw/ Heading Bug

Hi! I recently made a post regarding a bug in the vex GPS sensor with incorrect wording. After further testing though I’ve found that moving the GPS sensor in a counterclockwise motion returns decreasing heading angles. e.g starting from 0 degrees and turning counterclockwise, 0, 350, 345, 330, 325, etc. Turning counterclockwise should return increasing angles e.g. 0, 30, 45, 90, etc, as in a unit circle.

This bug is an issue because c/ c++ math.h cosine and sine functions follow the unit circle. To get around this I just multiplied GPS.yaw() * -1

As I said in the other topic, this is not a bug, you are seeing the expected behavior. We use same value of heading as would be returned by the IMU, clockwise is increasing value.

2 Likes

Ahh thanks! Do most IMU’s lbehave like this? (as in IMU’s outside of vex?)

It varies.
We wanted to match the legacy EDR yaw rate gyro, here’s a few notes from when we were implementing the IMU.

IIRC, you can actually reverse it if you really want to, see the constructor.

      /** 
       * @brief Creates a new gps object on the port specified.
       * @param index The port index for this gps. The index is zero-based.
       * @param heading_offset The gps sensor rotational offset.
       */
      gps( int32_t index, double heading_offset = 0, turnType dir = turnType::right );

pass turnType::left and see what that does.

2 Likes

Oh awesome! Thanks for the added info, that’s cool to see how y’all decided on the behavior. Ooo I’ll try out turnType::left as well