1) Does Legacy navX work today? and 2) Why is ADIS16470_IMU missing getRotation2d?

Q1: 781 has 2 legacy navX boards that I’d like to use (versus buying new current units). In java, constructing them with “ahrs = new AHRS(SPI.Port.kMXP);” throws no build errors, however the code will not load onto the rio. Before I dig into this, anyone know if the legacy navXs can work with wpilib 2022+?
Q2: We do have an ADIS16470_IMU which I switched to after discovering 1. I notice that the ADIS16470_IMU class does not extend the Gyro class, and so does not have a getRotation2d() method. I’ve created an (untested) method (based on the gyro class) but wondered why wpilibj does not have that baked in.
Thanks
Pat

The AHRS class works with both the original NavX and the NavX2.
A new version of the vendordep is released every year to be compatible with that year’s WPILib.
If you’d like help debugging why the code doesn’t load, please include the error message, stack trace, etc.

As for ADIS16470_IMU not inheriting Gyro or having a getRotation2d method, open an issue on the allwpilib repo.

1 Like
1 Like

I think you can get a rotation2d from the raw angle using Rotation2d.fromDegrees(rawGyroAngle)

1 Like

Quick updates:

  1. there was a null pointer exception error because the AHRS was being created after the drive Odometry was instantiated. Fixed now and all is good using the legacy navXs.
  2. The “public Rotation2d getRotation2d()” method to “return Rotation2d.fromDegrees(-m_gyro.getAngle())” works with the ADIS16470. I appreciate the discussion in the allwpilib issue 4876.
    Now to get some path planning code going. Thanks everyone!
    Pat
1 Like

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