Upload
anson-chan
View
213
Download
0
Embed Size (px)
Citation preview
Oakville Robotics Symposium – The Light Sensor 22-Oct-20112
Introduction – Richard McMullin
› Leader in IT• Engineer, University of Waterloo – Systems Design• Technical Leader at National Bank of Canada• Changing hearts and minds to improve effectiveness of over 300 people
› Entrepreneur • Started several technology companies• Finance, Medicine
› FLL Coach• 4th year coaching FLL• Tournaments: Toronto West, Provincial Championships
› FRC Volunteer• Tournament setup• Field Referee
Oakville Robotics Symposium – The Light Sensor 22-Oct-20113
Agenda
1. Attaching the light sensor(s) a. Placement on the Robot b. Attaching to the ports (default port 3)
2. Testing the light sensora. Built-in program on the robot
3. Controlling the light sensora. Programming blocks that use the light sensorb. Stopping on a line – Program
4. Walking a linea. Left right methodb. Program
5. Tracking a linea. Line tracking methodb. Program
6. Questions
Oakville Robotics Symposium – The Light Sensor 22-Oct-20114
Attaching the light sensor
› Light Sensor Placement on the Robot• Facing down towards the mat• Better if forward of the wheels (for steering)• Allow a gap for the light to be reflected (not touching the mat)• Place somewhere stable (consistent readings)• Place somewhere protected (avoids contact and external light sources)
› Attaching to the Ports• Default port is port 3.• Any port can be used, but always check that the program is set for the correct port.
Oakville Robotics Symposium – The Light Sensor 22-Oct-20115
Testing the light sensor
› Built in testing• Programs exist on the Robot to test the attached light sensor• But they just make sounds
› Here is a program to show the light sensor value
White value = 60
Black value = 34
• Branch on a light sensor
• Loop until a light sensor value
Oakville Robotics Symposium – The Light Sensor 22-Oct-20116
Controlling the light sensor
› Programming blocks that use the light sensor
• Read the light sensor
• Wait for a light sensor value
Oakville Robotics Symposium – The Light Sensor 22-Oct-20117
Program Example – stopping on a line
› Steps in the program• Go forward forever• Wait until the line is detected• Stop
Oakville Robotics Symposium – The Light Sensor 22-Oct-20118
Program Example – Walk a line
› Steps in the program• If the sensor senses white, steer to the right• If the sensor senses black, steer to the left
› Bounded unstable program
Oakville Robotics Symposium – The Light Sensor 22-Oct-20119
Advanced – Track a line
› General idea• Track along the ‘grey’ value between black and white. • Use the difference between the current value and the ideal ‘grey’ value to tell the robot how
hard to turn.• The more ‘white’ the value is, the harder you steer to the left• The more ‘black’ the value is, the harder you steer to the right.
› Math• Assume the following values:• Black: 36, White 60.• Ideal ‘grey’ value is (60+36)/2 = 48
• In order to find out the amount to steer, take the current sensor value and subtract it from the ideal ‘grey’ value.
• Steering value = 48 – sensor value• Max white steering = 48 – 60 = - 12 (left turn)• Max black steering = 48 – 36 = + 12 (right turn) • Grey steering = 48 – 48 = 0 (go straight)
Oakville Robotics Symposium – The Light Sensor 22-Oct-201110
Advanced – Track a line
› The simple program
Read the light sensor
Subtract from 48
Use the result to set the steering
Oakville Robotics Symposium – The Light Sensor 22-Oct-201111
Program Example – Track a Line
› Use additional math blocks to set the sensitivity of the turning. • Whole number math only available with multiplication and division• In order to multiply by .75, multiply by 3 then divide the result by 4.• Always do the multiplication first to keep the highest accuracy• Use a second light sensor to stop the walk along the line
These blocks adjust the turning sensitivity
Use a second light sensor to break the loop
Oakville Robotics Symposium – The Light Sensor 22-Oct-201112
Questions
› Contact Info:
› Richard McMullin› [email protected]