Skip to content.

Sections
Personal tools
You are here: Home Assignments Assignment 4
Document Actions

Assignment 4

by Max Chang last modified 2007-02-06 10:34 AM

Meet in CSB 101.

Sensor Stats

due Sunday February 11

Preparation

  • Read the NQC tutorial at http://www.cogsci.ucsd.edu/Plone/classes/WI07/COGS008/read/overmars99-nqc-tutorial.pdf
  • For the first part of the asssignment, you must know how to make the robot drive forward and backward, as well as stop. Being able to adjust the power of the motor will also be helpful in Part Two.
  • In part two, you must know how to create and use a datalog (see page 38 in the tutorial), access sensor readings, and use conditionals.

Part One

Test your robot, communicate with it, write a simple program to control it, calibrate the motors.

  1. Check out your robot from your TA in CSB 101, the robot lab.

  2. Communicate with your robot.

    1. Connect an IR tower to the keyboard of a Macintosh machine, and launch MacNQC.
    2. Set your robot in front of the IR tower and turn it on. It is best to have the tower face away from the center of the room to avoid interfering with the robots being used by other teams.
  3. Calibrate the rotation sensor.

    For this step, you will write, download, and run an NQC program that will drive your robot straight ahead about 3 feet. You should have read the NQC tutorial before attempting this step.

    You will need to estimate the distance covered in a particular amount of wait time after the motors have been turned on. This may require some experimentation with the robot.

    1. Using what you have learned from experimentation, write the program.
    2. Compile and download your program into the robot.
    3. Reset the rotation sensors and place your robot on the table.
    4. Mark the starting point with a sticky note.
    5. Press the Run button to run your program.
    6. Mark the ending point.
    7. Record the value of each of the rotation sensors (using the View button on the top of the RCX unit.) Are they the same? What does it mean if they are not?
    8. Measure the distance from the start of the run to the end in inches.
    9. If the sensors do not have the same reading, note which one is larger. Divide the larger sensor reading by the distance covered (as measured in inches). That is the number of rotations per inch. Write this down so you can use this information in the next part of the assignment.
  4. Save this simple program for submission as part of the homework.

Part Two

Add light sensors, write, download and run an NQC program to move the robot while logging data from sensors.

  1. Add light sensors to the robot.

    Place a light sensor at each end of a 1x16 bar centered across the front of the RCX unit. Light sensors should point forward. Connect the rotation sensor with the higher reading (step 4.i. above) to input 1 on the RCX. Connect the left light sensor to input 2, connect the right light sensor to input 3. Record the identification number of each sensor. They come in pairs L<num>A, and L<num>B. You will include this information in the README file submitted with the other components of the assignment.

  2. Write an NQC program that records sensor data.

    To sample the light readings on the table your robot will have to make simple planned movements while logging data from the sensors. Your program will cause the robot to back up the correct distances when placed in the starting locations (approximately 24 inches). While backing up, the robot should log the readings from three sensors (rotation, light_sensor 1, light_sensor2) such that at least 20 samples are taken at even intervals as the robot moves across the table. From each starting position your robot should back up until its wheels are within two inches of the table edge.

    NOTE: we will grade you on how well your robot takes 20 samples. That is to say, your code should take 20 evenly spaced samples, no more, and no less. The closer to 20 you get, and the more robust your algorithim for doing so, the better your grade. We care about the algorithim you use, so don't edit the datalog by hand to be exactly 20 long and expect we will give full credit for that.

  3. Run your program at each of the starting positions. Check that the robot and your program are behaving correctly before you actually make the sensor calibration runs. You should be sure that the data log is being written correctly.

    A lamp should be positioned above the corner of the table so that it shines directly down onto the surface of the table, the disk of the shade is just inside the edges of the 2x4s, and the rim on the shade is the width of your hand above the upper edge of the 2x4s. Be sure the adjustable slider is on full bright.

    Starting positions for the robot are:

    • Offset 0: Front of robot against the long table rail, with the side of the robot within one inch of the short side table rail.
    • Offset 11: Front of robot against the long table rail, side of robot one page length (11 inches) away from side table rail.
    • Offset 22: Front of robot against the long table rail, side of robot two page lengths (22 inches) away from side table rail.

    Coordinate with others working in the room so that you can turn off all of the lights except the lamp in the corner of the table. Upload the data log after each sampling run. Name the files using the following conventions: “DL_<teamname>_<offset>_LLRR”, where offset can be “0”, “11”, or “22”. Note, your team name is <UCID#1>_<UCID#2> (ie jsmith_rbelew).

  4. Make a different run.

    Rewrite your program so that the robot can move along the long side 2x4 rail of the table. It should take at least 40 samples at even intervals as the robot moves from the light to the edge of the table. Upload this data log and save it as “DL_<teamname>_long_LLRR”. As in step 6, we will grade you on how close to 40 samples you get.

  5. At this point you should have logged four tracks. Now, put the left light sensor on the right side and the right light sensor on the left side. Leave the input wiring as it was.

    Repeat the four sampling runs and label the new data logs “DL_<teamname>_<offset>_LRRL”.

Assignment submission details

  1. Place your code for both the simple movement program and the data logging program in a file called SensorBot_<team_name>.nqc (team_name described above).
  2. Write a very brief ASCII text file called README_SensorBot_<team_name>.txt documenting your progress (e.g. describing experiments you did to get the program and the robot working correctly) and anything else you want to communicate about the assignment. Include the identification numbers of your light sensors in the README file.
  3. Combine your datalogs into a single file with each data collection run headed by a text line that matches the naming conventions given above.
  4. Attach all of these files to an Email message sent to cg8w1@icogsci1.ucsd.edu no later than Sunday, February 11 at 11:59 pm.
 

Powered by Plone, the Open Source Content Management System