LESSON 3: OBSTACLE AVOIDANCE
In this unit you will:
- Understand the purpose of software libraries (you’ve already been using them)
- Learn about using servo motors and how they work
- Learn about ultrasonic sensors and how they work
- Write a program to create an obstacle-avoiding robot
Write a blog post about your project and what you have learned.
There are many complete ultra-sonic sensor obstacle avoiding programs in the public domain. Don’t just copy and implement. It is important that your program demonstrates what you have learned so far, with your code well commented. Even if it doesn’t work perfectly, show what you have learned.
PART 1: LEARNING ABOUT SOFTWARE LIBRARIES
Like other programs you have created, this program requires the use of a library. A software library generally consists of pre-written code, classes, procedures, scripts, configuration data and more. Typically, a developer might manually add a software library to a program to achieve more functionality or to automate a process without writing code for it. (Technopedia)
The Arduino IDE has several libraries preinstalled. You can read documentation on Arduino libraries, or look specifically at the Servo libraries, which we will be using. Click through each of the 6 functions that are part of the Servo library so you know how to use the servo class methods.
PART 2: SERVO MOTORS AND HOW THEY WORK
On the robot, the servo will be used to adjust the direction of the ultrasonic range finder. The servo can rotate in a 180 degree range. You will need to calibrate your servo to make sure that the range finder is able to be positions between far left and far right. Use the following programs to help understand how servos work and calibrate your servo. You will ultimately need to understand the servo function in order to create your obstacle avoidance routine.
PART 3: ULTRASONIC SENSORS AND HOW THEY WORK
The ultrasonic sensor uses sonic ranging to detect objects and measure the distance to them. To do this, it bounces sound pulses off of objects and records the time it takes for those sound pulses to return to the sensor. This time measurement along with knowing the speed of sound can be used to calculate distances.
Use the basic ultrasonic program below to test your sensor and understand how it works. The program utilizes functions() with return values (i.e. functions() that are not type void).
PART 4: OBSTACLE AVOIDANCE
The goal here is to develop a program that utilizes the servo, ultrasonic range finder and steering to avoid obstacles.
Step 1: Develop an algorithm. This will be in pseudocode format or a flowchart of the necessary steps to detect and avoid obstacles automatically. You can start with your robot moving forward in a straight line and encountering an obstacle (e.g. a box or a doorway). The algorithm should navigate past the obstacle and continue in a straight line after.
Step 2: Convert your pseudocode into actual code
Step 3: Set up an obstacle and video your robot successfully navigating around
BLOG POST #11: ULTRASONIC SENSOR/SERVO MOTOR
Provide the following information in your post:
About your project
- Include a video of your robot avoiding an obstacle.
- Write about what you learned about software libraries, servo motors, and ultrasonic sensors.
- What library was used in your program and how does it work? Be specific.
- Explain how the servo motor and the programming for the motor works. Use examples from a program you worked with by also commenting on the code.
- Explain how the ultrasonic sensor and the programming for the sensor work. Use examples from a program you worked with by also commenting on the code.
- What challenges did you encounter even if you were not able to overcome them?