java.lang.ArrayIndexOutOfBoundsException error in Nvx-Micro (FTC)

16 views
Skip to first unread message

RB

unread,
Feb 5, 2017, 10:37:48 PM2/5/17
to navx-mxp
Hi Scott,

Today we had our FTC Championship event, where our robot froze in almost every attempt to drive it after 2 games.  We are trying to find out the problem going through the logcat files, but I found the following error message that came from Nav-micro.  Could you go through the error message and see if there is some issue with the Navx driver code ?  Please let me know if you need more information. - Thanks

02-05 12:29:18.079 17567 17680 E AndroidRuntime: FATAL EXCEPTION: r/w loop: Modern Robotics USB Core Device Interface Module [AL00VBY8]
02-05 12:29:18.079 17567 17680 E AndroidRuntime: Process: com.qualcomm.ftcrobotcontroller, PID: 17567
02-05 12:29:18.079 17567 17680 E AndroidRuntime: java.lang.ArrayIndexOutOfBoundsException: length=0; index=2
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.kauailabs.navx.AHRSProtocol.decodeBinaryUint32(AHRSProtocol.java:685)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.kauailabs.navx.ftc.AHRS$navXIOThread.decodeNavxProcessedData(AHRS.java:1306)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.kauailabs.navx.ftc.AHRS$navXIOThread.ioComplete(AHRS.java:1052)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.kauailabs.navx.ftc.AHRS$DimI2cDeviceReader.portDone(AHRS.java:1688)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.kauailabs.navx.ftc.AHRS$DimI2cDeviceReader.access$600(AHRS.java:1513)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.kauailabs.navx.ftc.AHRS$DimI2cDeviceReader$1.portIsReady(AHRS.java:1546)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.qualcomm.robotcore.hardware.I2cDeviceImpl.portIsReady(I2cDeviceImpl.java:249)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.qualcomm.hardware.modernrobotics.ModernRoboticsUsbDeviceInterfaceModule.readComplete(ModernRoboticsUsbDeviceInterfaceModule.java:932)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.qualcomm.hardware.modernrobotics.comm.ReadWriteRunnableStandard$1.run(ReadWriteRunnableStandard.java:369)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.qualcomm.robotcore.util.ThreadPool.logThreadLifeCycle(ThreadPool.java:513)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at com.qualcomm.hardware.modernrobotics.comm.ReadWriteRunnableStandard.run(ReadWriteRunnableStandard.java:304)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
02-05 12:29:18.079 17567 17680 E AndroidRuntime: at java.lang.Thread.run(Thread.java:818)

admin

unread,
Feb 6, 2017, 12:10:19 PM2/6/17
to navx-mxp
Hi RB,

I've been reading through the code and reviewing the logs.

So from the logs, the AHRS class is requesting data over I2C from the CDIM, the request is for 26 bytes.  Then, as the returned data is decoded, an exception occurs.  The reasonble explanation for this to occur would be that the although the CDIM indicated the read was complete, 0 bytes of data are returned.

I've never seen this happen before; in cases where the sensor is not connected, the DIM will return 26 bytes of "junk".

This issue has been added re: making the navX FTC driver resilient in this case, but the logs suggest something has changed in the normal operation of the Core Device Interface Module. 

Do you have another you could try?

 Another perhaps less likely hypothesis is that there was a memory allocation failure somewhere (in the code that attempted to allocate the byte array to return the results to the navx_ftc library.  Are you seeing any other symptoms of an out-of-memory condition?

- scott 

RB

unread,
Feb 6, 2017, 4:06:02 PM2/6/17
to navx-mxp

admin

unread,
Feb 6, 2017, 4:47:36 PM2/6/17
to navx-mxp
Hmm, this is useful information.  We'll get to work on a modifying the navx_ftc to discard the 0-length read response rather than attempt to decode it.  Hopefully we should have that ready and tested within a week or less.

It's worth however continuing to understand why these cases of 0 returned bytes might be occurring.  Specifically, is this a bug or is this an expected behavior....

Also, I'm assuming that in your robot configuration there are multiple devices connected to the Core Device Interface Module, can you please confirm?

RB

unread,
Feb 6, 2017, 6:00:33 PM2/6/17
to navx-mxp
Yes, apart from navx-micro, we have a range sensor and a color sensor on the I2C bus, and an ODS sensor on the analog port.

RB

unread,
Feb 6, 2017, 6:14:21 PM2/6/17
to navx-mxp
btw, the full logcat files are available here:


If you see anything suspicious, even if it unrelated to navx-micro, please let me know.  Appreciate your help in resolving this issue.

admin

unread,
Feb 10, 2017, 8:01:46 PM2/10/17
to navx-mxp
The issue w/the navx_ftc library throwing an exception if it receives a non-null, 0-byte length array (or any array length less than the 26 bytes that was requested) when reading I2C data from the Core Device Interface Module (CDIM) has been resolved.

This is now available on the navX-Micro Software Download page (click on the Download button).  The new version is 3.0.324.

- scott

RB

unread,
Feb 15, 2017, 1:49:56 PM2/15/17
to navx-mxp
OK, thank you very much!  I will test it this week.

admin

unread,
Feb 15, 2017, 1:50:47 PM2/15/17
to navx-mxp
Please keep us posted on your results.

RB

unread,
Feb 15, 2017, 3:21:47 PM2/15/17
to navx-mxp
Do I need to update the firmware on the sensor, or only copy the new navx_ftc-release.aar file into my Android Studio?

admin

unread,
Feb 15, 2017, 4:27:08 PM2/15/17
to navx-mxp
Only the library needs to be updated.

RB

unread,
Feb 16, 2017, 8:47:31 PM2/16/17
to navx-mxp
I just downloaded and ran setup.exe on my windows computer, and I see navx-micro/firmware/navx-micro_3.0.324.hex file, which is different from navx-micro_3.0.273.hex file.  This seems to indicate that I need to update the firmware also.  It is not a big deal, I can do that, but I just want to verify with you that the firmware has been refreshed.  Thanks.

admin

unread,
Feb 16, 2017, 10:28:48 PM2/16/17
to navx-mxp
For FTC, the firmware you have is fine; the new revision of firmware has some FRC-specific features in it.
Reply all
Reply to author
Forward
0 new messages