Setting Up Your Eclipse Workspace For Using The NRSDK
From Neuron Robotics Wiki
Contents |
Setup Your System
IMPORTANT: Install all software before plugging in your hardware!
Before you can move on to the rest of the directions, everything in this section needs to be either done or accounted for.
Setting up Eclipse to use the NRSDK is not much different than using a generic Java environment.
- You will also need the Java 7 JDK.
- Start by installing Eclipse IDE for Java Developers. (This is installed for you on Ubuntu as a dependency to the NRSDK)
- Also before you can start you will need to download and install the NR RDK latest release.
- Locate the nrdk-<version>.jar file. It will be either installed on your system by the installer or in the zip file. It will be found in:
<install path>/rdk/java/
For example
On Ubuntu Linux, with the installer, it will be:
/usr/local/NeuronRobotics/RDK/java/
On Windows it will be:
C:\Program Files\Neuron Robotics RD\nrdk-3.8.1\java
You will also notice that there is a directory "NRDK_Test". In this directory are all of the samples from the website along with a few additional sample Java projects.
Starting Eclipse
Once you have eclipse installed and running you are ready to start a new project. Click on the "Workspace" button to get started.
Right click in the tab labeled "Package" and select:
New>Java Project
Name your project whatever you want, in this case I will call it NRSDK_test.
Make a new .java file by right clicking on the 'src' directory:
New>Class Enter a name for the class ( i will be using Main) Enter a package (I will be using 'test') Hit 'Finish' when your done
Adding the NRSDK
Manual Install of NRSDK jar
Now you want to add the NRSDK jar to your project
- Add a new folder to your project called 'lib' (the name is not actually important, but it is convention)
- Right click on the project
- Select New>Folder
- Place it in the root of the project (Just select the project, not a sub-folder)
- Copy the NRSDK .jar file into that folder. (I am not using a specific file name, as that will change with new releases)
- Locate the jar file from System Setup
- Drag it from the un-ziped folder into lib folder in the eclipse Package browser
Now right click on your project and select 'Properties'. Select Java Build Path and go to the Libraries tab. Click the 'Add JARs...' button.
Select the .jar file you added to your project. The NRSDK should now show up in the 'Referenced Libraries' section of the project.
The last step is to go in to 'Properties' again.
- Go to the 'Order and Export' tab.
- Select the jar file
- Click the up button so that it is above JRE System Library
This will avoid any conflicts with previous versions of the NRSDK.
Testing the NRSDK
Now that we have the NRSDK set up, just make a call to it to make sure our build is ok.
package test;
import com.neuronrobotics.sdk.common.SDKInfo;
public class Main {
public static void main(String[] args) {
System.out.println(SDKInfo.MAJOR_VERSION);
System.out.println(SDKInfo.MINOR_VERSION);
}
}
When run, this should print out:
0 3
then exit.
Testing the DyIO
Now lets add some code to run the NRSDK to talk to a DyIO:
package test;
import com.neuronrobotics.sdk.dyio.DyIO;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
public class Main {
public static void main(String[] args) {
DyIO dyio=new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)){
System.exit(2);
}
System.out.println("Everything is OK!");
dyio.disconnect();
System.exit(0);
}
}
Should show us:
The warning from RXTX can be safely ignored. It is an issue with java rxtxSerial, a library we use underneith the NRSDK for talking to serial ports.
The SerialConnectionDialog is the dialog box that pops up asking you to select a serial port. It will list any serial ports on the system. When you select a serial port it will verify that there is a bowler compliant device on the other end. If there is no response, or an invalid response it will return to this dialog. Note that getBowlerDevice is a blocking function and will not return until the user makes a choice. It will only return true if it found a bowler device.
Errors
DyIO Connection Problems
When writing code with the NRSDK, you need to be aware that the back end is a multi-threaded application. If your application crashes (un-handled exception or error) then the back end will continue to run. This can cause the serial port to stay bound by java, preventing the dyio from functioning properly until that application is properly stopped. If you experience connection problems, make sure all instances of the NRSDK are stopped (if your using eclipse, restart it, un-plug the USB cable, then plug it back in). To prevent this problem make sure that any time the dyio is connected, that before the applacation naturally ends to call:
dyio.disconnect(); System.exit(0);







