| CSC 161 | Grinnell College | Fall, 2011 |
| Imperative Problem Solving and Data Structures | ||
The goal of this lab is to practice using the Scribbler 2 motion commands, while increasing proficiency with loops and conditionals.
Before beginning the following exercises, move to the labs folder used for
this class and create a file called loops-motion-lab.c for
this lab. Also, remember to set the forwardness in every program with
motion using the command
rSetForwardnessTxt("fluke-forward");
Often, you will want to write programs that have the Scribbler 2
move for varying amounts of time. In loops-motion-lab.c,
write commands that perform the following actions.
Spirals begin from a center point, with the line moving in a circular motion, with a gradually greater distance from the origin. There are two straightforward ways, each using only one loop, that moves the Scribbler 2 in a spiral motion for at least ten seconds.
Hint: use rMove(double translate, double
rotate).
The Scribbler 2 robot has many capabilities; so far, you have been introduced to motion and sound. In this exercise, you will try to get the robot to move while beeping. Pseudocode is provided for each exercise.
Pseudocode:
connect to the robot
move forward for one second
beep for one second
disconnect from the robot
Pseudocode:
connect to the robot
beep for one second
move forward for one second
disconnect from the robot
Pseudocode:
connect to the robot
move forward
stop
beep for one second
disconnect from the robot
Hint: use a continuous command such as rMotors
or rMove.
Pseudocode:
connect to the robot
move forward
beep for one second
stop
disconnect from the robot
You now know how to make the robot beep while moving. You also learned in a previous lab how to use a loop to make rising pitches. Now, you will combine the two actions. Write a program that moves the Scribbler 2 while it beeps fifteen times in a row, with every beep rising in pitch, then stops the Scribbler 2.
When you have finished this lab, be sure to fill out its evaluation form in the "Lab Evaluation" section for CSC 161 on Pioneer Web
This document is available on the World Wide Web as
http://www.walker.cs.grinnell.edu/modules/module-cond-loops-testing/motion-loops-lab.shtml
|
created 21 July 2011 by April O'Neill last full revision 29 July 2011 by April O'Neill minor editing 24 August 2011 by Henry M. Walker |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |