Monday, January 5, 2009

The GUI is Implemented

The GUI for the Monte Carlo localization is largely implemented. The directory for the files can be found here. The most recently updated files are CommandPanel.java, EventHandler.java, Statistics.java, FileDump.java, ConnectPanel.java, and Localization.java.

I have also added a new class called Robot.java. This class is meant to be run on the NXT brick. Consequently, it should be placed in a separate project, with the project being turned into a Lejos project. I assume here that you are using Eclipse. Link and upload Robot.java to your brick.

To establish the Bluetooth connection, first run Robot.java on the brick. You should hear two beeps, which indicates that the brick is waiting for a Bluetooth connection from the PC.

Next, start Tester.java running. The GUI should open. Recall that the Bluetooth field has been primed with the Bluetooth address of my brick. Your Bluetooth address will be different, and you should enter your brick’s Bluetooth address in the field. Now, press the connect button.

Once the Bluetooth connection is established, you should hear the robot chime, which indicates that it is connected. On the GUI, the connect button should turn red and read disconnect. The status field should read connected. All of the buttons on the GUI should become active.

You can make the robot turn and move using the appropriate buttons and by supplying an angle in degrees or a distance in millimeters, as the case may be. You can request the battery voltage, or manually ping the ultrasonic sensor. After every turn or move, the latest ultrasonic sensor readings should appear on the GUI.

You can dump the statistics of the MCL algorithm into a csv file. However, please note that the file path and file names are hard coded in the Event Handler class. I welcome suggestions on how to make this more flexible.

The Robot class assumes 56 mm diameter wheels with a 121 mm wheel base. The left motor is connected to the C port; the right to the A port. If your robot’s configuration is different than mine, you will have to change the line of code in the Robot class, which instantiates the Pilot class. The Robot class also assumes that the ultrasonic sensor is connected to sensor port S1. Additionally, I assume that the ultrasonic sensor will point directly straight ahead along the robot's line of forward travel. I welcome suggestions on how to make the configuration of the physical parameters more flexible for the user.

Because the MCL algorithm is not yet fully implemented, the particles on the display do not appear to change in response to movements or turns of the robot. This is to be expected. However, if you do want to see the display change, click on the initialize button to restart the MCL algorithm.

To disconnect the PC and the robot, click on the disconnect button, and click on the yes button to confirm. Once the disconnection cycle is complete, the robot should chime. On the GUI, the disconnect button should now read connect in green lettering, and the status field should now read disconnected.

To bring the localization program to an end, click on the close button, and then click on the yes button to confirm.

Happy roboting!

To submit suggestions or report bugs, please email me at adcaine@gmail.com.

Thank you.

No comments: