Robotran: Robot programming adventures for novices in LEGO-land - PowerPoint PPT Presentation

About This Presentation
Title:

Robotran: Robot programming adventures for novices in LEGO-land

Description:

... of robotics Recruit new students to CS Teach non-majors simple programming Provide a framework for CS majors to learn Java ... a sumo ring and tries to ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 31
Provided by: MarkM120
Learn more at: http://cs.canisius.edu
Category:

less

Transcript and Presenter's Notes

Title: Robotran: Robot programming adventures for novices in LEGO-land


1
Robotran Robot programming adventures for
novices in LEGO-land
  • R. Mark Meyer
  • Debra T. Burhans
  • Canisius College
  • Buffalo, NY

2
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?

3
But first... Our chief protagonist
The Pen bot a roverbot with an attached pen so it
can draw, like turtle graphics.
4
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

5
Most of all....
  • Our goal is happy students!

6
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

7
Role of AI
  • Only CSC 360 is a true AI course and uses AI
    techniquesWumpus 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

8
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

9
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

10
Simple Light Follower program
  • program follow1
  • constant BLACK 42
  • loop
  • var lightvalue S3
  • display lightvalue
  • if lightvalue lt BLACK then
  • stop
  • else
  • go forward
  • end
  • end

11
Light Hunter
  • program follow4
  • global constant BLACK 42
  • global var turnedLeft 1
  • loop
  • var lightvalue S3
  • display lightvalue
  • if lightvalue lt BLACK then
  • do findLight
  • else
  • go forward
  • end
  • end

define huntLeft() returns number turn left
sharp 25 degrees var lightvalue S3
if lightvalue gt 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 gt
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
12
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

13
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

14
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

15
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)

16
Navigating the Maze
  • Robots were
  • programmed in
  • NQC, Lejos, and
  • Robolang

17
Better algorithms, anyone?
  • The trickiness of the algorithms was a great
    leveler.
  • There was no strong edge for those who used more
    complex languages.

18
Robot Competitions are Fun!
The Physics Team at the Robot Competition
(Jeff, Mark, Jim) Taken 18 Nov 2006
19
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.

20
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!

21
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.

22
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

23
Some of the Simulation code...
/ 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, Motor
A, MotorB, MotorC, Sensor1, Sensor2, Sen
sor3, Rom, Memory, Poller, Sound, LCD
  • 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)
  • _at_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

24
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

//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) //systemSound
call //a2 0 short beep 1 double beep 2
descending arpeggio 3 ascending arpeggio //
4 long low beep 5 quick ascending
arpeggio else if (aAddr 0x299a) if
(a1 Opcodes.SOUND_QUEUED) RCX.Sound.syste
mSound(true, (int)a2) else if (a1
Opcodes.SOUND_UNQUEUED) RCX.Sound.systemSoun
d(false, (int)a2) //getVoltageInter
nal call //a2 pointer address place where to
store the voltage else if (aAddr 0x29f2
a1 Opcodes.POWER_BATTERY) RCX.Memory.write
Short(a2, (short)RCX.batteryVoltage)
25
The New Robotran and Simulator
26
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

27
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

28
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

29
Our focus the students
30
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!
Write a Comment
User Comments (0)
About PowerShow.com