Robotran: A programming environment for novices in LEGO-land

Robotran: A programming environment for novices in LEGO-land

Robotran: Robot programming adventures for novices in LEGO-land R. Mark Meyer Debra T. Burhans Canisius College Buffalo, NY 1 Overview Our use of LEGO Mindstorms in the curriculum, especially early courses Robolang a simple, non-threatening programming language Simulation let them take it home with them How to sneak AI concepts into intro courses Whats NXT?

2 But first... Our chief protagonist The Pen bot a roverbot with an attached pen so it can draw, like turtle graphics. 3 Educational Objectives Motivate students to stay in CS using the fun and challenge of robotics Recruit new students to CS Teach non-majors simple programming Provide a framework for CS majors to learn Java better (using Lejos)

Use social implications of robotics to motivate ethics discussion Introduce students to AI concepts 4 Most of all.... Our goal is happy students! 5 Curricular Use CSC 110 A CS 0 course

CSC 109 Another CS 0 course that is solely robotics EGR 111 Introduction to engineering (pre-engineers) CSC 111 Our Java-based CS 1 CSC 360 Intelligent Systems: AI, robotics, knowledge bases CSC 391/491 Seminar, 1 credit hour special projects 6 Role of AI Only CSC 360 is a true AI course and uses AI techniques: Wumpus world, intelligent agents, searching CSC 109 focus on basic AI and computing in the context of robotics, programming as a way of creating behaviors CSC 110 mostly drawing letters, simple algorithms EGR 111 study sensor electronics, basic programming concepts (BrickCC), engineering through robot building We also sneak AI concepts into CSC 111 Seminar allows students to work on larger AI projects

7 Robotran V.1 Translator program Robolang a simple Python-ish language Translator to true Lejos Used as web applet or standalone Java app Can compile and download 8 Robolang Details Streamlined syntax for assignments and control structures, especially button handler methods Uses Java expression syntax and transparently inserts into the final Lejos code

Simplified robot commands: go forward 10 seconds Motor.A.start(); Motor.B.start(); try { Thread.sleep(10000); } catch (Exception e) {} Simplified function (method) syntax 9 Simple Light Follower program program follow1 constant BLACK = 42 loop var lightvalue = S3 display lightvalue if lightvalue < BLACK then stop else

go forward end end 10 Light Hunter program follow4 global constant BLACK = 42 global var turnedLeft = 1 loop var lightvalue = S3 display lightvalue if lightvalue < BLACK then do findLight else go forward end end

define huntLeft() returns number turn left sharp 25 degrees var lightvalue = S3 if lightvalue > BLACK then return 1 else turn right sharp 25 degrees return 0 end end define huntRight() returns number turn right sharp 25 degrees var lightvalue = S3 if lightvalue > BLACK then return 1 else turn left sharp 25 degrees return 0

end end define findLight var result if turnedLeft = 1 then result = huntLeft() if result = 1 then return end result = huntRight() if result = 1 then turnedLeft = 0 return end end if turnedLeft = 0 then if huntRight() = 1 then return

end if huntLeft() = 1 then turnedLeft = 1 return end end end 11 Syntactic Sugar Use only one equals sign to compare things Allow several syntaxes for assignment statements; avoid the old equals confusion let X = 5 set X to 5 Allow parentheses around conditions to be omitted Use clear control structure delimiters: end statements

Turn around the order of elements in a function definition, la Pascal define huntRight() returns number 12 The Place of Language Continuum of difficulty in Robot languages: Robolab and NXT graphical environment Lisp, Robolang, Python type languages NQC Lejos What is your goal?

Teach beginner non-majors to control a robot? Use easy language Inspire engineers? Use NQC Reinforce Java for CS majors? Use Lejos However, a difficult language may turn off students! Alternative: use a ramp-up strategy like Dr. Java project Use Scheme first, then Java 13 Lessons Learned from Language Design Separating button events from sensor polling is tricky for novices Language structures should aid this distinction when RUN button is pressed do stuff end This shouldnt be in-line with main program Need definite program structure with its own end

More study is needed to pinpoint troublesome concepts 14 Assignments Robot avoids obstacles by randomly turning after bumps Robot draws letters Robot follows a light source and hunts for it when lost Robot receives input from bumps and button presses, including binary or unary numbers

Robot is taught a path which it can then replay (uses arrays) Robot follows a line on the floor Robot stays within a sumo ring and tries to push another robot outside without leaving the ring itself Robot navigates a maze (needs to remember path & obstacles) 15 Navigating the Maze Robots were programmed in NQC, Lejos, and Robolang 16 Better algorithms, anyone? The trickiness of the algorithms

was a great leveler. There was no strong edge for those who used more complex languages. 17 Robot Competitions are Fun! The Physics Team at the Robot Competition (Jeff, Mark, Jim) Taken 18 Nov 2006 18

AI concepts at work Many of these tasks can motivate AI discussion and algorithm development, esp. searching, strategy and data structures One definition of intelligence: having a wide repertory of solutions from which to choose when encountering a problem We cant do much with the RCX alone due to limited memory and processing time Even the NXT only has 256K RAM, but it can more easily use a wirelessly connected computer as its brain These robots are learning environments, not built to actually explore Mars! Similarly our students are just getting started. 19 Need for a Simulator Almost everyone agrees we need one

Shouldnt usurp the tactile, kinetic experience Allow students to complete assignments at home or outside of lab Could be used to explore more complicated behaviors Major challenge to build a realistic and useful one! 20 Doomed to Succeed? ... and the demo was launched again. This time the students lost their wireless connection and the process had to begin again. In the end, the visiting Boeing bigwigs gathered around a laptop display and watched an elaborate demonstration of the treasure hunt concept in simulation. The Boeing folks were quite intrigued and, seemingly, satisfied. Simulations, so the

saying goes at the RI (Robotics Institute at CMU), are doomed to succeed. Almost Human: Making Robots Think by Lee Gutkind WW Norton, 2006. 21 Our simulator Simulate the penbot, only one at a time, geared towards real assignments Dont get overly caught up with 3d graphics Provide functionality with both Robolang and Lejos Make it flexible for future implementation on NXT Use the lejos compiled code that makes calls to the firmware ROM Create our own ROM object with same API and let the compiled code, running in tinyVM, call it Then our ROM object sends updates to a graphics simulation object

22 Some of the Simulation code... package simulator.rcx; //import simulator.*; /* This class represents the RCX robot during a simulation. It keeps track of * states and properties that are associated with a RCX robot. * Note that most fields are static because components on the RCX are finite * meaning that there are a static number of robot components. (ex: number of * buttons will always be 4) *@author David Puehn */ public class RCX { /* The state the robot is in * 0: off * 1: on * 2: on and running a program */

public static int state = 0; /* The current voltage of the RCX's batteries */ public static double batteryVoltage = 319; //TODO: create me thod to convert voltage to readable value /* The virtual RCX's buttons */ public static Button ButtonRUN = new Button(0x01); public static Button ButtonVIEW = new Button(0x02); public static Button ButtonPRGM = new Button(0x04); /* The virtual RCX's motors */ public static Motor MotorA = new Motor('A'); public static Motor MotorB = new Motor('B'); public static Motor MotorC = new Motor('C'); /* The virtual RCX's sensors */ public static Sensor Sensor1 = new Sensor((short)1); public static Sensor Sensor2 = new Sensor((short)2); public static Sensor Sensor3 = new Sensor((short)3); /* The RCX's ROM */ public static ROM Rom = new ROM();

/* The RCX's Memory */ public static Memory Memory = new Memory(); /* The RCX's Poller */ public static Poller Poller = new Poller(); /* The RCX's Sound */ public static Sound Sound = new Sound(); /* The RCX's User Controls */ public static RcxController Controller = new RcxController(); /* The RCX's LCD */ public static Display LCD = new Display(); /* Holds all of the simulator components so that we can iterate through them */ public static RcxComponent[] components = { ButtonRUN, ButtonVIEW, ButtonPRGM, MotorA, MotorB, MotorC, Sensor1,

Sensor2, Sensor3, Rom, Memory, Poller, Sound, LCD }; Emulating the native ROM routines package simulator.rcx; /* An emulation of the RCX's native ROM routines */ public class ROM implements RcxComponent { //simulates behavior when call to RCX's rom public static void call(short aAddr) { //refresh the lcd if (aAddr == 0x27c8) { RCX.LCD.refresh(); }

//clear the lcd else if (aAddr == 0x27ac) { RCX.LCD.clear(); } } //simulates behavior when call to RCX's rom public static void call(short aAddr, short a1) { //setSegment of lcd //a1: the lcd segment if (aAddr == 0x1b62) { RCX.LCD.setSegment(a1); } //simulates behavior when call to RCX's rom public static void call(short aAddr, short a1, short a2) { //readButtons call //a2: pointer address; place to store the button that is pressed if (aAddr == 0x1fb6 && a1 == Opcodes.BUTTONS_READ) { short buttonState = Button.readButtons();

RCX.Memory.writeShort(a2, buttonState); } arpeggio // 4 = long low beep 5 = quick ascending arpeggio else if (aAddr == 0x299a) { if (a1 == Opcodes.SOUND_QUEUED) { RCX.Sound.systemSound(true, (int)a2); } else if (a1 == Opcodes.SOUND_UNQUEUED) { RCX.Sound.systemSound(false, (int)a2); } } //clearSegment of lcd //a1: the lcd segment else if (aAddr == 0x1e4a) { RCX.LCD.clearSegment(a1);

} //reset two byte timer //a1: who the hell knows? else if (aAddr == 0x339a) { //TODO: figure out what the hell this is } } //systemSound call //a2: 0 = short beep 1 = double beep 2 = descending arpeggio 3 = ascending //getVoltageInternal call //a2: pointer address; place where to store the voltage else if (aAddr == 0x29f2 && a1 == Opcodes.POWER_BATTERY) { RCX.Memory.writeShort(a2, (short)RCX.batteryVoltage); } } The New Robotran and Simulator

Near future improvements Simulator Permit collision detection with the walls Permit building obstacles that the robot can bump into Permit building a black line path on the ground for light following Permit a light source to simulate a flashlight that the robots light sensor can detect Better Robolang parser and error messages 26 Our experience

Students in early courses that use only Robolang like it They can implement very complex algorithms quickly They participated in a local robot competition and did well Those who went on to CSC 111 seemed to appreciate the link and made the transition to Lejos/Java well Surveys and anecdotal evidence indicate high level of satisfaction After first robot lab: I actually got a robot to do something! No statistical difference in final grades between non-robot and robot years in CSC 111 27 Student Reactions to AI

Some students who are not very interested in computer science find AI fascinating The interest in AI helps motivate them in robot programming tasks Students are able to make connections between the very simple systems they are using and extremely complex robots such as the Honda Asimo Students appreciate the difficulty of unsolved AI problems such as vision The cultural perception of programmers is negative and boring a la Office Space, but roboticists are viewed as interesting and sexy 28 Our focus: the students 29

Future Plans Test the use of programming language structures effect on task completion time Test the ease of adjustment to a harder language Continue to track recruitment and retention (problem with small sample size at smaller colleges) Port to the NXT Teach an honors science elective that is heavily liberal arts and is focused on AI and robotics Develop a cross-disciplinary minor in AI/robotics that will draw a larger audience into computer science courses Of course, debug, Debug, DEBUG! Have fun! 30

Recently Viewed Presentations

  • The First Line of Response: Student Disclosure of Sexual Assault

    The First Line of Response: Student Disclosure of Sexual Assault

    The First Line of Response: Student Disclosure of Sexual Misconduct NEW FACULTY ORIENTATION AUGUST 18, 2015 The role of faculty Awareness Knowledge Culture Title IX of the Education Amendments of 1972 37 Powerful Words….
  • 90º Peel Test - MIT

    90º Peel Test - MIT

    3.042 Materials Project Laboratory Design Review Team No-Drip Tania Chan Michele Dufalla Jacqueline Greene New Goal Plastic Joining Fasteners Hinges Hot Die Fusion and Hot Wire/Resistance Welding Hot Gas Welding Induction/Electromagnetic Welding Press Fits/Shrink Fits Snap Fits Spin Welding Staking/Cold...
  • Welcome Welcome to Welcome to Dr. Chus  Welcome

    Welcome Welcome to Welcome to Dr. Chus Welcome

    Convert from 123,560 Pa to atm. ... Convert 1.5 atm to mmHg. Convert 768 mmHg to kPa. Convert 235,620 Pa to psi. Convert 0.23 psi to torr. Pressure - exercise Answers. Convert 1.5 atm to mmHg [1140 mmHg] Convert 768...
  • The Agency Problem - Cengage

    The Agency Problem - Cengage

    Owner-managers may need to seek outside capital and thus give up some of the ownership control. In these cases, protection of the minority owners' rights becomes important. To avoid these potential problems, as they grow and become more complex, the...
  • Elipsa, Zeugma

    Elipsa, Zeugma

    ELIPSA, ZEUGMA Petra Libíková 14.4.2010 ELIPSA Z řeckého slova ellipsis = nedostatek, chyba, vynechání Označována též výpustka (výpustek) ELIPSA = vynechání takových slov nebo vět, které označují skutečnosti známé ze situace nebo z kontextu, a které si proto můžeme bez...
  • Introduction to Greek Drama

    Introduction to Greek Drama

    Introduction to Greek Drama Origins: The ancient Greeks believed that the gods held great influence over the lives of humans; this was the basis of their most enduring invention: The tragic drama. The tragic dramas were performed over the course...
  • Linear Programming - Mercer University

    Linear Programming - Mercer University

    Arithmetic Gradient Factors (P/G, A/G) Cash flows that increase or decrease by a constant amount are considered arithmetic gradient cash flows. The amount of increase (or decrease) is called the gradient.
  • Warm-ups, 2nd 6 weeks

    Warm-ups, 2nd 6 weeks

    Warm up #9 Odyssey review1-7-14 Create a flowchart of the . all 16 . stops Odysseus makes on his Odyssey home. (1st 4 shown) Aeolus (1224) Summarize what happens to Odysseus in this episode.