2009-08-26

Logo

Today we created a simple logo for the project.

Landscape


Download as:
PNG
EPS
SVG

Portrait


Download as:
PNG
EPS
SVG


What do you think?

2009-08-21

Improved scanner

Except that we had a lot of problems with the USB communication today (which turned out to be due to a driver error) we improved our scanner a lot. Today we used te OpticalDistanceSensor instead of the UltrasonicSensor and it turned out that OpticalDistanceSensor had much better accuracy when you get the distance in an angle. It seems to be like the optical solution is much better then the ultrasonic one.

Anyhow, this is what the test looked like:





Comparison

Comparison between the old sensor and the new one:

OLD (Ultrasonic)




NEW (Optical)





As you can see the new one looks a lot more like the environment the scanner is standing in. The odd lines in th corners are there because there is space between our boxes and the sensor recognizes them. Though there is still more to improve.

We also tested the new Accelerometer/Tiltsensor.


No big test yet, just printing out all info on the display to se that it works.

Enough for today.
/Peter and Josef

First official project lesson in school

Today is our first offical school lesson for our project. We've received information about how we are supposed to work and what the result is supposed to be. We will soon meet our mentor and discuss our plans.

Later this afternoon we will test a new navigator class and a new Accelerometer/Tiltsensor that we've bought. We will also try to create a simple prototype for our product. With the sensors and robot we have and the new navigation class we're working on we should be able to create something that can follow a wall and map out its' contours without too much trouble.

2009-07-26

First test of the new sensors

So we finally decided to buy the sensors I told you about a couple of weeks ago.
We bought this from Mindsensors.com:
* High Precision Long Range Infrared distance sensor for NXT (DIST-Nx-Long-v2)
* Multi-Sensitivity Acceleration Sensor v3 for NXT - (ACCL-Nx-v3)
And this from HiTechnic.com:
* NXT Compass Sensor
* NXT Extended Connector Cable Set



And now they've finally arrived to Sweden :)
I've been able to test the Compass and the distance sensor so far, Josef still got the Acceleration Sensor at home and we will test it together when we meet in a couple of weeks.

Anyhow they look really good :) The accuracy of the distance sensor is very high, it gives you the distance in mm and it works good!



I put together a simple bot to test out the CompassNavigatorin LeJos.



We will do some more advanced stuff soon!

2009-06-30

Useful sensors

This weekend I read the book Develop LeJOS Programs Step by Step by Juan Antonio Breña Moral. It was really good with alot of nice examples of how to do LeJOS stuff. It also included some information not directly connected to LeJOs, like Lego Mindstorms history for example, but this was really entertaining to read.



Anyhow the book included some useful links and one of the brought me to the company Mindsensors. I found a really nice sensor that could improve this project alot. The High Precision Long Range Infrared distance sensor for NXT (DIST-Nx-Long-v2) would allow us to calculate distances between 20 to 150 cm in millimeters!! Thats 10 times better than with the Ultrasonicsensor that only gives us the distance in cm.



I also read that the CompassNavigator in leJOS may take advantage of the compass sensor from HiTechnic. This would be really nice to have because (as i've understood it) the turns won't depend on the tachometer in the motor, instead it will look at the angle the compass returns i.e. it will rotate until it has rotated as much as needed.


2009-06-21

Going the Right Way

Now we've finally begun to build something that with a bit of imagination remotely resembles our ultimate goal. UltrasonicScanner is a stationary robot which is much like the UltrasonicTest, but now we've integrated communication between the computer and the NXT through Bluetooth and we can let the computer do all the calculation and show the results graphically.

UltrasonicScaner
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/UltrasonicScannerClient/src
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/UltrasonicScannerServer/src



The code is more or less CommunicationTest combined with UltrasonicTest. We've established streaming of both the ultrasonic sensor getDistance() and motor getTachoCount() (which returns the angle from it's original position) and then perform all the necessary calculations serverside. We also have a third "channel" streaming data to allow us to give commands in both directions. This means that both the NXT and the JAVA application have the ability to close both programs.

private Point getScreenPos(int Distance, int Angle) {
Angle += 90;
int x, y;
int distx, disty;

distx = (int) (((Math.min(ULTRASONIC_SENSOR_MAX_DISTANCE, Distance) / (double) ULTRASONIC_SENSOR_MAX_DISTANCE) * (getWidth() / 2)));
disty = (int) ((Math.min(ULTRASONIC_SENSOR_MAX_DISTANCE, Distance) / (double) ULTRASONIC_SENSOR_MAX_DISTANCE) * getHeight());
x = (int) ((distx * Math.cos((Angle) * Math.PI / 180)) + (getWidth() / 2));
x = getWidth() + (x * -1);
y = (int) (-1 * (disty * Math.sin(Angle * Math.PI / 180)) + getHeight());

return new Point(x, y);
}


This is the algorithm we use to calculate the coordinates on the screen based on the data from the NXT, and it's all straightforward mathematics.






As you can see on these pictures the "map" the robot managed to create isn't totally accurate. Apparently the sensor can't give accurate data when facing at an angle to a flat surface, with the result that flat surfaces seems to be curved around the robot. Once we have the robot mobile a lot of this problem should be solved.

If check out our videos you can also see a version before we implemented Bluetooth for it.

This is the final result:

It's working!


It's astonishing how much you can manage to do in just one day of coding. Or astonishing how long time coding takes, depending on how you look upon it. In one day we've started to familiarize ourselves with the NXT and we've created all kinds of smaller test programs, all of which you can find on our Google Code page.


HelloWorld
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/HelloWorld/src

The first basic program to show that the NXT and leJOS works properly. The same program that every programmer has done at least once during his early career. What it does is to simply write a String on our NXT's screen. The leJOS code for writing on the screen of the NXT is:
LCD.drawString("String",x,y);

UltrasonicTest
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/UltrasonicScannerClient/src
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/UltrasonicScannerServer/src

In this project with its very intuitive name we started playing with the Ultrasonic Sensor. This works like a sonar; it sends out ultrasonic sound and measures the time to the echo. To use the sensor you simply declare the sensor, which then has a number of predetermined methods. Note that you have to specify the port he sensor is located in as well.
UltrasonicSensor sensor = new UltrasonicSensor(SensorPort.S1);
int distance = sensor.getDistance();
LCD.drawInt (distance , 1, 1);



These lines will cause the sensor to measure the distance ahead of it and write out the distance in centimeters on the display.

We used this to create a program that measures the distance in a 180 degrees radius and then write it out on the LCD screen. Here we also used a motor to rotate the ultrasonic sensor. The motors also have a set of predetermined methods, but you don't have to declare them.

class HeadRotator extends Thread {
@Override
public void run() {
Motor.A.setSpeed(40);
while (!this.isInterrupted()) {
Motor.A.rotateTo(-100, true);
Sound.beep();
while (Motor.A.getTachoCount() >= -90 && !this.isInterrupted()) {
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
}
Sound.beep();
Motor.A.rotateTo(100, true);
while (Motor.A.getTachoCount() <= 90 && !this.isInterrupted()) { } try { Thread.sleep(200); } catch (InterruptedException e) { } Sound.beep(); } } }


This loop makes the sensor rotate back and forth in a 180 degree arc. In a separate thread we continuously gather data which we then translate into coordinates on the LCD and write it out.

We noted that the sensor isn't very accurate when facing at an angle to a flat surfaces, and when the sensor sweeped over a flat surface the surface would appear curved on the screen. This is something we'll have to take into consideration later on. Also, we noticed the limits of the NXT' computing capacity, as it didn't quite manage to keep up with the data income. Though the most difficult part for it was to manage to write all the data to the LCD fast enough, so the screen flickered.


CommunicationTest
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/CommunicationTestClient/src
http://code.google.com/p/penemunxt/source/browse/#svn/trunk/CommunicationTestServer/src

To solve the problem with the NXT's limited computing capacity we wanted to be able to run most of the computation on a server, in this case a computer. Also we want to be able to show the results on a real screen instead of the very limited LCD of the NXT. Thus, we had to establish a communication link.

The first comm test was just a simple app sending the data from a touch sensor to the computer through USB. When the touchsensor was pressed the computer app should exit. leJOS included some really great examples for rthis so it wasn't that hard to establish the first connection.

We extended the data transfer so that it also transmitted the data from the soundsensor aswell as the ultrasonicsensor in real time. The PC recieved the data and painted it to an applet as a graph. The PC also always sends back a status code telling the NXT if the status is OK or not, if it's not OK everything should shut down.

Then it wasn't that hard to switch to Bluetooth mode instead. The use the same connector but with different protocols:

USB:NXTConnector conn = new NXTConnector();
conn.connectTo("usb://")

Bluetooth:NXTConnector conn = new NXTConnector();
conn.connectTo("btspp://")

Though there are better ways to implement it which we will test later on. Anyhow we missed one important thing in the beginning, we forgot to add the reference to the BT package bluecove.jar. It took us at least one hour to figure out that this was the missing part.

Video of the CommunicationTest:


Summary
So what we've learned so far will be really important. Now we will use our know knowledge in BT communication and ultrasonic data to build a simple bot that rotates, collects US data and sends it to the computer to display it.

Stay tuned!!
/Peter And Josef

Links
http://lejos.sourceforge.net/nxt/nxj/api/index.html leJOS NXT API
http://lejos.sourceforge.net/nxt/pc/api/index.html leJOS PC API
http://lejos.sourceforge.net/nxt/nxj/tutorial/Communications/Communications.htm leJOS Communication Tutorial