Announcement

Collapse
No announcement yet.

new FTC-compatible navX-Micro IMU / AHRS Sensor Announced

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Try using this version of the AHRS class: http://pastebin.com/Zfyebnwa.

    Comment


    • I looked at this with them and it appears that the new I2C interface is not compatible with the old one. Specifically, the line that says:

      Code:
      navx_ftc/src/main/java/com/kauailabs/navx/ftc/AHRS.java:1116: error: I2cDevice is abstract; cannot be instantiated
                  navXDevice = new I2cDevice(dim, dim_port);
      and comparing the javadoc from 1.77 to an old version, I2Cdevice is totally different.
      FTC 4962 / 3638
      FLL 11 / 21 / 9293

      Comment


      • Originally posted by dmssargent View Post
        Try using this version of the AHRS class: http://pastebin.com/Zfyebnwa.
        Nevermind that, I thought it was a different problem in the AHRS class.

        Originally posted by FTC4962 View Post
        We are trying to compile against the 1.77 beta, and are getting this runtime error for "failed compile-time verification". We're running Android Studio 1.5.1. Does anyone have ideas about what might be going on? It's using the example code for reading the raw output.



        Code:
        06-02 22:09:18.815 18545-18790/com.qualcomm.ftcrobotcontroller I/RobotCore: Attempting to switch to op mode ExNavXRaw
        06-02 22:09:18.818 18545-18790/com.qualcomm.ftcrobotcontroller V/RobotCore: thread: ...terminating 'opmode loop()'
        06-02 22:09:18.819 18545-18790/com.qualcomm.ftcrobotcontroller E/AndroidRuntime: FATAL EXCEPTION: opmode loop()
                                                                                         Process: com.qualcomm.ftcrobotcontroller, PID: 18545
                                                                                         java.lang.VerifyError: Rejecting class com.kauailabs.navx.ftc.AHRS$navXIOThread because it failed compile-time verification (declaration of 'com.kauailabs.navx.ftc.AHRS$navXIOThread' appears in /data/app/com.qualcomm.ftcrobotcontroller-1/base.apk)
                                                                                             at com.kauailabs.navx.ftc.AHRS.<init>(AHRS.java:175)
                                                                                             at com.kauailabs.navx.ftc.AHRS.getInstance(AHRS.java:247)
                                                                                             at com.qualcomm.ftcrobotcontroller.opmodes.ExNavXRaw.init(ExNavXRaw.java:76)
                                                                                             at com.qualcomm.robotcore.eventloop.opmode.OpModeManager.callActiveOpModeInit(SourceFile:357)
                                                                                             at com.qualcomm.robotcore.eventloop.opmode.OpModeManager.runActiveOpMode(SourceFile:273)
                                                                                             at com.qualcomm.ftccommon.FtcEventLoop.loop(SourceFile:169)
                                                                                             at com.qualcomm.robotcore.eventloop.EventLoopManager$b$1.run(SourceFile:379)
                                                                                             at com.qualcomm.robotcore.util.ThreadPool.logThreadLifeCycle(SourceFile:298)
                                                                                             at com.qualcomm.robotcore.eventloop.EventLoopManager$b.run(SourceFile:330)
                                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                                             at java.lang.Thread.run(Thread.java:818)
        06-02 22:09:18.871 18545-18666/com.qualcomm.ftcrobotcontroller V/RobotCore: sending CMD_INIT_OP_MODE_RESP(145), attempt 0
        06-02 22:09:19.343 18545-18545/com.qualcomm.ftcrobotcontroller I/FIRST: Stopping FTC Controller Service
        06-02 22:09:19.343 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: There are 0 Wifi Direct Assistant Clients (-)
        06-02 22:09:19.343 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: Disabling Wifi Direct Assistant
        06-02 22:09:19.438 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: executive service robot setup is terminated
        06-02 22:09:19.438 18545-18545/com.qualcomm.ftcrobotcontroller D/RobotCore: RobocolDatagramSocket is closed
        06-02 22:09:19.438 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: waiting for service EventLoop SendReceive
        06-02 22:09:19.438 18545-18667/com.qualcomm.ftcrobotcontroller D/RobotCore: RobocolDatagramSocket receive error: java.net.SocketException: Socket closed
        06-02 22:09:19.438 18545-18667/com.qualcomm.ftcrobotcontroller V/RobotCore: thread: ...terminating 'RecvRunnable.run()'
        06-02 22:09:19.438 18545-18666/com.qualcomm.ftcrobotcontroller V/RobotCore: thread: ...terminating 'ScheduledSendRunnable.run()'
        06-02 22:09:19.444 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: awaitTermination returned, isTerminated=true
        06-02 22:09:19.444 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: executive service EventLoop SendReceive is terminated
        06-02 22:09:19.444 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: waiting for service EventLoop
        06-02 22:09:19.450 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: awaitTermination returned, isTerminated=true
        06-02 22:09:19.450 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: executive service EventLoop is terminated
        06-02 22:09:19.450 18545-18545/com.qualcomm.ftcrobotcontroller V/RobotCore: EventLoopManager state is STOPPED
        06-02 22:09:19.450 18545-18545/com.qualcomm.ftcrobotcontroller I/FIRST: Robot Status: stopped
        06-02 22:09:19.451 18545-18545/com.qualcomm.ftcrobotcontroller D/RobotCore: RobocolDatagramSocket is closed
        06-02 22:09:19.451 18545-18545/com.qualcomm.ftcrobotcontroller I/FIRST: Robot Status: null
        06-02 22:09:19.458 18545-18545/com.qualcomm.ftcrobotcontroller E/ActivityThread: Activity com.qualcomm.ftcrobotcontroller.FtcRobotControllerActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
                                                                                         android.app.IntentReceiverLeaked: Activity com.qualcomm.ftcrobotcontroller.FtcRobotControllerActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
                                                                                             at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:907)
                                                                                             at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:708)
                                                                                             at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1771)
                                                                                             at android.app.ContextImpl.registerReceiver(ContextImpl.java:1751)
                                                                                             at android.app.ContextImpl.registerReceiver(ContextImpl.java:1745)
                                                                                             at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:488)
                                                                                             at com.qualcomm.analytics.Analytics.register(SourceFile:209)
                                                                                             at com.qualcomm.analytics.Analytics.<init>(SourceFile:235)
                                                                                             at com.qualcomm.modernrobotics.ModernRoboticsUsbUtil.init(SourceFile:85)
                                                                                             at com.qualcomm.ftccommon.FtcEventLoop.init(SourceFile:142)
                                                                                             at com.qualcomm.robotcore.eventloop.EventLoopManager.a(SourceFile:650)
                                                                                             at com.qualcomm.robotcore.eventloop.EventLoopManager.setEventLoop(SourceFile:621)
                                                                                             at com.qualcomm.robotcore.eventloop.EventLoopManager.start(SourceFile:562)
                                                                                             at com.qualcomm.robotcore.robot.Robot.start(SourceFile:58)
                                                                                             at com.qualcomm.ftccommon.FtcRobotControllerService$b$1.run(SourceFile:175)
                                                                                             at com.qualcomm.robotcore.util.ThreadPool.logThreadLifeCycle(SourceFile:298)
                                                                                             at com.qualcomm.ftccommon.FtcRobotControllerService$b.run(SourceFile:123)
                                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                                             at java.lang.Thread.run(Thread.java:818)
        06-02 22:09:20.342 18545-18941/com.qualcomm.ftcrobotcontroller V/RobotCore: closing logcat file /storage/emulated/0/com.qualcomm.ftcrobotcontroller
        06-02 22:09:20.400 18545-18560/com.qualcomm.ftcrobotcontroller W/art: Suspending all threads took: 5.466ms
        06-02 22:09:20.432 18545-18941/com.qualcomm.ftcrobotcontroller V/RobotCore: Killing PID 18594
        06-02 22:09:51.251 18545-18559/com.qualcomm.ftcrobotcontroller I/art: WaitForGcToComplete blocked for 9.218ms for cause HomogeneousSpaceCompact
        06-02 22:09:51.277 18545-18560/com.qualcomm.ftcrobotcontroller W/art: Suspending all threads took: 24.906ms
        06-02 22:10:01.664 18545-18559/com.qualcomm.ftcrobotcontroller I/art: WaitForGcToComplete blocked for 24.028ms for cause HomogeneousSpaceCompact
        06-02 22:10:01.689 18545-18560/com.qualcomm.ftcrobotcontroller W/art: Suspending all threads took: 24.852ms

        Originally posted by BSV View Post
        I looked at this with them and it appears that the new I2C interface is not compatible with the old one. Specifically, the line that says:

        Code:
        navx_ftc/src/main/java/com/kauailabs/navx/ftc/AHRS.java:1116: error: I2cDevice is abstract; cannot be instantiated
                    navXDevice = new I2cDevice(dim, dim_port);
        and comparing the javadoc from 1.77 to an old version, I2Cdevice is totally different.
        From what I can see is the I2cDeviceImpl is the dropin replacement for I2cDevice, try changing line 1135:
        Code:
        navXDevice = new I2cDevice(dim, dim_port);
        to
        Code:
        navXDevice = new I2cDeviceImpl(dim, dim_port);
        The FTC SDK apparently broke backwards compatibly big time with the I2C Device.

        The following function may be used to resolve cross version differences in how I2C devices are built, but I can't guarantee anything:
        Code:
        /**
        * Creates a API independent {@link I2cDevice} instance
        *
        * @param dim {@link I2cController} this channel is attached to
        * @param port  port on the I2C controller
        * @return the corresponding I2C Device instance
        * @throws RuntimeException if the I2C Device can't be built
        */
                public static I2cDevice getI2cDeviceInstance(I2cController dim, int port) {
           Constructor constructor = null;
           Exception cause = null;
           try {
               constructor = I2cDevice.class.getConstructor(I2cController.class, Integer.TYPE);
           } catch (NoSuchMethodException e) {
               final Class<?> aClass;
               try {
          aClass = Class.forName("com.qualcomm.robotcore.hardware.I2cDeviceImpl");
          constructor = aClass.getConstructor(I2cController.class, Integer.TYPE);
               } catch (ClassNotFoundException | NoSuchMethodException ex) {
          // handled at a later point in time
          cause = ex;
               }
           }
             try {
               if (constructor != null) {
          return (I2cDevice) constructor.newInstance(dim, port);
               }
           } catch (InvocationTargetException ex) {
               throw new RuntimeException("The instance throw during instantiation.", ex.getCause());
           } catch (Exception ex) {
               cause = ex;
           }
             throw new RuntimeException("Cannot determine how to create I2C Device instance", cause);
        }

        Comment


        • Originally posted by dmssargent View Post
          From what I can see is the I2cDeviceImpl is the dropin replacement for I2cDevice, try changing line 1135:
          Hmm, yeah, you are right. Builds perfectly. Will have the kids try to plug it in this weekend.
          FTC 4962 / 3638
          FLL 11 / 21 / 9293

          Comment


          • And thanks for the info!
            FTC 4962 / 3638
            FLL 11 / 21 / 9293

            Comment


            • Hi, so we recently got the NAVX and found that the FTC Robot Controller would crash whenever we started the NavXProcessed OpMode on the Beta Release(Release 16.07.08), we then tried on on the latest stable release link on the navX Github (Release 16.02.09) and found that it worked. Any ideas on what causes this?

              Thanks!
              FTC 8686

              Comment


              • We figured it out, didn't see the post before this with the solution, just change I2cDevice to I2cDeviceImpl in AHRS.class
                Thanks

                Comment


                • The navX-Micro Robotics Navigation Sensor library for FTC/Android has been updated to work correctly with the latest Beta 2.0 version of the FTC "ftc_app" library. The updated library can be downloaded from the navX-Micro site.

                  The various navX-Micro robot application examples have also been updated to conform to the new pattern for examples specified in the 2.0 beta release.

                  Please feel free to contact [email protected] if you have any questions.

                  Comment


                  • Originally posted by FTC10386 View Post
                    The various navX-Micro robot application examples have also been updated to conform to the new pattern for examples specified in the 2.0 beta release.

                    It's great that you've tweaked your examples to conform to the "Samples Convention" that's now part of the SDK (external/samples). Consistence is the key to easier idea exchange.

                    It's not required, but if you modified your motor device names just a tad, your samples would be drop-in compatible with the standardized Push-bot configuration template.

                    leftMotor = hardwareMap.dcMotor.get("left_drive");
                    rightMotor = hardwareMap.dcMotor.get("right_drive");

                    would go to

                    leftMotor = hardwareMap.dcMotor.get("left motor");
                    rightMotor = hardwareMap.dcMotor.get("right motor");

                    I'm looking forward to trying these.

                    Phil.

                    Comment


                    • Hello,
                      We bought a NavX Micro sensor last season and having difficulty incorporating it into the New App this season. When I try to build the project, I get an error:

                      Error:Error converting bytecode to dex:
                      Cause: com.android.dex.DexException: Multiple dex files define Lcom/kauailabs/navx/AHRSProtocol$AHRSPosUpdate;
                      :TeamCode:transformClassesWithDexForDebug FAILED
                      Error:Execution failed for task ':TeamCode:transformClassesWithDexForDebug'.
                      > com.android.build.api.transform.TransformException : com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

                      Did anyone else encounter this error? If so, how did you resolve it?

                      Also, are there Mac specific software libraries for NavX micro? The instructions on the Kauai labs seem to be only applicable to Windows. Our programming team is using Mac OSx so we had to download the library to a Windows computer first and then transfer the extracted .ear files to Mac. Not sure if that was the cause of above error.

                      Comment


                      • Originally posted by rbFTC View Post
                        Hello,
                        We bought a NavX Micro sensor last season and having difficulty incorporating it into the New App this season. When I try to build the project, I get an error:

                        Error:Error converting bytecode to dex:
                        Cause: com.android.dex.DexException: Multiple dex files define Lcom/kauailabs/navx/AHRSProtocol$AHRSPosUpdate;
                        :TeamCode:transformClassesWithDexForDebug FAILED
                        Error:Execution failed for task ':TeamCode:transformClassesWithDexForDebug'.
                        > com.android.build.api.transform.TransformException : com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

                        Did anyone else encounter this error? If so, how did you resolve it?

                        Also, are there Mac specific software libraries for NavX micro? The instructions on the Kauai labs seem to be only applicable to Windows. Our programming team is using Mac OSx so we had to download the library to a Windows computer first and then transfer the extracted .ear files to Mac. Not sure if that was the cause of above error.
                        Haven't seen the error, however the message about "multiple dex files defining Lcom/kauailabs/navx/AHRSProtocol$AHRSPosUpdate" does imply a build path issue. See this discussion: http://stackoverflow.com/questions/8...x-files-define

                        As far as using the navX libraries on a Mac, it sounds like you've done what is the suggested workaround, which is to install the navX-Micro software to Windows, then copy the following file from C:\Users\<username>\navx-micro\android\libs to a similar destination on the Mac: navx_ftc-release.aar

                        Note that the current setup will install also a debug version of the .aar file (navx_ftc-debug.aar). There shouldn't be any need to copy this file. And indeed it's possible that both are being referenced which might lead to the error message you are seeing.

                        Comment


                        • Thank you for your help. That indeed turned out to be a build.gradle issue. The build worked after putting the nax_ftc-release.aar file in an external (outside the Android Studio project) directory adding that path to the build.gradle(TeamCode Module) file. I also found out that I mistakenly put the navx java files under FtcRobotController/src/main/java/com/kauilabs/..... So I removed all the navx java (AHRS.java, etc.) from the project.

                          Comment


                          • Hi - We are using the NavX Micro navigation sensor. Board version 4.0, firmware 2.3. The sensor is being used during Autonomous for turns (yaw). Several times during competition, the robot, rather than executing a 180 deg turn, spins continuously. Long story short, we were able to isolate the behavior. Our drive team will sometimes restart the robot (from the driver's station) during the pre-match setup. This consistently yields an unchanging (frozen) yaw output. If the robot is power-cycled, the Nav-X starts producing data (or the software starts receiving data?).

                            Some things we've done. Hooked the NavX up to NavXUI. Everything seems correct. Calibration takes about 18 seconds and all the data looks good.

                            Hooked the bot up to Core Device and pulled the data from the following registers while the sensor was functioning properly.
                            0x08 Op Status - result 4 - NAVX_OP_STATUS_NORMAL
                            0x09 Cal Status - result 2 - NAVX_CAL_STATUS_IMU_CAL_COMPLETE
                            0x0A Self Test Status - result 135 - appears to not be a valid result
                            0x0B Capability Flag - result 236 - appears to not be a valid result
                            0x10 Sensor Status - result 6 - appears to not be a valid result

                            Any thoughts on the matter? Anyone else see this behavior? Thanks, 4318

                            Comment


                            • We did experience the same problem on our robot. I do not recollect power-cycling the robot solving the problem; I am pretty sure we tried it. We did not do any diagnosis with the Core Device Discovery, but the NavxUI did not show anything suspicious. The problem disappeared after we eventually put NavX on its own exclusive CDIM.

                              Comment


                              • Thanks rbFTC. Seems like the NAVX shouldn't need a dedicated CDIM. It should operate on the I2C bus without any conflicts. Current thinking (will look closely this weekend) that we are not utilizing the AHRS close() and AHRS.getInstance() methods correctly. Will take a close look this weekend and report back. Cheers.

                                Comment

                                Working...
                                X