Installing and using the Java Robot API




What is the API?


The robot API is a set of java files that allow you to easily program the ER1 robots in Java. The robot API comes in a few parts, but only two really important parts. The Robot.java file defines a class called Robot. This Robot object allows you to interact with the robot in a number of different ways. In addition the API comes with the AdvancedRobot.java file which defines a class called AdvancedRobot that has a bit more functionality than Robot, but usually isn't needed.


  • How do I get the API?
  • How do I use the RobotAPI?
  • Nick broke the API, now what?
  • What if I don't use Eclipse?





  • How do I get the API?

    The easiest way to get the API (or at least, the way I'm going to show you) is to download it with Eclipse. The API is stored in the robot directory and can be retreived using CVS (concurrent vision systems, a useful tool, but it's not important you know much about it.) To check out the API follow the following steps.



    First, open up Eclipse (you don't need to create a new project, just open Eclipse) and choose File/Import.



    Next, choose "Checkout Project From CVS."



    Next, it's time to fill out some fun information. Make sure to fill it out as follows...
    Host: dmx.cs.colostate.edu
    Repository Path: /s/bach/a/class/cs495/CVS/
    User: Your username
    Password: Your password
    Connection Type: extssh
    Use Default Port: Use Default Port
    Save Password: NO, do not choose save password!
    Then click next.



    Almost done, the next screen looks pretty boring, but it's not. Choose "Use an existing module" and some stuff will happen. You may get some messages about hostkeys, choose ok and yes to get past these. Hopefully, a few choices will appear below. You want to choose RobotAPI and then choose Finish



    That should be all you need to do. It should create a project named RobotAPI with a number of packages. There may be some errors in it, but don't worry about these. The important thing is to include the proper classes in all your programs. If you create a new project for your own code (recommended) then you'll also need to add the RobotAPI project to your projects buildpath. To do this, right click your project and choose properties.



    Choose "Java Build Path" on the left menu, and after that, choose the "Projects" tab. Then choose "Add" on the right.



    Now go ahead and check "RobotAPI" and then click "OK"



    This allows the RobotAPI project's source code to be used by your project's source code. All you need to remember now is to include the line "import robot.*;" at the top of your Java files that use the RobotAPI.

    Actually, that above statement is a lie. You will also need to make sure that your project is set up to use Java 5. In order to do this, you'll want to right click your project and choose properties (like you would do to add the robot project to your build path (see above)). Now you'll want to click the "Java Compiler" tab and make sure that the compiler compliance level is 5.0






    How do i use the RobotAPI?


    The RobotAPI is actually easier to use than you might think. In fact, the best way to get started using it is to just mess around with it. Follow this link for a simple Java program that uses the RobotAPI. The RobotAPI itself is well-documented, so also, don't be afraid to go into the source code and look around.






    Nick broke the API, now what?


    CVS allows us to modify and change the RobotAPI as necessary, and it's possible that someone may make a change that breaks the API (if so, it's probably Nick), in this case, you can always get a stable version of the API by jumping through a few more hoops. In the instructions for checking out the API (Above.) there is a step where you choose RobotAPI and then click finish. (This step.) However, instead of clicking finish, click next. This will take you to a screen that talks about how you want to check the project out, just click next, the defaults are fine. This will take you to another screen that talks about the same stuff (the title is "Check Out As") again, just click next, the defaults are fine. Now you'll get to a screen that talks about "Head, Branches, Version, and Dates", this is what we want. If you click the arrow next to versions you should see 1 or more version names. The verions with the word "Stable" in them are versions Weston hasn't broke yet. Choose one of these (the latest if there's multiple versions listed) and then click finish.



    This will check out the latest stable version to you, these stable versions should work regardless of what changes are being made.






    What if I don't use Eclipse?


    From the linux machines, you can still easily access the RobotAPI project files using CVS from the command line. There's plenty of documentation available online, and the man page is more than verbose. However, to just grab the files you can type the command cvs -d /s/chopin/f/proj/robot/CVS/ checkout RobotAPI