tirsdag den 15. september 2009

Lab session 2


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

Please check out
our video:


The main goal was to investigate the ultra sonic sensor from the Lego NXT kit.

Sub goals

Update the robot with the ultra sonic sensor, so it becomes similar with Ref1.

The software class “SonicSensorTest.java” should be uploaded to the robot and different sample intervals should be tested. Furthermore, the precession of the ultra sonic sensor must be tested in order to evaluate the credibility of the sensor measurement.

When the basic functionality is evaluated two more complex classes are uploaded to the robot. The classes “Tracker.java” and “Car.java” implements an active regulator, which tracks a certain position and regulates the actual position.


· Construct a robot with one ultra sonic sensor and two independent motors with build-in rotation sensors.

· Upload the java program from Ref2

· Measure distances from the wall manually and compare it with the ultra sonic measurement

· Evaluate the measurement accuracy and performance of the robot with different sample intervals

· Upload the java program from Ref3

· Evaluate the performance of the regulator by changing the important parameters.

· Make a wall follower program, which enables the robot drive parallel with a wall.


Description of experiment

Four kinds of experiments: Distance measurement experiment, ultra sonic sample interval experiment, Wall tracker experiment, Wall follower experiment. The first two experiments are handled in the subparagraph “Measurements”. The final two experiments are dealt with in the following subparagraph “Programming attempts”.

Programming attempts

Two wall follower methods were investigated during this lab session and are explained in the following subparagraphs.

Wall follower 0.1

Philippe Hurbain’s WallFollowe

r application is based on a “bang-bang” regulator with six thresholds values (one of the thresholds is not even used). The distance estimation starts with rough determination of the new direction for the robot by using one of the thresholds values. The determination will end up in one of the following cases:

· Very close (turn in place)

· Close enough (turn)

· A bit too close (shallow turn)

· If small variation turn (avoids turning too short on salient angles)

· A bit too far (shallow turn)

Philippe Hurbain’s WallFollower application assumes that all states for the embedded system are known. The deterministic behavior of the code results in bad driving skills.

The code is not well structured and therefore it might be complicated to update or change the code for alternative use.

Philippe Hurbain’s WallFollower application is not implemented but replaced with proportional regulator code. The proportional regulator can easily be updated to PID regulator if needed.

Wall follower 0.2

The code beneath shows how simple a wall follower can be made by using a p-regulator.

error = distance - desiredDistance;

power = (int)(gain * error);

Car.backward(minPower+offSet-power, minPower+power);

The offset is used to make the motors as identical as possible. A video showing the execution of the code is also uploaded.


Distance measurement

Several distance measurement were made and is presented in Table 1.

Manual measurement (cm]

Ultra sonic measurement [cm]















Table 1 – Distance measurements

The table is made to investigate precession of the ultra sonic sensor.

Sample interval observation

The optimal simple interval for the ultra sonic sensor can be easily calculated by calculating the maximum traveltime.

Equation 1

Equation 1 shows the simple linear relationship between time and distance. Figure 1 shows the tracking result for 255cm. The optimal sample time is therefore two times the X-value. The optimal sample time is therefore 15ms.

Figure 1 - Linear tracking

Pictures of Lego model

Figure 2 - Picture of robot

Problems encountered



This lab session concludes the need for real life measurements and careful selecting regulation method, by evaluating the complexity of the specific task. The PID regulator from Ref4 could be implemented to optimize the solution. The result would be more effective and more precise. The ‘I’ part would ensure that the robot would move more straight and the ‘D’ part would make the regulator faster if the correct ‘D’ gain is found trough experiments. It was prioritized to work more thorough with simpler issues and only read and understand the theory behind a more complex implementation.


Ref 1: Mindstorms education 9797 (add-on: page 28-30)

Ref2: http://www.legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson2.dir/SonicSensorTest.java

Ref3: http://www.legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson2.dir/Tracker.java and http://www.legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson2.dir/Car.java

Ref4: Chapter 5, pp. 179-190 of Fred G. Martin, Robotic Explorations: A Hands-on Introduction to Engineering

Ingen kommentarer:

Send en kommentar

Faste læsere