Navx MXP (classic) yaw reset problem

Hi,
we are using Navx MXP plugged into Roborio’s MXP port. During practice, whenever a new version of the Robot code is deployed from VScode, we want the current orientation to be considered as 0 yaw. To accomplish this, we put “ahrs.reset();” statement in the DriveTrain() constructor method. However, the yaw value being displayed on the SmartDashboard continues to display the old value.

The following statement displays the yaw value:
DriveTrain::periodic() {
SmartDashboard.putNumber(“yaw”, ahrs.getYaw());
}

Restarting the Robot code or Roborio from the Driver Station did not cause yaw reset either; only unplugging the battery caused yaw reset.

Are we doing something wrong in resetting the yaw? If so, what is the right way to do it?

Calling that function should work. I looked for your code, but it doesn’t seem to be on the github user I thought it would be. Can you send a link so we can know how to help?

We discovered that the navX doesn’t want to reset during calibration, so we added a loop to wait until calibration was complete, the reset it. If you enable print statements in the DS console you’ll likely see a message about resetting during calibration

Thank you. The code is on a Student’s laptop. I will post the link once it is pushed to github. fyi, that will not happen until tomorrow afternoon (Eastern time) though.

We tried that step too, but it did not help. So the full Navx related code in DriveTrain constructor looks like this (I am typing from my memory):

...
ahrs = new AHRS(SPI.Port.kMXP);
if (ahrs.isConnected())
    while (ahrs.isCalibrating())
         ;
ahrs.reset();
...

I will check the print statements in DS console tomorrow when I go to the school. Thank you for the suggestion.

I would remove the ahrs.isConnected() condition, we tried that and for some reason it wouldn’t report as connected until it was done calibrating

1 Like