DOC PREVIEW
Princeton COS 116 - Laboratory 3

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

COS 116 The Computational Universe Laboratory 3: Controlling the Robot Last week you met the Scribbler robot and saw how to use pseudocode to control it. This week, you finally get to be in charge. By applying your knowledge of pseudocode, you’ll explore the robot’s capabilities and use it to investigate physical world phenomena. If you get stuck at any point, feel free discuss with another student or a TA. However, you are not allowed to copy another student’s program or answers. You should hand in your lab report at the beginning of lecture on Tuesday, February 28. Include the following: • Printouts of the 9 numbered programs described below • The 3 pictures that you draw with the Scribbler in Part I • Responses to questions printed in bold (number them by Part/Experiment) You can print your programs directly from Scribbler Control Panel, or copy and paste them into a program like Microsoft Word. (Click “Copy as Text” from the Edit menu.) Part I: Motion by Dead-reckoning You can move the robot along a pre-determined path by specifying the motor speed and duration of each leg of the journey. This kind of navigation is called dead reckoning. The robot’s basic movement commands all work this way (except that the Scribbler uses motor power to approximate speed.) One drawback of dead reckoning is that any error in the measurement of speed or direction accumulates over time, causing the robot’s position to become less and less accurate. In this section you’ll use dead reckoning to make the Scribbler draw some simple figures. You’ll also see how to apply basic geometry to plan the robot’s course. Before you begin, calibrate your robot’s motors to ensure that it can drive straight. Your TA will provide instructions. Experiment 1 — Draw a square Instructions required: Forward, Spin Right, Pause, Do for n times Program the Scribbler to draw a square with sides approximately 4 inches in length. Use trial and error to get the distances and angles right. Use a loop to avoid writing the same instructions four times.Tips for accurate drawing: Tape the paper to your lab table so it doesn’t slip. Always test the robot on the paper, since angles and distances may come out differently on other surfaces. Always insert a 0.2 second pause between motor commands to give the robot time to come to a stop. Experiment 2 — Draw a star Start and end here.36° Instructions required: Forward, Spin Right, Pause, Do for n times Program the Scribbler to draw a five-point “pentagram” star, as show. Again, use a loop to avoid writing the same instructions multiple times. Each vertex has an interior angle of 36°. Use this fact and the time you ran the motors to make a 90° angle in Experiment 1 to estimate how long to run the motors for the angles of the star. To draw more complicated pictures, you’ll need to take advantage of the Scribbler’s Advanced Motor Controls. These allow greater control over the speed of each wheel. Click on the Motor command in Scribbler Control Panel, and check the box next to “Enable Advanced Motor Controls.” Notice the additional sliders that become available. You can use these to set the speed of each motor from 100% (full power, forward) to -100% (full power, reverse). Try clicking each of the Basic Motor Control commands: Forward, Reverse, Left Turn, Right Turn, Left Spin, Right Spin. Note the Advanced Motor Control speed settings corresponding to each basic command. One use of Advanced Motor Controls is to make the Scribbler turn along a path with a specific radius. Suppose you wanted to draw a circle with radius r, as shown at right. If the distance between the robot’s wheel is 2w, then in one full circle the left wheel will travel a dof 2π(r + w), while the right wheel wiltravel a distance of 2π(r – w). Say it takes t seconds to draw the circle. Then: left wheel speed = 2π(r + w) / t, and right yields the proportion: istance l wheel speed = 2π(r – w) / t. This COS 116 – Lab 3 2r Pen radius r - w Right wheel radius r + w Left wheel radiuswrwrspeedleftspeedright+−= Measure w (half the distance between the wheels). Assume the left motor speed is 100% and solve the proportion to find the speed for the other motor that results in a curve with a 6 inch radius. What about a 3 inch radius? A 1 inch radius? Experiment 3 — Draw a circle Instructions required: Advanced motor controls Program the Scribbler to draw a circle with a radius of approximately 5 inches. Use algebra to set the motor powers. Use trial and error to make sure the circle is complete without retracing too much of the line. Your program should use only a single instruction. Part II: Motion with Sensor Feedback Another way to direct a robot’s motion is to use feedback from its sensors. In contrast to dead reckoning, sensor feedback allows the robot to limit the accumulation of positional error by continually updating its knowledge of its environment. In this section you’ll use Scribbler’s obstacle sensor and stall sensor to experiment with feedback-driven motion. Experiment 4 — Avoiding obstacles with the obstacle sensor Instructions required: Forward, Spin Right, Do forever, If Program the Scribbler to move around the room while avoiding obstacles. Whenever an obstacle is detected by the obstacle sensor, change the robot’s direction before proceeding forward. Hint: Move the robot forward for a very short time, check the status of the obstacle sensor, and repeat. As you saw last week, the obstacle sensor will not detect objects at very close range, and it cannot tell exactly how close an obstacle is. These limitations make the obstacle sensor ill-suited for navigating in confined spaces. The stall sensor should be used instead. When the robot is applying power to its motors but they are prevented from turning because the robot it hitting an obstacle, we say the motors have stalled. The stall sensor detects this condition. Up to this point, all the motor instructions you’ve used specify a duration for the movement. They switch the motor on, wait for some period of time, and then switch the motor off. The stall sensor can’t be used with instructions like these, since the motors COS 116 – Lab 3 3aren’t considered to be stalled anymore if they have been turned off. To utilize the stall sensor, you’ll need to control the motors in a different way. Say you


View Full Document

Princeton COS 116 - Laboratory 3

Documents in this Course
Lecture 5

Lecture 5

15 pages

lecture 7

lecture 7

22 pages

Lecture

Lecture

32 pages

Lecture

Lecture

16 pages

Midterm

Midterm

2 pages

Lecture

Lecture

23 pages

Lecture

Lecture

21 pages

Lecture

Lecture

24 pages

Lecture

Lecture

22 pages

Lecture

Lecture

28 pages

Lecture

Lecture

21 pages

Lecture

Lecture

50 pages

Lecture

Lecture

19 pages

Lecture

Lecture

28 pages

Lecture

Lecture

32 pages

Lecture

Lecture

23 pages

Lecture

Lecture

21 pages

Lecture

Lecture

19 pages

Lecture

Lecture

22 pages

Lecture

Lecture

21 pages

Logic

Logic

20 pages

Lab 7

Lab 7

9 pages

Lecture

Lecture

25 pages

Lecture 2

Lecture 2

25 pages

lecture 8

lecture 8

19 pages

Midterm

Midterm

5 pages

Lecture

Lecture

26 pages

Lecture

Lecture

29 pages

Lecture

Lecture

40 pages

Lecture 3

Lecture 3

37 pages

lecture 3

lecture 3

23 pages

lecture 3

lecture 3

20 pages

Lecture

Lecture

21 pages

Lecture

Lecture

24 pages

Lecture

Lecture

19 pages

Load more
Download Laboratory 3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Laboratory 3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Laboratory 3 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?