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.
- 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.
- 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).
- 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.
- 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.
- 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.
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.
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.
- What is your name?
- What is your quest?
- What is your favorite color?
- What is your favorite Monty Python Movie?
- Make your robot fancier.
- Add LEDs that reflect the robot's actions.
- Add other sensors to your robot and show it reacting to them.
- Add capabliities to your robot.
- Just as we could record LED commands, record the robot commands for later replay.
- Set up some type of user input, such as a switch or a button.
- Add more commands, like jiggle, or spin
- Make another constructor for the DualMotor class that takes in a string like "2 3 4 5 6" and uses the string to initialize the pins array and nPins fields. Look up the strsep function.
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.
- 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?
- 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.
- 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.
- The answers to any follow-up questions.
- A brief description (1-3 sentences) of what you learned.
- 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.
- Don't forget to label your writeup so that it is easy for others to find. For this lab, use cs153f18project9
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.
- Code that should graded and any required supporting materials. This week, submit your code from all of the project tasks. Code from lab exercises will generally not be graded unless it is used as part of the project tasks (e.g. the DualMotor class).
- Videos of your work. You can also submit videos as part of your report on the wiki, but please put a copy of the video here.
Your report should be submitted as a wiki page with the appropriate label, as noted above.