Notebook 02

# Lab Notebook

Date: 09/02 2012
Group members participating: Falk, Jeppe and Jakob
Duration of activity: 4 hours

## Goal

The goal of this lab session is to get familiar an experiment with an I2C sensor, namely the ultrasonic sensor.

## Plan

• Explore the reading from the ultrasonic sensor using SonicSensorTest.java to determine under which circumstances the readings are most accurate and when it is not.
• Run and analyse the Tracker.java to see how the ultrasonic sensor can be used to control a robot.
• Using the setup from Philippe Hurbain, implement a leJOS wall follower.

## Results

### Test of the Ultrasonic Sensor

With the sensor mounted, and running the SonicSensorTest.java the measurements are done indoor and on a flat surface with no obstructions.

#### Distance

The distance measurements was done with a 15x30 cm plastic plate.
Distance is measured in centimeters from the front of the sensor.

Distance Value
0 255
0.3 5
5 5
10 14
15 18
20 23
30 32
40 43
50 50
175 176
225 (max) 226

Looking at the table, we note the following things which are important for using the ultrasonic sensor

• If the sensor is completely blocked, it can not read the ultra sonic waves and so it returns 255 (no echo).
• The lowest measurement is 5 cm, and from a few millimeters to 5 cm, the return value is 5 for a steady (non-moving) target.
• For a distance below 50 cm we get slightly bigger numbers than the actual distance
• The sensor does not react to objects before they are only 225 cm from the sensor, which is a bit shorter than the theoretical distance of 254 cm.

#### Cone

Based on the readings from the Lego mindstorms ground plane, the cone is 22.5 degrees from the middle to the left and the right (45 degrees in total).
Making the robot lie on its side to measure the vertical angles of the cone, the readings result in the same values.
Holding a pen a few millimeters from each of the 'eyes' the left eye gives the value 255 and the right eye give the value 5. Concluding from this, the left eye must be the sensor and the right eye the sender.

#### Objects

Trying to read the distance to a round transparent plastic bottle, the readings are a bit weird.
Trying to read different kinds of water bottles, the values seems to be a bit off. At distance 17 the values fluctuates between 17 and 24,
Moving the object a bit more to the left (from the sensor's view) the measurements becomes a lot more accurate. This is the case not only with round objects, but with all smaller objects, that the most accurate results are obtained when the object is in the center of the view of the sensor, or slightly to the left of the center.

#### Time limit

If there is no object within the theoretical max range (254cm), the reading should time out.
The time limit for the measurements is the time it takes for the sound wave to travel the maximum distance back and forth.

(1)
\begin{align} \text{Time limit} = 2\cdot \frac{\text{distance}}{\text{speed of sound}} = 2\cdot \frac{2.54\text{m}}{340.29 \tfrac{\text{m}}{\text{sec}}} \approx 0.015\text{s} = 15\text{ms} \end{align}

Since no object (probable) will travel faster than the speed of sound, the frequency of readings ensures that the sensor will know the object is closing.

### Tracker Beam

Using the Tracker.java (that uses the Car.java) the car drives forward until it measures an object within the desired distance (default 35cm), and then it oscillates around that value driving forward and backwards never stopping, not even if actually measured 35cm.

#### Change of Constants

• If the minimum speed (minPower) is increased the robot oscillates more.
• The gain is the importance of the distance (power = gain*error). If the gain is increased the robot brakes faster when the distance get smaller.
• The desired distance is obvious and there is no need to test this.

The control of the Tracker.java is a closed loop control seeing that it get feedback all the time. It uses proportional control for the setting of the speed.

#### Differential Control

Adding differential control to adjust the speed the robot reduced the size of the oscillations.
There were some problems with getting the speed from the motor, seeing that the API seems to be out of date.

### Wall Follower

Building a wall follower inspired by Philippe Hurbain. The robot has limited flat surfaces and therefore the mounting of a 45 degrees sensor can be a bit difficult.

The WallFollower.java is not too complicated however Philippe Hurbain has very different values for the distances.

## Conclusion

The running of the SonicSensorTest.java and the related results reveals the limits of the ultrasonic sensor regarding distance and the cone/vision. It also showed that the sensor had misreadings when an object was not centered in front of the sensor.
The Tracker.java works very well, and the implementation of the WallFollower.java is not too difficult once the problems of attaching the sensor in a 45 degree angle is overcome.
All in all both the limitations and how to control the robot from the input of the ultrasonic sensor is shown in the above.