lørdag den 7. november 2009

Lab Session 8

Attendees: Jesper Jakobsen, Mads Hansen Lund and Michael Nygaard Pedersen
Work time: 9.15 - 13.35

The theory behind artificial intelligence is inspired from “primitive” animals. The increasing levels of abilities require different amounts of intelligence and are handled in asynchronous modules with additional prioritization. Modules of higher prioritization will suppress modules of lower prioritization. Example: An animal gets interrupted in the eating process because a dangerous situation suddenly occurs. The module of the animal’s brain, which handles danger, will suppress the module, which controls the eating process.

What if an animal is to choose between two identical opportunities?Example: A dog is put between two eating toasts; the eating toasts are exact identical. Because the attractiveness from each eating toasts is the same, the dog will be unable to decide and die of hunger. The modules of intelligence have been developed by thinking of the process of evolution.

Goal

Rodney A. Brooks’ article “A Robust Layered Control System for a Mobile Robot” presents an idea to program animal like creatures based on observations in biological world. The principle of the modules is formed to a description of layers. Each layer consists of sequence functions as presented in Figure 1. Rodney A. Brooks’ article describes the modules running on separate computational machines . Note: The already given java code from lab session 8 makes use of multi threads instead of separate computational machines.





Figure 1: An illustration of the module function sequence

Figure 2 illustrates modules shared into levels that run “concurrent”. A higher level suppresses a lower level and so on. The hierarchic level control offers the possibility for a similar developing process as the biology evolution. The developing process starts from the state of “reptilian brain” as level 0 and then more intelligent parts are added as needs arises. In Lab session 8 the “reptilian brain” level is described as random drive. To avoid a crash an “evolutionary”/developing process leads to the next level. A valuable observation in this developing process is that a layer of highest priority can exclude lower levels by suppressing them infinitely.






Figure 2:An illustration of the hierarchy programming architecture of level control

Sub goals

The Lab session is shared into two exercises.

1. Make an observation of developed multi threaded control handed out by Ole Caprani. The layers is presented in Figure 3.

2. Implement an additional layer to follow a light source (based on lab session 7). The priority of new integrated layer has to be carefully evaluated according to theory from coherent lecture.




Figure 3: Shows how levels are shared out the lowest level starts from the bottom.

Plan

· Build a NXT robot with two light sensors and ultra sonic sensor.

· Analysis the software for lab session 8

· Evaluate the performance of the software for lab session 8

· Extend the abilities of the NXT robot with the software from lab session 7

· Evaluate the performance of the new software

Results

Description of experiment

Software explanations

Why a daemon thread?

The main difference between user threads and daemon threads is that the JVM will only shut down a program when all user threads have terminated. Daemon threads are terminated by the JVM when there are no longer any user threads running, including the main thread of execution. A daemon thread is a thread with no other purpose than to serve other processes.

What is a super class?

In computer science a super class is the mother class form which other classes are derived. The classes that are derived from a super class are known as sub classes. A super class allows for a generic interface to specialized functions through the use of virtual functions. This could be interface to the NXT motors or LCD.


Programming attempts

Two attempts were completed to evaluate the suppress mechanism, where the performance for both is observed and explained in the following subparagraphs.

Basic program observations

The SoundCar program has three different behavior objects implemented;

  • RandomDrive – Makes the car drive randomly around.
  • AvoidFront – Makes the car trying to avoid obstacles.
  • PlaySounds – Plays a sound every 10th seconds.

The software required for the SoundCar to run as intended was loaded into the Lego NXT car (build as described on page 30 in the Lego building instruction booklet) and the behavior of the vehicle was observed;

  • The SoundCar starts out by driving randomly around for a while. Every time it detects an obstacle in the way, the car backs off a bit and turns to the left (i.e. the “random driving” is suppressed ).
  • Every 10 seconds a short melody line is played. When playing the melody line, the car stands still and waits for the melody to finish (i.e. “random driving” and “avoid obstacles” are suppressed).
  • The only external event capable of triggering the car to respond is objects detected by the ultrasonic sensor (which triggers the avoiding behavior).
  • In the LCD is simply output, which of the threads are active and which are suppressed.

The three threads RandomDrive, AvoidFront andPlaySounds are “concurrent” with different priorities;

  • PlaySounds – highest priority; suppresses AvoidFront and RandomDrive.
  • AvoidFront – second highest priority; suppresses RandomDrive.
  • RandomDrive – lowest priority; suppresses nothing.

Thread triggering conditions;

  • PlaySounds is triggered ever time a 10.000mS delay has elapsed.
  • AvoidFront is triggered by an external event (an obstacle) has been detected.
  • RandomDrive is triggered/running all the time if not suppressed by another thread.

Extended program observations

The basic program was extended with the Braitenburg behavior from lab session 7. The approach was simply to evaluate the complexity of the Braitenburg class and compare it with the abilities from the basic program.

Random drive is the most primitive because it is interpreted as careless wandering with no purpose.

To avoid an object in front of the robot can be interpreted as “avoid danger”. The light following ability is then interpreted as ability to find food. The ability is prioritized above the careless wandering but beneath the ability to avoid danger.

rd = new RandomDrive("Drive",1, null);

bb = new Braitenberg("Search light",2,rd);

af = new AvoidFront ("Avoid",3,bb);

ps = new PlaySounds ("Play ",4,af);

When the light following ability was added the random drive was constantly suppressed because “food” / light always are present (graphical presentation in Figure 4).






Figure 4: Shows how levels are shared out the lowest level starts from the bottom.

This could be accepted as natural consequence or the code could be changed, so both abilities are executed at some time.

One method is to run the light following class X times and then make the class unusable for some time.

public Braitenberg(String name, int LCDrow, Behavior b) {

………

public void run(){

while (rumtimes <>

{ ………

……

An alternative solution could be to evaluate the light conditions. If the general light amount is too low, then do not search for it. Analogy: is there is very little food present do not bother to find.

public Braitenberg(String name, int LCDrow, Behavior b) {

………

public void run(){

while ((ls1.getNormalizedLightValue() >thresholdLight ||ls2.getNormalizedLightValue() >thresholdLight))

{ ……………

Pictures of Lego model









Figure 5 - Picture of robot

Conclusion

If the structure becomes too complex, the suppress pattern might need more inputs, than just a predefined prioritized action model. This is because a basic ability might always be suppressed this primitive behavior. This could be intentionally as a consequence of evolution or unwanted because the robot then is unable to fulfill a specific task. A human being can no longer breath under water because of evolution has made it meaningless.

References

Ref 1 A robust layered control system for a mobile robot, IEEE Journal of Robotics and Automation, RA-2(1), p. 0

Ref2 A robust layered control system for a mobile robot, IEEE Journal of Robotics and Automation, RA-2(1), p. 1

Ref3 A robust layered control system for a mobile robot, IEEE Journal of Robotics and Automation, RA-2(1), p. 7

fredag den 30. oktober 2009

Lab session 7

Attendees: Jesper Jakobsen and Michael Nygaard Pedersen

Work time: 9.0o - 13.00

Goal

The goal is to create and investigate simple Braitenberg creatures.

Sub goals

To program three different types of Braitenberg creatures and investigates the behavior of its own and among other Braitenberg creatures.

Plan

· Build a basic robot with the properties of the Braitenberg creature (2a and 2b from Ref1)

· Program and test a light following Braitenberg creature

· Evaluate a light avoiding Braitenberg creature

· Compare direct control form and comparator control form.

· Evaluate and implement light measurement filter.

Results


Description of experiment

Ref2

Programming attempts

Four different approaches where either fully implemented or investigated during this lab session.

Direct control

The direct control works in almost the same way as the filtered implementation, which is presented in the next subparagraph and dealt with in detail.

Filtered direct control

The Braitenberg vehicles are constructed as shown in Ref1. It basically consists of two light sensors and two motors.

The values read by the light sensors are fed directly to two motors, respectively, as shown in Ref1. Vehicle 2a avoids the light while Vehicle 2b searches the light. To change the functionality of one vehicle to the other, the light sensor/motor connections are simply swapped.

The “estimate” value is set to 50 as default and offset is 250 - Both values are based on experiments. The “light searcher” essentially works as follows:

public void searchLight() {

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

normVal1 = ls1.getNormalizedLightValue();

normVal2 = ls2.getNormalizedLightValue();

// Filter algorithm

estimate1 = estimate1 + (filterKoef*(normVal1 - estimate1));

estimate2 = estimate2 + (filterKoef*(normVal2 - estimate2));

normVal1 = (int)estimate1;

normVal2 = (int)estimate2;

// Range algorithm - Not used in this implementation

calibrateSensor(normVal1); calibrateSensor(normVal2);

// Search algorithm.

leftMotor.controlMotor(normVal1-offset,forward);

rightMotor.controlMotor(normVal2-offset,forward);

}

}

The light sensor values are read, filtered and normalized to comply with the .controlMotor method. The filter “smoothes” the operation of the vehicle by slowly integrating weighed changes in light intensity.

Differential control

Another way of optimizing the behavior is to make the light measurement depended of one another. By subtracting the two measured values, the ambient light level is less important, when the speed is determined. The direction is determined by the polarization of the subtraction and the turning and drive speed can be calculated based on the difference.

Filtered direct control in two threads

To make the Braitenburg creature even more real, the two inputs with the belonging output was tried implemented in two different threads (two brain halves controlling each side). The idea was to take implemented filter control and put half of the functionality into one class and the other half into another. The main class should then extend threads and each class should then run independently in two threads. The final implementation was not made, because of the used time.

Problems encountered

When the Braitenberg creature was tried implemented in threads there was several compiler errors and they were not resolved within the lab session.

Conclusion

The NXT behavior was never tested among other NXTs, because only few NXTs where actual working. The designed robot was borrowed from another group because LegeCarstens’ group member with access to the robot never showed up. The written software worked perfectly on the other robot.

References

Ref 1: Notes on construction of Braitenberg's Vehicles, Chapter 1-5 of Braitenbergs book

Ref2: Introduction to Machina Speculatrix and Braitenberg Vehicles

lørdag den 10. oktober 2009

Lab session 6

08102009

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

Goal

In this lab session we will try to make a car that drive as fast as possible following the Alishan train track. The Alishan train track has been used at a robot competition called World Robot Olympiad in 2007 (Ref 1).

Sub goals

To evaluate the sub goals a detailed analysis of the track is made.

Track analysis

Figure 1 shows the track with all the issues needed to be resolved. All the state identifiers are unique for this lab session and might be used more than once, but will always refer to the same state.












Figure 1 - Alishan train track top view

1: The robot should drive forward in the beginning and activate line following sequence, when at least two sensors detect a white surface.

2: The robot should be orientated on the right side of the line in the first straight line.











Figure 2 - Follow simple line

3: When the center sensor and sensor on the inside of the corner reads a black value the robot is set in reverse and will now detect and drive more careful.











Figure 3 - Detect sharp corner

4: When the sharp corner functionality has been executed the standard line following code is activated again. But the line orientation should be shifted after X seconds and the sharp corner functionality is also inverted.



















Figure 4 - Change side to keep orientation on the left side for the next corner

5: If all sensors detect black a 180 degree turn should be performed after X seconds and both the line orientation and sharp corner functionality must be reversed yet again after X seconds of blind mode to ignore the big black line across the track. Then the program is just executed like from the bottom and up.






Figure 5 - Wait and turn 180 and evaluate that track is half finished

When all three sensors detect green for the second time the program is stopped and total time is logged.

Plan

To sum up a self explaining pseudo flowchart for the main algorithm is presented in Figure 6.













Figure 6 - Pseudo flowchart

The plan is to implement this general Alishan train track algorithm and apply some or all the necessary exception states to complete at least one half of the track.

Results

Description of robot

The racing vehicle utilizes three RCX light sensors located in front of the steering wheels to gather information about the racing track in advance. The three light sensors are fixed in position with respect to each other but can move up and down in order to keep the same distance to the surface. This done with an assistant ''distance wheel'' which insures that the light sensors always are kept in a constant distance from the track (see Figure 7).














Figure 7 - Picture of robot

The picture to the right in figure 7 shows a logged time for a run on the track in milliseconds.

Software description

Folowing flow chart diagrams and related text should be read together with the uploaded code (REF3).

The concept for the software is based on the linefollower from Lab Sesion 1 (REF2). The linefolower has been modified for the Alishan train track. The main differences are illustrated in Figure 8 where the program has a optional line side orientation.










Figure 8: Flow chart for the main concept.

The 90 degrees corners requiere an more aggresive turn, which is peformed with a reverse motor drives and slower speed illustrated in Figure 9.







Figure 9: Flow chart of the two turning modes (the hard turn is activated by a 90 degrees corner).

When the robot encounters a 90 degrees corner it passes the corner by failure, but registers that an error has been made. To get back on track the robot move slightly backwards and proceed with a more gentle tracking method and more aggressive handling.









Figure 10: Flowchart illustrates that the robot reverse back to find the line again when it arrives at a 90 degrees corner.

Problems encountered

At first the light sensors were located too close to the steering wheels which made the vehicle unable to react to changes in the racing track.

The line follower uses a bang-bang control algorithm, which at first made the vehicle sway relative violently from side to side.

The biggest problem was to make it through the 90° corners. When encountering a corner the line follower algorithm would cause the vehicle to race off track.

The final algorithm used causes the vehicle to be relatively slow since it needs to slow down to manage the 90° corners.

When encountering the black line separating the last slope and the highest plateau, the vehicle sometimes think it has encountered a corner and starts moving backwards.

The battery needs a fair amount of charge to be to drive uphill.

Conclusion

The robot did not reach the final destination, but all the principles from the track analysis has been investigated and proven to work. The robot is very slow but works very well uphill, which is the only functionality fully implemented. This video shows the robot in action:

References

Ref 1 http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson6.dir/Lesson.html

REF2 http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson1.dir/Lesson.html

REF3 http://legocarsten.blogspot.com/2009/10/code-from-lab-session-6.html

Faste læsere