Download presentation
Presentation is loading. Please wait.
1
Programming – Using a Range Finder
Intro to Robotics
2
Ultrasonic Rangefinder
The Ultrasonic Rangefinder measures distances using sound. It sends out a pulse of sound, then waits to hear the sound’s echo off of a solid object in the environment. By measuring how long it takes for the sound to bounce back, the sensor can calculate the distance that the sound must have traveled, and hence, how far away the object was that reflected it back.
3
Ultrasonic Rangefinder
The Ultrasonic Rangefinder will work in a very similar way to the Encoder program you wrote in the previous section, but instead of measuring the distance that the wheel has turned, it will use the Ultrasonic Rangefinder to measure the distance to the nearest object in front of the arm. Add an Ultrasonic Rangefinder to the front of the robot’s arm. The design shown below will be used as the reference for the remainder of the unit.
4
Create a New Program
5
Range Finder Setup
6
Range Finder Setup
7
Range Finder Code
8
Modifying the WHILE loop
9
Test the code
10
Setup the encoders
11
Save your program as SONAR CODE
Save your program as SONAR CODE. COPY and PASTE your Movestraight () function and place it at the beginning of your code. Save.
12
Cut-off Values
13
Thresholds
14
Thresholds The threshold sets the point at which the robot’s behavior will change, because it marks the point at which the (condition) in the while loop (or if-statement) will change from true to false, or false to true, and thus change which lines of code will run. The robot is now set and ready to run for any object the Ultrasonic Rangefinder might see… but what happens when it doesn’t see anything at all?
15
Using the Debugger
16
Using the Debugger
17
Using the Debugger
18
Testing the sonar reading
19
Using the program
20
Using the program
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.