CSC 126

Create robot

Comments

Using Sonar


Objectives

Tools and Parts Needed



Sonar sensor In this lab, we will be exploring the NXT ultrasonic distance sensor which looks like the image to the right.  

The ultrasonic "sonar" distance sensor detects objects in front of the sensor by emitting a short high-frequency sound and then listening for the echo. If an echo comes back there is an object in front of it. The time it takes for the echo to return can be used to measure the distance to the object. If there is no echo within some time limit the situation is interpreted as no object.   The sensor can read distances between 1 cm and 255 cm, but it is most accurate between 6 to 180 cm.


Your Task

Your task is to create a "sentry robot" which will monitor a doorway by hiding alongside the inside of the doorway.  

Mount Sonar
First, mount your sensor to read in the forward direction.  One way to do this is to use the following parts to mount on the underside of the NXT brick:

parts mount
mount


After mounting your sonar sensor, measure the distance to the other side of the doorway using the sonar sensor.  

Sonar in RoboLab
At this point, you should be fairly adept at finding icons in Robolab and reading the help screens, but let me point out that there are 5 new icons worth reading about.  
Sonar Waitfors are sonar "wait fors" and are located in the "wait for area."  (One of these will be useful for the first part of the task.)
Sonar events are sonar "events" and are located in the "event area." (One of these will be useful for the second part of the task after the intruder has first been detected.)
sonar fill is used to set a container to the value of the sonar distance sensor.  (This is needed to store the distance to where the intruder appeared.)

Sonar Sentry Task
Next design a program to monitor the doorway as follows:

If anything (like a hand) breaks the sonar beam, then the robot should:
Notes if no intruder ever enters the doorway, the robot should obviously not move or sound any alarm.  If when the robot is spinning and sounding the original alarm, if it never detects the intruder in the smaller distance, it should act like one of those annoying car alarms, and just keep going and sounding the alarm.

Next, implement this algorithm in RoboLab:
  1. Be sure to include explanatory comments to your RoboLab code by using the Edit Text icon: edit text icon  In particular, it is required that you add the following comments:
  2. Lab L17
    • All of your team member's names
    • Appropriate comments on the computation of the turn.
    • Comments about what the robot will do if the user enters 0 clicks, 1 click, and more than 8 clicks.
  3. Finally, modify your pseudocode, robot, and RoboLab program to improve your robot's performance. 
  4. Answer the questions in your Lab Report.

Your Lab Report

All lab reports should be self-contained and should contain all of the following information at the top: As usual, for this lab, your team will submit two files: the Lab Report entitled yourusername1-yourusername2-L17 and the RoboLab program entitled yourusername1-yourusername2-L17. For the report, your team should discuss the answers to each of these questions. Using correct spelling and good grammar, this lab should then address the following questions:
  1. Your Pseudocode: Include the final version of your pseudocode in your Lab Report.
  2. Your Robot: Briefly describe which sensors and actuators need to be attached to which ports for your implementation. 
  3. Computation: Explain your distance computation and how you arrived at this algorithm.
  4. Your Success: In a paragraph or so, describe how to use your program and whether or not your robot functions as desired. If not, what goes wrong and under what conditions?
  5. Outreach: In its current state, this lab is probably not ready for our outreach to children.  Brainstorm ideas for improving the robot's behavior for outreach.  Then in your report, expand on the top one or two of these ideas.
  6. Comments and Suggestions: Write a paragraph that summarizes your team's reaction to RoboLab and to this lab. If there are any problems you encountered or any questions that remain, please ask! Also, be sure to include any suggestions you have for how this lab could be improved.
http://faculty.berea.edu/pearcej/CSC126/ | Licensed under a Creative Commons Attribution-Share Alike 3.0 United States License