I’m trying to get our gyro working using a navX sensor. I have the libraries downloaded and the latest firmware updated onto the navX, but the gyro angle doesn’t change. It stays at 0. Am I missing something?
Here’s the code:
AHRS navX = new AHRS(I2C.Port.kMXP);
In teleop periodic:
System.out.println(navX.getAngle());
From your example, you appear to be using navX-MXP and Java (please let us know if that’s not correct).
If an angle of 0 is always being returned, the most likely issue is your software is not connecting to the sensor. You can use the “isConnected()” method of the AHRS class to tell if the connection is established; teams often put this information onto the dashboard (along with “isCalibrating()”) so they can easily verify sensor status.
There are many helpful navX-sensor examples that demonstrate basic usage. One of them (the “Data Monitor” example) is particularly helpful if you’re new to using the navX-sensor.
Once you’ve gotten things up and running, you’re strongly recommended to also review the Best Practices documentation.
And if you get stuck and the fine folks here on ChiefDelphi aren’t enough help for you, you can contact navX-Sensor support for help.
Alright so I was able to test, and isConnected() is returning false. Is it possible that the navX is stuck in a specific mode? The 3.3v led is always red while the cal and s1 wires are green.
As long as the green S1 and S2 LEDs are on the sensor is operating as expected. Is the S2 LED solid on?
Does this “not connected” behavior occur when you run the DataMonitor example?
Can you post your custom code that initializes the sensor and accesses the data? And a photo that shows how your sensor is mounted and what the onboard LEDs look like?
The more info like this you can provide the quicker we can determine what the causes for your troubles are.
I haven’t used the NavX yet, but these results appear to be very similar to problems encountered with the 2019.1.x WPILib (gyro returning consistently 0).
You say here that you have the latest software on the NavX, what about WPILib?
Yup I have the latest firmware for both navx and wpilib. the isConnected() method returns false, while the isCalibrating() method return true. Angle is still 0.
I tried that and I noticed that when connected to the robot, the cal led on the navX blinks orange and never turns off. This means that it is in calibration mode. So I’m guessing that it is stuck in calibration mode and never enters “normal” mode.
Note that, code returns true for isCalibration() but not isConnected()