MyroOverview - Bryn Mawr



MyroOverviewBelow is a chapter by chapter summary of all the Myro features introduced in this text. For a more comprehensive listing of all the Myro features you should consult the Myro Reference Manual.Chapter 1from myro import *This command imports all the robot commands available in the Myro library. We will use this whenever we intend to write programs that use the robot.initialize(<PORT?NAME>)init(<PORT NAME>)This command establishes a wireless communication connection with the robot. <PORT NAME> is determined at the time you configured your software during installation. It is typically the word com followed by a number. For example, "com5". The double quotes (") are essential and required.beep(<TIME>,?<FREQUENCY>)Makes the robot beep for <TIME> seconds at frequency specified by <FREQUENCY>.getName()Returns the name of the robot.setName(<NEW?NAME>)Sets the name of the robot to <NEW NAME>. The new name should be enclosed in double quotes, no spaces, and not more than 16 characters long. For example: setName("Bender").gamepad()Enables manual control of several robot functions and can be used to move the robot around.Chapter 2backward(SPEED) Move backwards at SPEED (value in the range -1.0…1.0).backward(SPEED,SECONDS)Move backwards at SPEED (value in the range -1.0…1.0) for a time given in SECONDS, then stop.forward(SPEED)Move forward at SPEED (value in the range -1.0..1.0).forward(SPEED,TIME)Move forward at SPEED (value in the range -1.0…1.0) for a time given in seconds, then stop.motors(LEFT,RIGHT)Turn the left motor at LEFT speed and right motor at RIGHT speed (value in the range -1.0…1.0).move(TRANSLATE,?ROTATE)Move at the TRANSLATE and ROTATE speeds (value in the range -1.0…1.0).rotate(SPEED)Rotates at SPEED (value in the range -1.0…1.0). Negative values rotate right (clockwise) and positive values rotate left (counter-clockwise).stop()Stops the robot.translate(SPEED)Move in a straight line at SPEED (value in the range -1.0…1.0). Negative values specify backward movement and positive values specify forward movement.turnLeft(SPEED)Turn left at SPEED (value in the range -1.0…1.0) turnLeft(SPEED,SECONDS)Turn left at SPEED (value in the range -1.0..1.0) for a time given in seconds, then stops.turnRight(SPEED)Turn right at SPEED (value in the range -1.0..1.0)turnRight(SPEED,SECONDS)Turn right at SPEED (value in the range -1.0..1.0) for a time given in seconds, then stops.wait(TIME)Pause for the given amount of TIME seconds. TIME can be a decimal number.Chapter 3speak(<something>)The computer converts the text in <something> to speech and speaks it out. <something> is also simultaneously printed on the screen. Speech generation is done synchronously. That is, anything following the speak command is done only after the entire thing is spoken.speak(<something>, 0)The computer converts the text in <something> to speech and speaks it out. <something> is also simultaneously printed on the screen. Speech generation is done asynchronously. That is, execution of subsequent commands can be done prior to the text being spoken.timeRemaining(<seconds>)This is used to specify timed repetitions in a while-loop (see below). Chapter 4randomNumber()Returns a random number in the range 0.0 and 1.0. This is an alternative Myro function that works just like the random function from the Python random library (see below).askQuestion(MESSAGE-STRING)A dialog window with MESSAGE-STRING is displayed with choices: 'Yes' and 'No'. Returns 'Yes' or 'No' depending on what the user selects.askQuestion(MESSAGE-STRING,?LIST-OF-OPTIONS)A dialog window with MESSAGE-STRING is displayed with choices indicated in LIST-OF-OPTIONS. Returns option string depending on what the user selects.currentTime()The current time, in seconds from an arbitrary starting point in time, many years ago.getStall()Returns True if the robot is stalled when trying to move, False otherwise.getBattery()Returns the current battery power level (in volts). It can be a number between 0 and 9 with 0 indication no power and 9 being the highest. There are also LED power indicators present on the robot. The robot behavior becomes erratic when batteries run low. It is then time to replace all batteries.Chapter 5getBright()Returns a list containing the three values of all light sensors.getBright(<POSITION>) Returns the current value in the <POSITION> light sensor. <POSITION> can either be one of 'left', 'center', 'right' or one of the numbers 0, 1, 2. getGamepad(<device>)getGamepadNow(<device>)Returns the values indicating the status of the specified <device>. <device> can be "axis" or "button". The getGamepad function waits for an event before returning values. getGamepadNow immediately returns the current status of the device.getIR()Returns a list containing the two values of all IR sesnors.getIR(<POSITION>) Returns the current value in the <POSITION> IR sensor. <POSITION> can either be one of 'left' or 'right' or one of the numbers 0, 1. getLight()Returns a list containing the three values of all light sensors.getLight(<POSITION>) Returns the current value in the <POSITION> light sensor. <POSITION> can either be one of 'left', 'center', 'right' or one of the numbers 0, 1, 2. The positions 0, 1, and 2 correspond to the left, center, and right sensors.getObstacle()Returns a list containing the two values of all IR sesnors.getObstacle(<POSITION>) Returns the current value in the <POSITION> IR sensor. <POSITION> can either be one of 'left', ‘center’, or 'right' or one of the numbers 0, 1, or 2. savePicture(<picture>, <file>)savePicture([<picture1>, <picture2>, …], <file>)Saves the picture in the file specified. The extension of the file should be “.gif” or “.jpg”. If the first parameter is a list of pictures, the file name should have an extension “.gif” and an animated GIF file is created using the pictures provided.senses()Displays Scribbler’s sensor values in a window. The display is updated every second.show(<picture>)Displays the picture in a window. You can click the left mouse anywhere in the window to display the (x, y) and (r, g, b) values of the point in the window’s status bar.takePicture()takePicture(“color”)TakePicture(“gray”)Takes a picture and returns a picture object. When no parameters are specified, the picture is in color.Chapter 6 & 7No new Myro features were introduced in these chapters.Chapter 8GraphWin()GraphWin(<title>, <width>, <height>)Returns a graphics window object. It creates a graphics window with title, <title> and dimensions <width> x <height>. If no parameters are specified, the window created is 200x200 pixels.<window>.close()Closes the displayed graphics window <window>.<window>.setBackground(<color>)Sets the background color of the window to be the specified color. <color> can be a named color (Google: color names list), or a new color created using the color_rgb command (see below)color_rgb(<red>, <green>, <blue>)Creates a new color using the specified <red>, <green>, and <blue> values. The values can be in the range 0..255.Point(<x>, <y>)Creates a point object at (<x>, <y>) location in the window.<point>.getX()<point>.getY()Returns the x and y coordinates of the point object <point>.Line(<start point>, <end point>)Creates a line object starting at <start point> and ending at <end point>.Circle(<center point>, <radius>)Creates a circle object centered at <center point> with radius <radius> pixels.Rectangle(<point1>, <point2>)Creates a rectangle object with opposite corners located at <point1> and <point2>.Oval(<point1>, <point2>)Creates an oval object in the bounding box defined by the corner points <point1> and <point2>.Polygon(<point1>, <point2>, <point3>,…)Polygon([<point1>, <point2>, …])Creates a polygon with the given points as vertices.Text(<anchor point>, <string>)Creates a text anchored (bottom-left corner of text) at <anchor point>. The text itself is defined by <string>.Image(<centerPoint>, <file name>)Creates an image centered at <center point> from the image file <file name>. The image can be in GIF, JPEG, or PNG format.All of the graphics objects respond to the following commands:<object>.draw(<window>)Draws the <object> in the specified graphics window <window>.<object>.undraw()Undraws <object>.<object>.getCenter()Returns the center point of the <object>.<object>.setOutline(<color>)<object>.setFill(<color>)Sets the outline and the fill color of the <object> to the specified <color>.<object>.setWidth(<pixels>)Sets the thickness of the outline of the <object> to <pixels>.<object>.move(<dx>, <dy>)Moves the object <dx>, <dy> from its current position.The following sound-related functions were presented in this chapter.beep(<seconds>, <frequency>)beep(<seconds>, <f1>, <f2>)Makes the robot beep for <seconds> time at frequency specified. You can either specify a single frequency <frequency> or a mix of two: <f1> and <f2>.<robot/computer object>.beep(<seconds>, <frequency>)<robot/computer object>.beep(<seconds>, <f1>, <f2>)Makes the robot or computer beep for <seconds> time at frequency specified. You can either specify a single frequency <frequency> or a mix of two: <f1> and <f2>. robot.playSong(<song>) Plays the <song> on the robot.readSong(<filename>)Reads a song file from <filename>. song2text(song)Converts a <song> to text format.makeSong(<text>)text2song(<text>)Converts <text> to a song format.Chapter 9getHeight(<picture>)getWidth(<picture>)Returns the height and width of the <picture> object (in pixels).getPixel(<picture>, x, y)Returns the pixel object at x,y in the <picture>.getPixels(<picture>)When used in a loop, returns one pixel at a time from <picture>.getRGB(pixel)getRed(<pixel>)getGreen(<pixel>)getBlue(<pixel>)Returns the RGB values of the <pixel>.makeColor(<red>, <green>, <blue>)Creates a color object with the given <red>, <green>, and <blue> values (all of which are in the range [0..255]).makePicture(<file>)makePicture(<width>, <height>)makePicture(<width>, <height>, <color>)Creates a picture object either by reading a picture from a <file>, or of the given <width> and <height>. If <color> is not specified, the picture created has a white background.pickAColor()Creates an interactive dialog window to select a color visually. Returns the color object corresponding to the selected color.pickAFile()Creates an interactive dialog window that allows user to navigate to a folder and select a file to open. Note: it cannot be used to create new files.repaint()repaint(<picture>)Refreshes the displayed <picture>.savePicture(<picture>, <file>)savePicture(<picture list>, <gif file>)Saves the <picture> in the specified file (a GIF or JPEG as determined by the extension of the <file>: .gif or .jpg). <picture list> is saved as an animated GIF file.setColor(<pixel>, <color>)setRed(<pixel>, <value>)setGreen(<pixel), <value>)setBlue(<Pixel>, <value>)Sets the color of <pixel> to specified <color> or <value>.show(<picture>)show(<picture>, <name>)Displays the <picture> on the screen in a window named <name> (string).takePicture()takePicture(“gray”)takePicture(“blob”)Takes a picture from the Scribbler camera. It is a color picture by default, or grayscale (“gray”), or a filtered image based on the defined blob (“blob”). See chapter text for examples.Chapter 10There were no new Myro features introduced in this chapter. Actually, when the chapter is complete it will have Myro primitives for neural nets/conx described here.Chapter 11 & 12No new Myro features were introduced in this chapter.IndexAAAAI 18ABC song 68abstraction 36acos 183, 326Aesop 43Aggressive, Vehicle#2 135-6Aibo 4algorithm 281, 292, 302, 305Al Khwarizmi 283Alive, vehicle#1 131-5Anananova 317and 85, 86, 92, 324Animated GIF 220AntiqueWhite 189append 111, 125, 325Apple Strudel 280Artificial Intelligence 4, 88, 245-271 movie 3, 245Asimov’s Laws 17asin 183, 326askQuestion 78, 79, 91, 137, 332assignment 50, 66, 323atan 183, 326Avoiding obstacles 148-151Bbackward 24, 38, 330battery disposal 89beep 12, 16, 201-205, 211, 329, 336Behavior-based control 158Blobs 236blob filtering 236Computational Linguistics 248Computer Science 273, 275conditions 84, 87constant time algorithms 302Corral Exiting 151cos 183, 326Coward, Vehicle#2 135-6currentTime 81-83, 91, 332DDar es Salaam 110, 112data 302Data Fountain 318dead reckoning 73decision making 176Deep Blue 250def 27, 39, 118, 321degrees 183, 326Delaware River 5Dijkstra, Edsger W. 273, 275Direct Control 159draw 190, 211, 336Ee 183, 326edge detection 237Elvis 85emboss image 230Energy Problem 55enlarge image 227-8exp 139, 164, 182, 326Explorer 43Explorer, Vehicle#3 138expression 50equal temperament 204Ericsson 18getGamepadNow 115-16, 122, 333getCenter 192, 211, 336getGreen 238, 337getHeight 218, 238, 337getIR 106-7, 122, 333getLight 103, 122, 333getName 13, 16, 329getObstacle 107-8, 123, 333getP1 191getP2 192getPixel 222, 238, 337getPixels 223, 238, 337getRed 238, 337getRGB 223, 238, 337getStall 87, 91, 332getX 190, 210getY 190, 210getWidth 218, 238, 337GIF 217global name 196-7, 328Google 3Gore, Al 68Gormson, Harald B. 18GPS 314-15Grade A eggs 281GraphWin 188, 209, 334Gray Poupon 47, 113grayscale images 102Gregorian Calendar 291HHallway Cruiser 145Hektor robot 314Hertz (Hz) 201hi-fidelity 202HiLo game 184Jones, Mick 129JPEG 217Julia Sets 213KKasparov, Gary 250Kismet robot 317Kitaoka, Akiyoshi 215Koch Snowflakes 213Konane 250LLadybug 129Larson, Doug 273LavenderBlush 189Law, Jude 245Leap Frog 313leap year 291-5Learning 267LED 89LEGO Mindstorms 3len 110, 124, 325Lenhi, Jurg 313Light following 146-8Line 191, 210, 335linear time algorithms 302List comprehensions 255lists 60, 109-13, 325Loan calculator 167-76local name 196-7, 328localtime 94log 165, 183, 326log10 165, 183, 326logarithmic time algorithms 302logical operations 85loop 60NASA JPL 1, 3, 310Nash, Johnny 97Natural Language Understanding 248natural languages 14, 247Naughts & Crosses 251negative image 230New York 85, 110, 112Nexi robot 317Nike viiinot 85, 86, 92, 324notes 204numbers 50Ooctave 204Ok Corral 151OLPC Project 22, 273-4Opportunity robot 1, 2, 17, 310or 85, 86, 92, 324Orb Swarms 309, 319Osment, Haley Joel 71, 245-6Oval 210, 335PPapal Bull 290-1Paper Scissors Rock 177-82, 264-7parameters 30, 195-7Paranoid 141Paris 85Paro robot 23Pathfinder 17PB&J 265Pennsylvania 5Philadelphia 117pi 183, 326pickAColor 222, 239, 338repaint 222, 239, 338repetition 60, 66, 176Resnick, Mitchel 153return 119, 124, 324return values 163-4reverse 111, 125, 325RGB 102, 193, 216, 223RoboCup 315Robot, definition 3, 4Robot Hall of Fame 18Robot Vision 232Rochambeau 177Rock Paper Scissors 177-82, 264-7Roomba 2, 3, 22, 59rotate 25, 38, 330Rotating Snakes 214Royal Mail 5Run Module 46runic alphabet 18SSaab 167savePicture 100, 123, 218-, 239, 334, 338scale 204Scassellati, Brian 316Science Magazine 153scope 195Scribbler 6, 22Scribbler 208Scribbler drawings 313-14Scribbler sensors 99Sear, Cole 71, 72Searle, John 270sequential execution 176senses 99, 108, 123, 334Squyres, Steve 1Start Python 9, 16, 321strings 50, 52stop 25, 38, 331Subsumption Architecture 160Sullivan, Jon 71syntax error 35urlopen 117, 124, 325USDA 281-2TTag reading pen 313takePicture 100-2, 123, 216-, 240, 334, 339Takada 312tan 183, 326Tengu 311-12Testing 296-9text 200, 210, 336Terra flops 304Thingamapoops 313Tic Tac Toe 250-264time 94Space Complexity 301-5timeRemaining 62, 64, 332Timid 141TOMY Company 312Toyota Prius 110Traffic Lights 157translate 25, 38, 331True 63, 84, 86, 91, 324Tumbleweed robot 2Turing, Alan 246, 270Turing Test 246turnLeft 24, 38-39, 331turnRight 24, 39, 331Bluetooth 6, 8Bluetooth logo 18, 40blur image 229Boolean 85boundary conditions 296Braitenberg, Valentino 130, 153Braitenberg Vehicles 130-Breazeal, Cynthia 18, 317Brooks, Rodney 309-10, 317Burglar Alarm 145CC 6C++ 293CamelCase 68case sensitive 48ceil 164, 182, 326Celsius 67characters 52Chazelle, Brian 307Chess 250Chicken Kabobs 276-7Chinese Room 270Ching-Chong-Cha 177choice 257, 269Circle 192, 210, 335Clash, The 129close 189, 209, 334Cockroach 153color_rgb 194, 210, 335CommonLisp 293comments 32computable 304Euclid v Error Checking 296-9Euro 67FFace Bank 312False 63, 84, 86, 91, 324Farenheit 67Firefox 44floating point numbers 51floor 164, 182, 326Flip Flap 312Flops 304Fluke Dongle 8, 9, 125Flying Circus 29Flynn, Anita M. 309-10Follower 146for 60, 66, 83, 323formal languages 14forward 24, 38, 330fractals 213Franke, Uli 313Franklin Institute 117from 34, 166, 322function 27, 34GGamepad controller 14, 114-16gamepad 14, 16, 108, 330Game playing 251-267Geier, Sven 187getBattery 88, 89, 91, 332getBlob 237getBlue 238, 337getBright 104-5, 122, 332getGamepad 115-16, 122, 333Hoare, C. A. R. 273Hogg, David 153Hugs & Kisses 251Human-robot interaction 315-16IiCat robot 316IDLE 10, 27, 29, 36, 62Idle, Eric 29if-statement 120, 123, 142, 154. 324, 326image 216Image 201, 210, 336image processing 226image understanding 232Imitation Game 246import 166, 322in 110, 124, 325Indecisive 141init 16, 329initialize 11, 12, 16, 329input 56, 65, 113, 322integers 51internet 5interoceptors 72invocation, function 28iPhone 85iRobot 2, 59Jjalapeno 72Jankenpon 177Java 6Joe, Gigolo 245Joel, Billy 187Jones, Crispin 311loop index variable 60Love, Vehicle#3 138Lousanne 314Mmain 65, 322makeColor 222, 224, 239, 338makePicture 219, 221-, 239, 338Mandelbrot Sets 213Mars Rover 1, 2, 4Martin, Fred 153math library 139-40, 164-6, 326Maze solver 151meaning of life 280Measuring Device 145-6Media Player 43Megapixel 217Mignot, Charles 318Minimax algorithm 262Minsvoort, Koert van 318MIT Media Lab 153, 317mixed case 68module 31, 33, 34, 299Monty Python 6, 29Morris, Errol 310Moscow 110, 112motors 23, 38, 330move (robot) 25, 38, 330move (graphics object) 198, 211, 336musical scale 204Myers, Mike 157Myro 6, 8, 13, 329myro Song Format 206NNames 48, 49, 65, 163, 195-8, 322pickAFile 239, 338pixels 102, 216-7playSong 208, 211, 337Pleo 4, 20-22PNG 217Point 190, 210, 335Polar coordinates 241Polka 206Polygon 210, 335polynomial time algorithms 303Pope Gregory XIII 291pow 165, 183, 326Powers, Austin 157print 46, 65, 322Programming 6, 274Programming Language 6, 44, 279, 292Proprioception 72proximity sensor 73Python 6, 44, 47Python Shell 10, 11Qquadratic algorithms 303Rradians 183, 326random 77, 92, 93, 178, 324randomNumber 91, 93, 332randint 77, 92, 324range 60, 66, 112, 124-5, 325Reactive behaviors 143-152Reactive control 159read 117, 124, 325readSong 208, 211, 337Rectangle 210, 335Refrigerator Detective 145Sensor Fusion 159setBackground 189, 209, 335setBlue 239, 338setColor 223, 239, 338setFill 193, 211, 336setGreen 239, 338setName 13, 16, 330setOutline 193, 211, 336setPixel 225setRed 239, 338setRGB 223setWidth 193, 211, 336sharpen image 229shrink image 227-8shrinking factor 228-9show 100, 123, 216, 218, 240, 334, 338Shyamalan, M. Night 71, 72Sierpinski Triangles 213Simpson, Homer 42sin 183, 326Sixth Sense movie 71, 72Snicker’s moment 72Sojourner 17, 310solvable 304song2text 212, 337SONY 4sort 111, 125, 325Social Robotics 316Soviet Union 283Space Complexity 301-5speak 47, 64, 125, 331Spitler, Phil 309split 113, 124, 324Spirit robot 1, 2, 17, 310Spielberg, Steven 3, 245sqrt 164, 183, 326UUGOBE Inc. 21uncomputable 304undraw 211, 336Unicode 85Unimation 4unsolvable 304urllib 117VValues 50, 65variable 50Victoria Crater, Mars 3Wwait 29, 39, 322, 331Wales 58Wall Detector 145Washington DC 301Washington state 301while 62, 66, 83, 87, 323WhiteSmoke 189Wikipedia 18, 29Wong, Yingshun 157world population 53, 64, 89world wide web 5XXO Laptop 273-4YY2K Problem 307ZZamboni 58, 92Zefrank 313-14 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches