navX2 mxp not outputing data - navX-Sensor DISCONNECTED on network console report

Hi all. I have the somewhat new navX2 mxp Micro (gyro) which should be compatible with the roboRio for FRC. I’m using the I2C port since the the Micro lack the SPI connection, but does have USB capabilities. For the code, imports include:
import navx
robotInit includes:
self.navx = navx.AHRS.create_i2c()
teleopPeriodic and disabledPeriodic both include for telemetry (with the proper prerequisite networktable initialization) :
self.networkTable.putNumber(“Navx Gyro”, self.navx.getAngle())
self.networkTable.putNumber(“Navx Yaw”, self.navx.getYaw())

All other telemetry in Shuffleboard works. The 2 Navx displays in Shuffleboard show “0” without refresh when the gyro is physically moved. I ran network console at code deployment and all was well without crash. At the end of the deployment, NC displayed “navX-Sensor DISCONNECTED”. Thus the lack of data output.
Has anyone else experienced this? Is there a compatibility issue with the NaxX2 version?
I’m soon running out of hair to pull. =)

There are two I2C ports on the RIO. I suggest explicitly passing the port used to the create_i2c() builder. Also, are you sure that the AHRS class is compatible with the navX2-micro?

Thanks Starlight220. I connected the navX2-micro to the other I2C connection on the Rio and all up and running correctly now. The I2C on the Rio’s MXP connector is apparently the default kwarg. Will try to pass port 0 or 2 and try the original port that I used for laughs and giggles.

Hi all. Have been using the NavX Micro on the I2C port this season 2022 for the most part without issue. However, the i2C port on the Rio has been a bit wonky per numerous reports. We had issues with the color sensor attached to the I2C port so that was removed. I am trying to migrate the NavX micro over to using the USB connection so to part ways with the I2C port for the time being. I am however not able to do so. Currently the NavX is initialized in the robotInit with this:

self.navx = navx.AHRS.create_i2c()

Does anyone know what is needed for the USB usage instead?
I have tried:
self.navx = navx.AHRS.create_SerialPort()
and other slight variations on Serial without success.

Would truly appreciate it if someone can chime in on this.
Thanks!

I’m not familiar with this setup myself, but I think you need to specify which USB port it is, and whether you want it to be raw or processed. Also, this FAQ may be useful.

Per NavX API — robotpy-navx 2022.0.2 documentation there isn’t an equivalent create function for serial/usb. But it does show an __init__ method for serial.

Unfortunately I don’t know python so I can’t help you from there.

As Joe pointed out, there isn’t a special static function for serial/usb. However, you should be able to use the constructor like so:

self.navx = navx.AHRS(wpilib.SerialPort.Port.kUSB)

There are several USB options apparently… kUSB, kUSB1, and kUSB2.

Thank You! Thank You! Thank You!

self.navx = navx.AHRS(wpilib.SerialPort.Port.kUSB)
did the trick. Worked like a charm.

Of note, here are my findings.
If use self.navx = navx.AHRS(wpilib.SerialPort.Port.kUSB) in robotInit,
both USB ports (outer and inner) will work with the NavX micro.
If use self.navx = navx.AHRS(wpilib.SerialPort.Port.kUSB1),
as expected, only the outer USB port will work.
If use self.navx = navx.AHRS(wpilib.SerialPort.Port.kUSB2),
neither port will work. Infact the Driver Station will crash with the robot code indicator
repeatedly flashing green then red .

Good riddance to the I2C port.

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