fredag den 4. september 2009

Lab session 1


04092009

Attendees: Jesper Jakobsen, Mads Hansen Lund og Michael Nygaard Pedersen

This lab session was the first for the group ”LegoCarsten”. This lab session was used to adresse and solve practical issues and obtain a basic understanding of the hardware and software.

Goal

The main goal is to make a NXT robot, which should be able to track and follow a black line without any human assistance.

Sub goals

A PC should interface the NXT control unit via USB and Bluetooth.

A robot should be constructed, which can be programmed in the Eclipse environment by adding the leJOS library. The robot should be controlled by the NXT control unit by adding the necessary sensors and motors.

The introduction for this session is found on the course homepage Ref1.

Plan

· Investigate the needs for software download and install the components.

· Establish connection to the NXT control unit and upload leJOS firmware to the flash memory.

· Construct a robot with one light sensor and two independent motors with build-in rotation sensors (Ref 2).

· Download the java program from Ref1

· Measure light sensor levels in order to optimize code performance

· Evaluate the final performance of the robot

Results

There are of cause relatively few results in this lab session because it is the first one of its kind.

Description of experiment

Several experiments were made to check the credibility of the line follower class.

Line tracking

The robot should be able to follow the black line on the track. If the robot fails the threshold value from the software should be changed. The code line beneath shows how the threshold value is defined.

final int blackWhiteThreshold = 45;

No adjustment were made afterwards because the robot just fulfilled the task perfectly.

Light reflection measurement

In case the software should be optimized it could be useful with additional measurements, which can indicate the reflection value for different colors. When the program is running, the reflection percentage is printed on the LCD.

LCD.drawString("to start", 0, 3);

while (! Button.LEFT.isPressed()){

LCD.drawInt(light.readValue(), 3, 9, 0);

}

These values where noted in order to determine limits or threshold values for the lights sensor.

The same experiment was performed with only ambient light available. The LED was turned off by setting the Boolean to FALSE.

light.setFloodlight(FALSE);

The results for measurement experiments are presented in the “Measurement” chapter.

Sample interval experiment

Three additional sample delays are tested to understand importance for the right sample interval. The tested sample intervals are: 10ms(default), 100ms, 500ms and 1000ms. The sample interval is changed in the code line beneath.

while (! Button.ESCAPE.isPressed()){


Thread.sleep(10);

}

It is important to change the value within the program while loop and not the sleep parameter outside.

The results for measurement experiments are presented in the “Measurement” chapter.

String function experiment

A test was made to investigate the effect of the variable declaration on the memory usage. The condition beneath was made to update the minimum of free memory and the condition was changed to “<” to observe the maximum of free memory.

CurrentMem = Runtime.getRuntime().freeMemory();

if (freeMem > CurrentMem) {

freeMem = CurrentMem;

}

LCD.drawString("Memory "+freeMem, 0, 4);

The string content of “left” was changed, and the content was placed directly in LCD.drawstring().

// On black, turn left

LCD.drawString(left, 0, 1);

MotorPort.B.controlMotor(power, forward);

MotorPort.C.controlMotor(0,stop);

Maximum free memory without variables: 56796

Minimum free memory without variables: 48

Maximum free memory with variables: 56700

Minimum free memory with variables: 44

Programming attempts

The two attempts are already explained. There is no need for further explanation because of the simplicity. All the attempts are made with a-so-called “bang-bang” regulator.

Measurements

This chapter contains measurement data from lab session 1.

Light measurement

The following measurements are made with the line follower software, which prints a percentage of the reflected light.

Color

Percentage with LED [%]

Percentage without LED [%]

Black

35 ±1

26 ±2

White

62 ±1

44 ±2

Blue

47 ±2

35 ±3

Green

41 ±3

32 ±5

Yellow

61 ±3

47 ±4

Orange

55 ±2

47 ±3

Red

52 ±2

43 ±3

Table 1 - Light sensor measurements

Based on the measurements in Table 1 it can be concluded, that it is almost impossible to detect colors with the light sensor. But it is possible to determine whether the color is bright or not.

Sample interval observation

The following observations are based on four different sample intervals to estimate the perfect interval to obtain both speed and precision.

10ms(default)

It moves relatively slow, but follows the line closely.

100ms

It moves faster compared to the original setup, but it looks less smooth during the run.

500ms

The robot detects the line from time to time, but it cannot follow the line for a longer period. The sample interval is impropriet for this assignment.

1000ms

The robot cannot follow the line. The robot drives around in circles and might be lucky to detect something, but it cannot follow the line.

Pictures of Lego model








Figure 1 - Picture of robot

Problems encountered

We had several problems with installing the leJOS software because of software version conflict. Most of the first lab session was used to establish contact to robot.

Conclusion

It is possible to build a line follower with only light sensor and “bang-bang” regulator. It should be noticed that the sample interval is very important in order to make the robot follow the line. In order to make the robot follow the line, the line and track color should have a large contrast relationship. The robot can interpret the difference. The robot has only one light sensor, because the robot has to toggle between the line and the surface to determine if it is on track or not. This control pattern makes the robot less smooth during the run, which makes the robot slow.

References

Ref1 http://legolab.daimi.au.dk/DigitalControl.dir/NXT/Lesson1.dir/Lesson.html
Ref2
Mindstorms education 9797

Ingen kommentarer:

Send en kommentar

Faste læsere