NXT-Spy – Pause button working :)

After 4 hours of testing, and of horrible-to-debug network channel dealdlocks, I have finally managed to create my pause button that allow us to restart the experiment by only restarting the PC client.

I did that because I had troubles to close my net channels on the phone and so every time I wanted to try my new control algorithm, I had to restart the robot and restart two times the phone!

This step will be crucial for all the upcoming in-deep developpment of the control algorithm because now, the phone and the robot won’t have to be restarted any more. The two devices will stay in stand-by mode every time I press the pause button allowing me to change my algorithm and re-launch the PC client without having to touch to the phone or to the robot.

Supervisor’s comment:

You should have had a better network diagram to start with!!!
Even so this is a real achievement because stopping part of a distributed network to then resume having changed one part and then restarting that asynchronously is really hard – well done.
The justification is absolutely correct and the fact that you built pause before attempting the actual control alogorithm is so much more impressive; showing great forethought!!
He informed me that he has an algorithm working but it required better isolation of ball colours and signs.  The obvious thing would be a sheet, probably white which has walls to reduce the interference from other objects in the environment.
Over the holidays he intends to build the arm that ‘captures’ the balls but it is a holiday so he may be unable due to external circumstances!!

NXT-Spy – Stop button, architecture diagram revised and first ball following algorithm

A lot of quality work this week:
– First, because I was fed up having to close the application on the three devices every times I wanted to restart the experiment, I decided to add a “stop” button that spreads a “stop” message to the two remote devices (phone and robot) and that has for effect to stop the application running on these devices automatically.
– Then, I removed the “start the server” button on the phone because it was not very useful anymore: the server can start automatically, when we start the phone’s application
– I finally revised the architecture of the program running on the PC:
* first of all, I have shrunk all the flag processing processes to one process, indeed, there is no point analyzing the same image with the same algorithm and the same parameters two times. So instead, I added three outputs to the new flag processing process (one for each flag : red, blue and home).
* I have also removed the multiplexer: It was here to avoid processing images we didn’t needed, but it is just too complicated to manage and the three image processing processes are not that heavy to run. It also simplified a lot the diagram by removing the potential deadlock that we could see in the first architecture.

During this week, I have also started writing the state based “artificial intelligence” that will drive the robot. I have only written the ball following algorithm so far, it is still not perfect but I already have got some interesting results…

Supervisor’s comment:

This is a much improved architecture that follows client server principles more closely.  It makes good sense.
Pleased to see that you are already starting to find and seek a ball.
During the week we discussed how he might “capture” a ball so that it can be moved around more easily.  This will have to wait until Christmas when he returns home and has his full Lego kit available to play with.
More coding is the name of the game to play next week.

NXT-Spy – First diagram for the robot control algorithm

Here is the first diagram I have done to describe how the AI that will drive the robot will work.

By doing this diagram, I have also thought about a solution for a problem highlighted by Kevin, my second marker:
How to avoid the robot from chasing the balls it has already sorted from the balls that still needs to be sorted.
The solution I have found is to create a third flag that we will call “home” flag that will be placed at the robot’s starting position. Thanks to this flag, the robot will be able to go back to its initial position every time it has sorted a ball.

Supervisor’s comment:

The plan is very sensible and is realistic with respect to what has been done and what needs to be done.
The control algorithm also seems to capture what needs to be done.  I like the idea of the Home base and the way in which it can resolve problems with previously sorted balls.
I think a continuous 5 degree turn in one direction might be better replaced by a wiggle and this could provide a comparison of techniques which could be measured in the evaluation.
User interface to remember the hue and Saturation and Intensity intervals for the different object, balls and flags has been constructed and is really cool.  It has taken a lot of work because such interfaces always do!  The fact that it is a JCSP-awt application is even nicer!!  It might be worth a little aside in the report on this aspect  He also wrote an active swing slider control!!!

NXT-Spy – Testing the QR code (flag) processing

For the QR code processing, I implemented the XZing library quite quickly thanks to the documentation of it. And I printed the QR codes for the letters B and R in full size on two A4 sheets.

At first, I didn’t have really good results : the barcode were decoded only when the camera was at a distance of 0.5m and with a good luminosity.

After some thought, I realized that the very low resolution I used so far was probably not big enough to allow ZXing to decode the complex QR code precisely.

So I almost doubled it to 320 x 240 and got way better results : QR codes are now decoded from as far as 1.5m and with and angle of something like 30 degrees with the flag. Obviously, I have a lower frame-rate, but it is still acceptable as long as we are working in optimal conditions (a powerful Linksys router with no encryption key).

Supervisor’s comment:

I am impressed that you are able to read the ‘flags’ from such a distance as 1.5 m and also from an acute angle.
Its now a case of getting all the bits and pieces to talk to each other in a coherent manner that allows the balls to be sorted!
Next week is the review with Kevin, so remember to bring i  the robot and show him those buts that already work and those bits that are still under development.