Lesson 2 description
Date: 9 september 2010
Duration of activity: 14.15 - 18
Group members participating: Nikki & Knud
GOALS for lesson 2
- Investigate the ultrasonic sensor and use it to make a wall follower program
Subgoals:
1. Test of the Ultrasonic Sensor
2. Test of Tracker Beam
3. Test of Wall Follower
Plan for achieving the goals
1.
The sensor will be mounted on LEGO 9797 car, and then tested with SonicSensorTest.java
- We will then make a table with columns [type of object] [measured distance] [real distance].
- We will try with different sample intervals as well
- We will try to measure the theoretically maximum measuring distance which is 254 cm to see if the sensor actually can measure such a distance under any conditions
- We will consider the implications of how the speed of sound limit usage of the sensor
Theoretic consideration for the sensor and the sample time
S=V*t <=> t = S/V
S =2.54 m
V =340,62 m/sec
t = 7,46 ms
total time = 14.92 ms
This means that with the default sample time of 300ms we have around 285ms of doing nothing
The implications is that our sample time cannot be shorter than 14.92ms (plus some ms for the a/d conversion and sensor to calculate the distance), as the sensor is limited by the speed of sound. To overcome this limit, we could use a sensor based on radio wave reflections, thus we are limited by the amazing speed of light.
2.
To test the tracker beam we will try the Tracker.java program and describe the behaviour of the car controlled by the program and experiments with changing the different constants in the program. And also consider what type of control system it is when the power to the car motors is the controlled variable and the distance is the measured variable?
Link to code:
http://www.legolab.daimi.au.dk/DigitalControl.dir/NXT/Lesson2.dir/Tracker.java
http://www.legolab.daimi.au.dk/DigitalControl.dir/NXT/src/Car.java
3.
We will try to use Philippe Hurbains program to make the Lego 9797 follow a wall
Results
1.
Lowering the sample interval isn't of interest here, its more of interest when having a moving robot that has to respond fast to different readings/obstacles.
2.
Tracker.java test program test:
From looking in the code its show that its measures the distance and calculates an error value from a predetermined distance. It drives either forward or backwards, determined by the error value. If the error is bigger than zero it drives forwards and if the error is less than zero it drives backwards. We confirmed this in practice.
The system responds to feedback so its a feedback control system. It multiplies the error with a gain value and uses this as power, thereby making it a P (proportional) closed loop regulator.
3.
Wall follower:
We converted Philippe Hurbains program to Java. We had some trouble calibrating the distance thresholds and angling the ultrasonic sensor correctly. It kept coming too close to the wall. In the end we succeeded, though it did not move smoothly..
The reason it did not move smoothly is because of abrupt turning.
It moves and turns by having 4 states for the right motor and 3 states for the left motor. The 4 states are:
- Reverse motor (only the right motor)
- Stop motor
- Medium power to motor
- Full power to motor
These states make it possible to drive forward and turn at 3 different speeds to the right and turn 2 different speeds to the left.
An alternative way to create the wall follower could have been to take the Tracker.java code and modify it so that not only drives forward and backward, but turns left or right according to the error. Since that code calculates the error more fluently and is a better estimate of making a closed loop P-regulator this could have resulted in less oscillating behaviour and more fluently turns. A PID-regulator would of course be even better.
Source code:
http://www.liscom.dk/lego/lab2Wallfollower/Lab2WallFollower.java
Ingen kommentarer:
Send en kommentar