CS 153: Project 8

Title image Fall 2018

Project 9: Dancing Robot

The purpose of this project is to continue to practice creating, editing, and using classes. The application for the project will be to get your robot moving, and to use a sensor within its control loop.


Tasks

    Setup

  1. Reconnect your Accel/Mag sensor and get your ACSensor_p8.h and ACSensor_p8.cpp files. You should probably rename them as ACSensor_p9.h and ACSensor_p9.cpp. If you want, copy over your LEDBank_p8.h and LEDBank_p8.cpp files as well, renaming them for project 9.
  2. Part 1: Open Loop Control

    The purpose of this section is to figure out how to get your robot to move straight, move the proper distance, and turn the proposer distance. To do this, you will have the robot repeatedly execute an action, but with different control parameters, and then measure the results.

  3. Write a program that uses the DualMotor class to make the robot repeat a two step process: (1) move forward for a certain amount of time, (2) stop for 10s. Have the robot repeat the process 10 times. When you run it, when the robot stops, record its distance from the start position, then pick up the robot and put it back in its start position. If 10s is not enough time, extend it until you can do this easily. Have the robot start by running the motors for 400us. Each time through the loop, increment the time the motors are running by by 200ms, so the final time through the loop the motors should run for 2400us (2.4s).
  4. Find a measuring tape or ruler to measure the distance the robot travels for each amount of time when you run your program. Then use Google Sheets or your favorite linear regression program to get a linear fit that relates distance-traveled (x-axis) to time (y-axis). Implement ths function in your forward function so that when the user inputs a distance it knows how long to delay while the motors are on. Double check that it works.
  5. Do the same process for turn left and for turn right. There is a large protractor in the lab you can use for measuring angles, or you can just divide up a circle into equal size slices and approximate. Find the function that relates angle to delay time.
  6. Have your robot execute a series of turns and forward motion. For fun, combine it with flashing lights and make it do a little dance. Hand in a recording of your robot executing the program.
  7. Part 2: Closed Loop Control

    The magnetic sensor tells you the absolute orientation of the robot relative to true north. That means you can execute a turn of a certain angle by doing the following.

    • Store the current orientation of the robot.
    • Calculate the desired orientation of the robot given the angle (or use the given orientation).
    • Compute the error between them, make sure the error is between -PI and PI or -180 and 180.
    • Figure out whether to turn right or left (depends on the sign of the error)
    • Make the control signal being sent to the appropriate motore proportional to the error.
    • When the error is small enoug, stop.

  8. Write a new function for your DualMotor class that takes in an orientation and the address of an ACSensor object. Implement the above algorithm so that it aligns the robot to the desired orientation. Test this function.
  9. Create new versions of left and right that take in the address of an ACSensor object, calculate the desired orientation of the robot, and then use the orient function to make it turn appropriately.
  10. Take a video of your robot working and include it in your wiki or handin folder.

Follow-up Questions


Extensions


Report

Each week you will write a brief report about your project. In general, your intended audience for your write-up is your peers not in the class. From week to week you can assume your audience has read your prior reports. Your wiki report should explain to friends what you accomplished in this project and to give them a sense of how you did it.

Your project report should contain the following elements.

  1. Abstract: a brief summary (200 words or less) of the task, in your own words. give the reader context and identify the key purpose(s) of the project. You can assume the reader has read your prior assignments.

    Writing an effective abstract is an important skill. Consider the following questions while writing it.

    • Does it describe the CS concepts of the project (e.g. writing loops and conditionals)?
    • Does it describe the specific project application (e.g. creating applications with the LCD)?
    • Does it describe your the solution or how it was developed (e.g. what code did you write/circuits did you build)?
    • Does it describe the results or outputs (e.g. did your code and circuit work as expected)?
    • Is it concise?
    • Are all of the terms well-defined?
    • Does it read logically and in the proper order?

  2. A description of your solution to the tasks. This should be a description of the form and functionality of your final code and the design of your breadboard circuits. Try to describe your algorithm or code without including actual code in your report. Using 1-2 lines as an example is acceptable. Using simple diagrams or pictures of your board may be helpful when describing your circuits. Note any unique computational solutions or hardware circuits you developed.
  3. A description of any extensions you undertook, including images, videos, or diagrams demonstrating those extensions. If you added any functions, or other design components, note their structure and the algorithms you used.
  4. The answers to any follow-up questions.
  5. A brief description (1-3 sentences) of what you learned.
  6. A list of people you worked with, including TAs, and professors. Include in that list anyone whose code you may have seen, such as those of friends who have taken the course in a previous semester.
  7. Don't forget to label your writeup so that it is easy for others to find. For this lab, use cs153f18project8

Handin

Mount the Courses volume. Navigate to the Private sub-directory. Create a new folder called project01. (It's best to avoid spces in the directory name.) Each week, the following items should be submitted here.

Your report should be submitted as a wiki page with the appropriate label, as noted above.