NavX2 code not working - has to do with edu.wpi.first.wpilibj.PIDController vs edu.wpi.first.wpilibj.controller.PIDController;

My team just received one of the new NavX2s. When looking over the documentation, we decided to look at the example code. However, all of the example code uses the old import edu.wpi.first.wpilibj.PIDController; when we need the new one edu.wpi.first.wpilibj.controller.PIDController. When we change it however, other locations in the code, (trying to make a new PIDController class with 6 arguments, setting input and output, and setting tolerance and continuous. Is there any alternatives to these or a solution? Thank you!

Bonus question: It seems all of the examples are for robots with omnidirectional wheels. Do we need those on our robot for the NavX2 to be useful?

I can answer your bonus question: No, the NavX and gyros in general are useful even on differential drives, but you might get more wheel scrub depending on your drivebase.

3 Likes

I doubt that there is any difference between the NavX2 and the original NavX code-wise. Look at the FRC documentation and the examples there, the docs and examples on Kauai’s site are possibly outdated. The NavX AHRSclass is a drop-in replacement for the ADXSR450_Gyro class used in the examples, with the exception of needing to invert the angle (just use -getAngle()).

Thank you for your help! Just one more question- what do you suggest as a replacement for PIDController with the new one not working with all of the functions?

Read this:

It explains how to use the newer PIDController class and notes some of the differences from the old/deprecated one.

The NavX examples on GitHub were just updated to use the new PIDController.

1 Like

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