Nav X only resetting about 1-2 seconds after enabling

We tried to reset the nav x gyro to 0 in the swerve constructor, but it wasn’t being called. We thought that the gyro might be calibrating and that’s why we couldn’t set the value. So we tried doing it in periodic when it stops calibrating and is connected to the robot (only once obviously), and it works fine and resets after 1-2 seconds. Is this normal? Is there a way to circumvent this and have it reset immediately?

I think you’re describing a problem we worked around.

We ended up doing something like this, and it works. Your solution seems cleaner, so I’ll try it out!

Thank you

Even if you wait until the NavX has finished calibrating, it doesn’t zero immediately, as it sends a command to the NavX Firmware to zero, and it takes time for the NavX to zero and send the result back. But it should be on the order of 10s of ms, not 1-2 seconds, IIRC.

It sounds like you’ve solved your problem, but my general advice would be not to reset the hardware gyro, but instead rely on features like Odometry.resetPosition, which says:

Resets the robot’s position on the field.
The gyroscope angle does not need to be reset here on the user’s robot code. The library automatically takes care of offsetting the gyro angle.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.