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:
Someone correct me if I’m wrong, but should it be:
AHRS navX = new AHRS(SPI.port.kMXP); ??
The NavX supports several interfaces. If the NavX is directly connected to the RoboRIO, then SPI is the best choice, but I2C should work as well.
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.
I have both a navx mxp and a micro navx. Both had the same issue.
But I’ll try the resources you gave me and see what happens. Thanks!
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.
Have you recalibrated your NavX since mounting it on the robot. All bets are off until you do that.
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.
How would you do this exactly?
Calibration? It’s in the manual. Two buttons in the proper sequence on a not moving robot.
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()
As long as the green S1 and S2 LEDs are on the sensor is operating as expected. Are the S1 and S2 LEDs solid on?
Do you have another NavX you can try?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.