1 / 241

Project “Georgia Computes!” First Courses Workshop Day 2

Project “Georgia Computes!” First Courses Workshop Day 2. Mark Guzdial College of Computing Georgia Institute of Technology guzdial@cc.gatech.edu http://www.cc.gatech.edu/~mark.guzdial http://www.georgiacomputes.org. Workshop Plan-Day 2.

babu
Download Presentation

Project “Georgia Computes!” First Courses Workshop Day 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project “Georgia Computes!”First Courses WorkshopDay 2 Mark Guzdial College of Computing Georgia Institute of Technology guzdial@cc.gatech.edu http://www.cc.gatech.edu/~mark.guzdial http://www.georgiacomputes.org

  2. Workshop Plan-Day 2 • 9-10:30: Introduction to Computing using Robotics in Python • 10:30-11:30: Tackling a homework assignment in Robotics • Follow the light • 11:30-12:30: Lunch • 12:30-2:30: Introduction to Computing for Engienering using MATLAB • 2:30-2:45: Break • 2:45-4:30: Data Structures in Media Computation using Java • 4:30-5: Wrap-up discussion and evaluation of workshop

  3. CS1 Robotics with Python • Microsoft Research has funded the Institute for Personal Robotics in Education • Tucker Balch, DirectingMonica Sweat, Developing GT’s CS1 • Joint between Bryn Mawr and Georgia Tech • Doug Blank (Developing Myro) • Deepak Kumar (Teaching their first CS1 with robots) • http://www.roboteducation.org

  4. Curriculum Goals • Make entry into computer science more accessible • Revamp CS1 & CS2 curricula • Use personal robots as a “vehicle” • Fresh approach to introducing computing • Influence robot design based on past experience • Influence software development

  5. Pilot CS1 in Spring 2007 • Offered at Bryn Mawr (Deepak Kumar) and GaTech (Monica Sweat) • Use the Parallax Scribbler robot • Wireless bluetooth interface designed by GaTech enables Scribbler interface • Myro software running under Dr. Python (IDE) to control Scribbler • Course will provide additional data on curriculum design

  6. Curriculum Development Strategy • Step One: Figure out something that students will want to do. • Step Two: Teach the CS and Robotics to make that happen. • Goals: • Relevance • Motivation • Context for Transferrable Learning

  7. Example CS1 Exercises: Early • Focus on variables, arguments, functions, giving commands to a computer, sequencing commands • Personalize your robot (use colors, pens, stickers, etc.). Give it a personality, and a specific “move” • Then experiment with difference basic robot movement behaviors (go forward, backward, spin, turn, etc.) and learn how to upload and play a tune. Design a series of steps for your robot to perform a dance while playing a tune. • Test the sensitivity and range of IR sensors for light detection, obstacle detection. The latter will vary depending on the reflectance of the object being sensed... • Put these results in Excel to introduce ideas of computational science: Gathering data from sensors and analyzing it.

  8. Example CS1 Exercises: Later • Iteration • Focus on iterating, sequencing within an iteration, limiting iteration • Experiment with simple behaviors like going forward for a while and then backward. Repeat these behaviors several times. Does the robot track the same space or are the movements shifting its space? A good way to test these would be to insert a pen and let the robot draw its path each time. This will help observe and get used to variations in your robots motor behaviors. • Write a loop to input a sound (could be on laptop instead of robot) then play it back. Do this in a group of robots. Make a sound, allowing the group behavior and dynamics to create a cacophony. • Write programs for the robot to draw a square, a circle, a figure-8, a 5 point star...and other shapes...a spiral?

  9. Example CS1 Exercises: Powerful • Representation and Interpretation • Using some other data structure or sensed data as a command to drive other behavior • Create a file with commands like "left on 30 \n right on 30 \n beep" Write a program to read these commands and execute them – in other words, define a mini robot language and write an interpreter for it. Gives us the opportunity to address string processing, a typical CS1 topic. • Have one robot "call out" audio commands (perhaps specific tones, via the speaker), and have other robots "hear" the commands (via microphones) and execute the commands. • Follow a line of symbols/fiducials, where the symbols (colors or scan codes) can be interpreted as music. Start the robot on the line, and as it encounters the markings, it plays a note. The spacing is the timing of the songs. Put one after another, and they play in a round. Have two go together (on two lines) and they play a harmony. The robot could also write the music with a pen. First robot writes the song, second robot plays it.

  10. Parallax Scribbler Robot • Low cost ($80) and features • 3 photosensors • IR sensors in front • IR on chasis • Servo controlled motors • 3 Programmable LEDs • Speaker • Battery operated (6 AAs) • Serial interface

  11. Assessment Methods • Within term: • Initial, midterm, final surveys. • Focus group or individual student interviews. • Across term: • Tracking – do they stay in CS?How well do they do?

  12. Installing Myro on Windows • Download the latest Myro from http://wiki.roboteducation.org/Windows_Setup • Save it, open it, and expand it. • Double-click on install.bat

  13. Setting up Bluetooth

  14. Testing Myro

  15. Testing the Robot In other words: initialize(“com5”)

  16. Controlling the robot’s motors • Most Myro robot movement functions control the speed (specifically, amount of power) of the motor. • motors(1.0,0.5) # Gives full power to motor Left, # half power to motor Right • forward(1.0) #Both motors, full speed ahead • backward(0.5) #Backwards, half speed • turnLeft (0.1) #Turn left, slowly • turnRight(0.25) # Turn right, slightly more quickly • stop() #STOP EVERYTHING • same as motors(0,0)

  17. Defining a robot function: Yoyo def yoyo(): forward(1) wait(1) # Wait one second backward(1) wait(1) stop() Can just type this in, and then execute it as: yoyo() Or can enter it into a module (filename)

  18. Parameterizing our YoYo def yoyo1(speed): forward(speed) wait(1) # Wait one second backward(speed) wait(1) stop()

  19. Further parameterizing def yoyo2(speed, wait): forward(speed) wait(wait) # Wait a bit backward(speed) wait(wait) stop()

  20. from myro import * initialize(“com5”) def yoyo2(speed, wait): forward(speed) wait(wait) # Wait one second backward(speed) wait(wait) stop() def wiggle(speed,waitTime): rotate(speed) wait(waitTime) rotate(-speed) wait(waitTime) stop() def dance(): while True: yoyo2(1.0,1) wiggle(1.0,0.2) yoyo2(0.5,0.5) wiggle(0.5,0.5) Can do something forever Use Control-C to stop this.

  21. Using the robot as an object Robot can be controlled using global functions,or as methods to robot objects.

  22. Review from myro import * robot = Scribbler(“com4”) robot.turnRight(0.25); wait(0.25); robot.stop() robot.forward(0.25); wait(0.25); robot.stop() def function(): while True:

  23. Reading the Light Sensors robot.getLight(0) robot.getLight(1) robot.getLight(2) >>> robot.getLight() [657, 1453, 1025] Light sensors

  24. Which one is which? • Exercise: Playing blind man’s bluff • 0,1,2: left, right, center? • Do the values go up with darkness or with light?

  25. Modeling Animals • How do animals sense light? • Why do moths move to the light? • How do they know which way to turn to get there? • Does it matter if you see vs. smell? • Let’s model light-seeking behavior

  26. Choosing action depending on senses • New statement: if • Allows us to test conditions (logical expressions) and choose actions based on those conditions. • if (some logical test goes here) : • The actions go on the line below, indented. if robot.getLight(0) > 800: robot.turnLeft(0.25)

  27. Blocks • Just like the lines after def and while, all the lines indented the same after if are part of the same block • A block is defined in Python by indentation. • Lines at the same level of indentation are in the same block. • A block is used to define the body of a function and the loop. • A block is used to define the actions of a successful if test.

  28. Where’s the light? • We can compare against a value, but what we really care about is the relative light values. if robot.getLight(0) > robot.getLight(2): print "LEFT!"

  29. Signaling a Turn def signalingTurn(): left = 0 right = 2 while True: if robot.getLight(left) < robot.getLight(right): print “Left!" if robot.getLight(right) < robot.getLight(left): print "Right!" signalingTurn()

  30. Audibly signaling a turn def signalingTurn(): left = 0 right = 2 while True: if robot.getLight(left) < robot.getLight(right): robot.beep(0.25,400) if robot.getLight(right) < robot.getLight(left): robot.beep(0.25,800) signalingTurn()

  31. Making Music beep(1,400) #Plays at frequency 400 Hz # for 1 second computer.beep(0.5,440) # Has the computer beep at A-above-middle C # (440 Hz) for ½ second Can they play a duet?Try it!

  32. Myro Song Format • Myro has a more music-like format that it supports: s = makeSong(“c 1; d .5; d#4 1/2”) # C in the fifth octave for a whole note # D in the fifth octave for a 1/2 note # D-sharp in fourth octave for a 1/2 note robot.playSong(s,0.75) # Play this for ¾ second

  33. Exercises • Option #1: Follow the Light • Write a function that will turn the robot toward the light, much as an insect might follow the light. • Can you turn based on the amount of light? • Option #2: Make the Robot Dance • Write a program to play music and “dance” your Scribbler • Use beep() and playSong to make music • Use movements like yoyo and wiggle

  34. CS1 for Engineering in MATLAB • Syllabus • Sample lessons on getting started

  35. Syllabus • Getting started with MATLAB • Introduction to Vectors, the main MATLAB data type • Conditionals, iteration, and functions • Cell arrays (mini-databases) • Structures • Problem solving • General arrays • Graphing (MATLAB does professional quality graphics) • Bodies of Rotation and Matrices • File I/O • Multimedia: Image and sound manipulation • Serious CS: Numerical methods, Big O, Sorting, Queues, and Graphs

  36. Objectives – the MATLAB User Interface ■ How to use the Command window to explore single commands interactively and how to recall earlier commands to be repeated or changed ■ Where to examine the variables and files created in MATLAB ■ How to view and edit data tables created in MATLAB ■ How MATLAB presents graphical data in separate windows ■ How to create scripts to solve simple arithmetic problems

  37. The Default Window File menu Close icon Current directory Current directory Command window Workspace window Command history

  38. Array Editor New variable icon

  39. If you don’t have MATLAB, Octave!

  40. 2.4 Scripts Create a script derived from the Pythagorean theorem to compute the hypotenuse of a right triangle: H2 = A2 + B2 where A and B are the sides adjacent to the right angle, and H is the hypotenuse opposite. clear clc A = 3; % the first side of a triangle B = 4; % the second side of a triangle hypSq = A^2 + B^2; % the square of the % hypotenuse H = sqrt(hypSq) % the answer

  41. 2.5 Engineering Example—Spacecraft Launch clear clc cmPerInch = 2.54; % general knowledge inchesPerFt = 12; % general knowledge metersPerCm = 1/100; % general knowledge MetersPerFt = metersPerCm * cmPerInch * inchesPerFt; startFt = 25000; % ft - given startM = startFt * MetersPerFt; g = 9.81; % m/sec^2 top = 100; % km - given s = (top*1000) - startM; % m initial_v = (2*g*s)^0.5 % the final answer

  42. 3.1 Concept: Using Built-in Functions • In this chapter we will see the use of some of the functions built into MATLAB. • At the end of each chapter that uses built-in functions, you will find a summary table listing the function specifications. • For help on a specific function, you can type the following: >> help <function name> • For example: >> help sqrt SQRT Square root. SQRT(X) is the square root of the elements of X. Complex results are produced if X is not positive.

  43. 3.2 Concept: Data Collections This section considers two very common ways to group data: in arrays and in vectors. Data Abstraction allows usto refer to groups of data collectively: • “all the temperature readings for May” or • “all the purchases from Wal-Mart.” We can not only move these items around as a group, but also perform mathematical or logical operations on these groups, e.g.: • compute the average, maximum, or minimum temperatures for a month A Homogeneous Collection is constrained to accept only items of the same data type – in this case, they will all be numbers

  44. 3.3 MATLAB Vectors Individual items in a vector are usually referred to as its elements. Vector elements have two separate and distinct attributes that make them unique in a specific vector: • their numerical value and • their position in that vector. For example, the individual number 66 is the third element in this vector. Its value is 66 and its index is 3. There may be other items in the vector with the value of 66, but no other item will be located in this vector at position 3.

  45. Vector Manipulation We consider the following basic operations on vectors: • Creating a Vector • Determining the size of a Vector • Extracting data from a vector by indexing • Shortening a Vector • Mathematical and logical operations on Vectors

  46. Creating a Vector – Constant Values • Entering the values directly, e.g. A = [2, 5, 7, 1, 3] • Entering the values as a range of numbers e.g., B = 1:3:20 • Using the linspace(...) function e.g. C = linspace (0, 20, 11) • Using the functions zeros(1,n),ones(1,n),rand(1,n) and randn(1,n) to create vectors filled with 0, 1, or random values between 0 and 1

  47. Size of Vectors and Arrays MATLAB provides two functions to determine the size of arrays in general (a vector is an array with one row): • the function size(A) when applied to the array A returns vector containing two quantities: the number of rows and the number of columns • The function length(A) returns the maximum value in the size of an array; for a vector, this is its length.

  48. Indexing a Vector • The process of extracting values from a vector, or inserting values into a vector • Syntax: • v(index) returns the element(s) at the location(s) specified by the vector index. • v(index) = value replaces the elements at the location(s) specified by the vector index. • The indexing vector may contain either numerical or logical values

  49. Numerical Indexing • The indexing vector may be of any length • It should contain integer (non-fractional) numbers • The values in the indexing vector are constrained by the following rules: • For reading elements, all index values must be 1 <= element <= length(vector) • For replacing elements, all index values must be 1 <= element

  50. Replacement Rules • Either: • All dimensions of the blocks on either side of the replacement instruction must be equal, or • There must be a single element on the RHS of the replacement • If you replace beyond the end of the existing vector, the vector length is automatically increased. • Any element not specifically replaced remains unchanged. • Elements beyond the existing length not replaced are set to 0.

More Related