navX MXP Import Issue

I’m working on setting up the navX on Java with our roboRIO. I’ve followed the steps listed in this tutorial http://www.pdocs.kauailabs.com/navx-mxp/software/roborio-libraries/java/ and I’m still getting an error with the import. Here’s what the error is saying:


Buildfile: C:\Users\Developer\Documents\GitHub\DeltaBot\build.xml
Trying to override old definition of task classloader
clean:
   [delete] Deleting directory C:\Users\Developer\Documents\GitHub\DeltaBot\build
compile:
    [mkdir] Created dir: C:\Users\Developer\Documents\GitHub\DeltaBot\build
     [echo] [athena-compile] Compiling src with classpath=C:\Users\Developer/wpilib/java/current/lib/WPILib.jar:C:\Users\Developer/wpilib/java/current/lib/NetworkTables.jar to build
    [javac] Compiling 1 source file to C:\Users\Developer\Documents\GitHub\DeltaBot\build
    [javac] C:\Users\Developer\Documents\GitHub\DeltaBot\src\org\usfirst\frc	eam2972\robot\Robot.java:22: error: package com.kauailabs.navx.frc does not exist
    [javac] import com.kauailabs.navx.frc.AHRS;
    [javac]                              ^
    [javac] C:\Users\Developer\Documents\GitHub\DeltaBot\src\org\usfirst\frc	eam2972\robot\Robot.java:33: error: cannot find symbol
    [javac]     AHRS ahrs;
    [javac]     ^
    [javac]   symbol:   class AHRS
    [javac]   location: class Robot
    [javac] C:\Users\Developer\Documents\GitHub\DeltaBot\src\org\usfirst\frc	eam2972\robot\Robot.java:54: error: cannot find symbol
    [javac] 	           ahrs = new AHRS(SPI.Port.kMXP);  
    [javac] 	                      ^
    [javac]   symbol:   class AHRS
    [javac]   location: class Robot
    [javac] C:\Users\Developer\Documents\GitHub\DeltaBot\src\org\usfirst\frc	eam2972\robot\Robot.java:169: error: package AHRS does not exist
    [javac] 	          AHRS.BoardYawAxis yaw_axis = ahrs.getBoardYawAxis(); 
    [javac] 	              ^
    [javac] 4 errors

BUILD FAILED
C:\Users\Developer\wpilib\java\current\ant\build.xml:69: Compile failed; see the compiler error output for details.

Total time: 3 seconds

And my import line looks like this:


import com.kauailabs.navx.frc.AHRS;

Any ideas as to what may be causing this error?

I believe a step or two in the java library configuration instructionswas missed, specifically these one:

  1. Add a Java Build Variable for the navX-MXP Java Library. To set the build variable, from the Eclipse menu select Window->Preferences->Java->Build Path->Classpath Variables, then click on the “New…” button. Then, in the “New Variable Entry” dialog, set the name to “navx-mxp” and set the Path to <HomeDirectory>
    avx-mxp\java\lib
    avx_frc.jar. Hit OK to save this change.

and…

  1. Ensure that your project’s library paths include the navx-mxp variable, as well as WPI library path variables (networktables and wpilib). If any are missing, you can add them by clicking on the “Add Variable…” button.

If either the “navx-mxp” build variable is not present in the Eclipse Java ClassPath Variables settings - or if your project’s library paths do not include this “navx-mxp” variable, the error message you have reported is the very likely result.

Thanks for your response! I’ve followed those steps and its still throwing that error. My thought is that there might be an issue with the classpath in the usage of slashes. Does it matter if they are forward or backslashes? It only seems to let me input forward slashes when I’m adding the classpath (it changes backslashes to forward slashes when I save it) but the error output seems all squirly with half forward and half backslashes as follows:


     [echo] [athena-compile] Compiling src with classpath=C:\Users\Developer/wpilib/java/current/lib/WPILib.jar:C:\Users\Developer/wpilib/java/current/lib/NetworkTables.jar to build

Do you think this may be a factor in the error?

I don’t believe the forward slashes is where the problem lies.

The navx-mxp.jar file should be in the classpath. However, I don’t see it listed in the classpath in your latest message (although I do see the WPI library .jar and I do see Networktables.jar). So I think the problem is that when eclipse builds your project, it can’t find navx-mxp.jar. And that is confirmed by the complaint that it can’t locate the AHRS class, which is contained within the navx-mxp.jar library.

Please post the build.properties of the project

since the navx jar is not showing up in the classpath, it looks like the build.properties is not set up correctly.

[echo] [athena-compile] Compiling src with classpath=C:\Users\Developer/wpilib/java/current/lib/WPILib.jar:C:\Users\Developer/wpilib/java/current/lib/NetworkTables.jar to build

I believe the issue is that WPILib doesn’t know where to find the navx jar file. You must configure the build.properties as shown here.

The build.properties seems to be setup correctly according to the FRC tutorial on adding 3rd party libraries:


# Project specific information
package=org.usfirst.frc.team2972.robot
robot.class=${package}.Robot
simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world
userLibs=${user.home}/navx-mxp/java/lib/navx_frc.jar

Is there another issue that could potentially be affecting the classpath?

Are you sure you have installed the latest, released version of the WPI Libraries (installed by updating to the latest WPI plugins in eclipse)? The 2015 WPI library, and the 2016 betas, did not include the userLibs parameter. But the 2016 release version does. So I’d recommend you check your versions.

I checked Eclipse and found that someone had turned off automatic updates, and so I did have an older version of the WPI Libraries, however after updating I am still confronted with the same error messages. Is it possible Eclipse did not update to the true current version?

Does it match the version listed here: For the 2020 season software documentation has been moved to https://docs.wpilib.org. Documentation for KOP items can still be found here. | FRC KOP Documentation

Our Java plugin version is (0.1.0.201601151923) which is listed as the latest version, but the kickoff version seems to be more recent (0.1.0.201601072029). When press the update button in eclipse it says that no updates were found, but if ours is the …23 version and there is a newer …29 version, shouldn’t it find that version and update or am I missing something? Is …23 more recent than …29?

The whole last number is a date string, so 201601072029 was built on January 7th, whereas 201601151923 was built on January 15th. So you do have the newest version.

Okay so we know the eclipse plugins are up to date. My error message has changed slightly to reflect that it is finding some sort of navX library, or at least its looking for one, as you can see below:


     [echo] [athena-compile] Compiling src with classpath=C:\Users\Developer/wpilib/java/current/lib/WPILib.jar:C:\Users\Developer/wpilib/java/current/lib/NetworkTables.jar:C:\Users\Developer
     [echo] avx-mxpjavalib
     [echo] avx_frc.jar to build

So now its looking for something in C:\Users\Developer\avx-mxpjavalib or \avx_frc.jar so I can clearly see that something is misspelled due to the “avx” instead of “navx” but I cant seem to find where it is misspelled. Where do I edit the filepath for this so that it is correct?

OK, we’re making progress - now that you’ve got the correct WPI library version, the build is attempting to link to the navx library. But it appears that the path is wrong:

Here’s what you entered in your build.properties:

userLibs=${user.home}/navx-mxp/java/lib/navx_frc.jar

But it appears that when eclipse is building, each time the “/n” characters are encountered, those characters are being treated as a new-line character.

It’s interesting to note that the
sequence (where \ is an ‘escape’ character) translates to an ascii new-line character, which is what eclipse appear to be outputting.

This is likely a system-specific configuration issue, and I’m going to recommend trying it on another system - or else identifying what it is in your system that is interpreting “/n” in file system paths as a new line character. I’ve see this kind of thing happen sometimes if a package like Cygwin is installed, although I can’t remember the details off of the top of my head.

Thank you so much!! Our code builds now, we’re just experiencing connection issues so we haven’t had a chance to test it, but the code is happy!