sophisticatedroboticsaccessible∗
DouglasBlank
HollyYanco
ComputerScienceComputerScienceBrynMawrCollegeUniv.ofMass.LowellBrynMawr,PA19010Lowell,MA01854dblank@cs.brynmawr.edu
holly@cs.uml.edu
Abstract
Aseducators,weareoftenfacedwiththeparadoxofhavingtocreatesimplifiedexamplesinordertodemon-stratecomplicatedideas.Thetrickisinfindingtherightkindsofsimplifications—onesthatwillscaleuptothefullrangeofpossiblecomplexitiesweeventuallywouldlikeourstudentstotackle.Inthispaper,wearguethatlow-costrobotshavebeenausefulfirststep,butarenowbecomingadead-endbecausetheydonotallowourstu-dentstoexploremoresophisticatedroboticsmethods.Wesuggestthatitistimetoshiftourfocusfromlow-costrobotstocreatingsoftwaretoolswiththerightkindsofabstractionsthatwillmakeiteasierforourstudentstolearnthefundamentalissuesrelevanttorobotprogram-ming.WedescribeaprogrammingframeworkcalledPyrowhichprovidesasetofabstractionsthatallowsstu-dentstowriteplatform-independentrobotprograms.
Introduction
TheKarel-the-robotenvironmentwasdesignedtointro-ducestructuredimperativeprogrammingtobeginningprogrammingstudents(RichardE.Pattis1981).Inasimilarway,inexpensiverobotshavemadeintroductoryAItopicsaccessibletoawiderangeofstudents,fromK-12tothecollegelevel.Theavailabilityoflow-costrobotshasledtotheirwidespreaduseintheundergrad-uateartificialintelligencecurriculum(Meeden1996;Turneretal.1996;Kumar&Meeden1998;Beer,Chiel,&Drushel1999;Harlan,Levine,&McClarigan2001;Wolz2001;Gallagher&Perretta2002;Klassner2002).Althoughthistrendhasbeenatremendoushelpinbringingroboticstostudents,webelievetheselow-costrobotplatformsoftenleadtoaroboticsdead-end,muchthesamewaythatoverrelianceontheKarelenviron-mentdidtoadvancedprogrammingparadigms.Whilelow-costrobots,liketheKarelenvironment,provideawonderfulmotivationandagreatstartingpoint,the
∗ThisworkwassupportedinpartbyNSFCCLIgrantDUE0231363.
DeepakKumar
LisaMeeden
ComputerScienceComputerScienceBrynMawrCollegeSwarthmoreCollegeBrynMawr,PA19010Swarthmore,PA19081dkumar@cs.brynmawr.edu
meeden@cs.swarthmore.edu
paradoxisthattheyoftentrapthestudentinasingleparadigm,orworse,asinglehardwareplatform.
Thereareseveralproblemswiththeuseoflow-costrobotsineducation.Thefirstproblemisthateveryrobotplatformcomeswithitsown,oftenproprietary,devel-opmenttoolsthataresubstantiallydifferentfromotherplatforms.Oftentheprimaryprogramminglanguagesusedaredifferentaswell.Moreproblematicmaybeacompletechangeinparadigmfromonerobottoanother.Consequently,evenifoneweretoinvestinlearningtouseonerobotplatform,probablynoneofthecode,andpossiblylittleoftheknowledgewouldtransfertoadif-ferentplatform.Thissituationisperhapssimilartotheoneintheearlydaysofdigitalcomputerswheneverycomputerhadadifferentarchitecture,adifferentassem-blylanguage,andevenadifferentwayofstoringthemostbasickindsofinformation.
Secondly,webelievethatmanyrobotprogrammingparadigmsdonoteasilysupportmoresophisticatedsen-sors.Forexample,low-costrobotsoftenonlycomeequippedwithinfraredrangesensors.Somecanbeexpandedtoincludesonarrangesensorsorevenlaserrangesensors.However,wesuspectthatifevenmoresophisticatedsensorsweretobecomeaffordable,wewouldbeunabletoutilizethembecausethereisnoeasywayofintegratingthemintoexistingrobotsoft-wareparadigms.Thatis,sophisticatedsensorsmaybehardwareaccessible,butnotconceptuallyaccessiblebythestudent.Theproblemisthattheframeworkdoesn’tpedagogicallyscalewell.
WebelievethattheproliferateduseofrobotsinAIeducationwillresultnotfromlow-costhardwareplat-forms,butfromaccessibilityoftheseplatformsviacommonconceptualfoundationsthatwouldmakepro-grammingthemuniformandconsistent.Ourpositionisdefinedmorebystrivingforalowerlearningcostofroboticswithoutsacrificingthesophisticationofad-vancedcontrollers.
Ourgoalistoreducethecostoflearningtoprogramrobotsbycreatinguniformconceptualizationsthatare
independentofspecificrobotplatformsandincorpo-ratetheminanalreadyfamiliarprogrammingparadigm.Conceptualizinguniformrobotcapabilitiespresentsthebiggestchallenge:HowcanthesameconceptualizationapplytodifferentrobotswithdifferentcapabilitiesanddifferentprogrammingAPI’s?Ourapproach,whichhasbeensuccessfultodate,hasbeenshowntoworkonsev-eralrobotplatforms,fromthemost-expensiveresearch-orientedrobot,tothelowest-costLEGO-basedones.Wearestrivingforthe“write-once/run-anywhere”idea:robotprograms,oncewritten,canbeusedtodrivevastlydifferentrobotswithoutmakinganychangesinthecode.Thisapproachleadsthestudentstoconcen-tratemoreonthemodelingofrobot“brains”byallow-ingthemtoignoretheintricaciesofspecificrobothard-ware.Moreimportantly,wehopethatthiswillallowstudentstograduallymovetomoreandmoresophis-ticatedsensorsandcontrollers.Inourexperience,thismoregeneralizedframeworkhasresultedinabetterin-tegrationofrobot-basedlaboratoryexercisesintheAIcurriculum.Itisnotonlyaccessibletobeginners,butisalsousableasaresearchenvironmentforrobot-basedmodeling.
ThePyroFramework
Wehavebeendevelopingarobotprogrammingframe-workthatwecallPyroforPythonRobotics(Blank,Meeden,&Kumar2003).Asthenamesuggests,mostoftheframeworkiswritteninPython.Pythonisaneasy-to-readscriptinglanguagethatlooksverysimilartopseudocode.Pythonfitsverywellwithourgoalsinthatitiseasyforbeginningstudentstolearn,andyetitalsosupportsmanyadvancedprogrammingparadigms,suchasobject-orientedandfunctionalprogrammingstyles.ItalsointegrateseasilywithCandC++codewhichmakesitpossibletoquicklyincorporateexistingcode.TheC/C++interfacealsoletsoneputveryex-pensiveroutines(likevisionprograms)atlowerlevelsforfasterruntimeefficiency.OneinterestingreasonforusingPyroisthattheentiresoftware,fromtheOpenGLinterfacetotheneuralnetworkcode,canbeexploredbythestudent.Inaddition,advancedstudentscancopythecodeintotheirownspaceandchangeanythingthatintereststhem.
WehavealsousedPyrowithbeginningprogrammersandnon-programmers.Forexample,inanintroductiontocognitivesciencecourse,PyrocanbeusedlikeonewoulduseLEGO-basedrobots.However,thestudentsneednotlearnanewinterfaceastheyexploreothercon-trolparadigms,suchasfuzzylogic,neuralnetworks,orgeneticalgorithms.
Inadditiontotheunifiedframework,wehavecreatedsimpleabstractionsthatmakethewritingofbasicrobotbehaviorsindependentofthesize,weight,andshapeof
arobot.Considerwritingarobotcontrollerforobstacleavoidancethatwouldworkona24-inchdiameter,50-poundPioneer2robotaswellasona2.5-inchdiameter,3-ounceKhepera.Thiswasmadefeasiblebymakingthefollowingabstractions:
RangeSensors:Regardlessofthekindofhardwareused(IR,sonar,laser)sensorsarecategorizedasrangesensors.Sensorsthatproviderangeinforma-tioncanthusbeabstractedandusedinacontrolpro-gram.
RobotUnits:Distanceinformationprovidedbyrangesensorsvariesdependingonthekindofsensorsused.Somesensorsprovidespecificrangeinformation,likedistancetoanobstacleinmetersormillimeters.Otherssimplyprovideanumericvaluewherelargervaluescorrespondtoopenspaceandsmallervaluesimplynearbyobstacles.Inourabstractions,inaddi-tiontothedefaultunitsprovidedbythesensors,wehaveintroducedanewmeasure,arobotunit:1robotunitisequivalenttothediameterof1robot,whateveritmaybe.SensorGroups:Robotmorphologies(shapes)varyfromrobottorobot.Thisalsoaffectsthewaysen-sors,especiallyrangesensors,areplacedonarobot’sbody.Additionally,thenumberofsensorspresentalsovariesfromplatformtoplatform.Forexample,aPioneer2has16sonarrangesensorswhileaKheperahas8IRrangesensors.Inordertorelieveaprogram-merfromtheburdenofkeepingtrackofthenum-berofsensors(andauniquenumberingscheme),wehavecreatedsensorgroups:front,left,front-left,etc.Thus,aprogrammercansimplyqueryarobottore-portitsfront-leftsensorsinrobotunits.Thevaluesreportedwillworkeffectivelyonanyrobot,ofanysize,withanykindofrangesensor,yetwillbescaledtothespecificrobotbeingused.MotionControl:Regardlessofthekindofdrivemechanismavailableonarobot,fromaprogram-mer’sperspective,arobotshouldbeabletomovefor-ward,backward,turn,and/orperformacombinationofthesemotions(likemoveforwardwhileturningleft).Wehavecreatedthreemotioncontrolabstrac-tions:translate,rotate,andmove.Thelattersub-sumesbothtranslateandrotateandcanbeusedtospecifyacombinationoftranslationandrotation.Asinthecaseofrangesensorabstractions,thevaluesgiventothesecommandsareindependentofthespe-cificvaluesexpectedbytheactualmotordrivers.Aprogrammeronlyspecifiesvaluesinarange-1.0..1.0(seeexamplesbelow).Services:Theabstractionspresentedaboveprovideabasic,yetimportantfunctionality.Werecognizethattherecanbeseveralotherdevicesthatcanbepresent
frompyro.brainimportBrain
classAvoid(Brain):
defwander(self,minSide):
robot=self.getRobot()
#ifapproachinganobstacleontheleftside,turnright
ifrobot.get(’range’,’value’,’front-left’,’minval’) #ifapproachinganobstacleontherightside,turnleft elifrobot.get(’range’,’value’,’front-right’,’minval’) robot.move(0.5,0) defstep(self): self.wander(1)defINIT(engine): returnAvoid(’Avoid’,engine) Figure1:AnobstacleavoidanceprograminPyro onarobot:agripper,acamera,etc.Wehavede-visedaserviceabstractiontoaccommodateanynewdevicesoradhocprogramsthatmaybeusedinrobotcontrol.Forexample,acameracanbeaccessedbyaservicethatenablesaccesstothefeaturesofthecamera.Further,studentscanexplorevisionprocess-ingbydynamicallyandinteractivelysequencingandcombiningfilters. Inthefollowingsectionweexploreanexamplethatutilizestheseabstractionsanddemonstratestheeffec-tivenessoftheseabstractionsinwritinggenericrobotcontrollers. scribedintheprevioussection.Itiswritteninanobject-orientedstyle,andcreatesaclasscalledAvoidwhichinheritsfromaPyroclasscalledBrain.EveryPyrobrainisexpectedtohaveastepmethodwhichisex-ecutedoneverycontrolcycle.Thebrainshownwillcausetherobottocontinuallywanderandavoidobsta-clesuntiltheprogramisterminated. ItisnotimportanttounderstandallthedetailsofPyroimplementation,butthereadershouldnoticethattheentirecontrolprogramisindependentofthekindofrobotandthekindofrangesensorbeingused.Thepro-gramwillavoidobstacleswhentheyarewithin1robotunitoftherobot’sfrontleftorfrontrightrangesensors,regardlessofthekindofrobot. Afterlearningaboutdirectcontrol,studentscanmovetoanyoftheothercontrolparadigms.TheparadigmsselectedwoulddependuponthecoursethatPyrowasbeingusedfor.Inacoursethatempha-sizedrobotics,thenextparadigmwouldmostlikelybebehavior-basedcontrol.AnAIormachinelearn-ingcoursewouldlikelyskipbehavior-basedcontrolandmoveimmediatelytoneural-network-basedcontrol.Currently,thefollowingmodulesareimplementedandextensivecourse-stylematerialsareavailable:di-rectcontrol,sequencingcontrol,behavior-basedcon-trol,neuralnetwork-basedlearningandcontrol,self-organizingmapsandothervectorquantizingalgo-rithms,computervision,evolutionaryalgorithms,andmulti-robotcontrol.Otherparadigmsandmodulesareplannedinthefuture.Thesewillincludelogic-basedreasoningandacting,classicalplanning,pathplanningandnavigation.Pyroisanopen-source,freesoftware AnExample Inthissection,we’llusetheexampleofavoidingob-staclestodemonstratetheunifiedframeworkthatPyroprovidesforusingthesamecontrolprogramacrossmanydifferentrobotplatforms. Directcontrolisnormallythefirstcontrolmethodin-troducedtostudents.Itisthesimplestapproachbe-causesensorvaluesareusedtodirectlyaffectmotoroutputs.Forexample,thefollowingpseudocoderep-resentsaverysimplealgorithmforavoidingobstacles. ifapproachinganobstacle ontheleftside,turnrightifapproachinganobstacle ontherightside,turnleftelsegoforward TheprogramshowninFigure1implementsthepseudocodealgorithmaboveusingtheabstractionsde- project,andwehopetogetcontributionsfromotherin-terestedusers. Conclusions Wehavearguedthatitismoreimportanttostriveforeasilylearnablerobotprogramminginterfacesthanforlow-costrobotplatforms.WehavetriedtoavoidtheKarel-the-robotparadoxbycarefullydesigningusefulanduniversalconceptualizations.Theseconceptualiza-tionsnotonlymaketherobotprogramsmoreversatile,theyalsohelpinroboticsresearch.Specifically,themodelingofrobotbehaviorscannowbetestedonsev-eralrobotplatformswithouthavingtochangethepro-grams.Thisaddsmuchcredibilitytothetestedmodelsastheresultswillhavebeenconfirmedonseveralrobotplatforms. Webelievethatthecurrentstate-of-the-artinrobotprogrammingisanalogoustotheeraofearlydigitalcomputerswheneachmanufacturersupporteddifferentarchitecturesandprogramminglanguages.Regardlessofwhetheracomputerisconnectedtoanink-jetprinteroralaserprinter,acomputertodayiscapableofprintingonanyprinterdevicebecausedevicedriversareinte-gratedintothesystem.Similarly,weoughttostriveforintegrateddevicesonrobots.Obviouslywe’renotthereyet.Ourattemptsatdiscoveringusefulabstractionsareafirstandpromisingstepinthisdirection.Webelievethatdiscoveriesofgenericrobotabstractionswill,inthelongrun,leadtoamuchmorewidespreaduseofrobotsineducationandwillprovideaccesstorobotstoanevenwiderrangeofstudents. Acknowledgments Pyrosourcecode,documentationandtutorialsareavail-ableatwww.PyroRobotics.org.ThisworkisfundedinpartbyNSFCCLIGrantDUE0231363. References Beer,R.D.;Chiel,H.J.;andDrushel,R.F.1999.Us-ingAutonomousRoboticstoTeachScienceandEngi-neering.CommunicationsoftheACM. Blank,D.;Meeden,L.;andKumar,D.2003.Pythonrobotics:anenvironmentforexploringroboticsbe-yondlegos.InProceedingsofthe34thSIGCSEtechni-calsymposiumonComputerscienceeducation,317–321.ACMPress. Gallagher,J.C.,andPerretta,S.2002.WWWAu-tonomousRobotics:EnablingWideAreaAccesstoaComputerEngineeringPracticum.ProceedingsoftheThirty-thirdSIGCSETechnicalSymposiumonCom-puterScienceEducation34(1):13–17. Harlan,R.M.;Levine,D.B.;andMcClarigan,S.2001.TheKheperaRobotandthekRobotClass:APlatformforIntroducingRoboticsintheUndergrad-uateCurriculum.ProceedingsoftheThirty-secondSIGCSETechnicalSymposiumonComputerScienceEducation33(1):105–109. Klassner,F.2002.ACaseStudyofLEGOMindstormsSuitabilityforArtificialIntelligenceandRoboticsCoursesattheCollegeLevel.ProceedingsoftheThirty-thirdSIGCSETechnicalSymposiumonCom-puterScienceEducation34(1):8–12. Kumar,D.,andMeeden,L.1998.ARobotLabora-toryforTeachingArtificialIntelligence.ProceedingsoftheTwenty-ninthSIGCSETechnicalSymposiumonComputerScienceEducation30(1). Meeden,L.1996.UsingRobotsAsIntroductiontoComputerScience.InStewman,J.H.,ed.,Proceed-ingsoftheNinthFloridaArtificialIntelligenceRe-searchSymposium(FLAIRS),473–477.FloridaAIRe-searchSociety. RichardE.Pattis.1981.KareltheRobot.JohnWileyandSons,Inc. Turner,C.;Ford,K.;Dobbs,S.;andSuri,N.1996.Robotsintheclassroom.InStewman,J.H.,ed.,Pro-ceedingsoftheNinthFloridaArtificialIntelligenceResearchSymposium(FLAIRS),497–500.FloridaAIResearchSociety. Wolz,U.2001.TeachingDesignandProjectMan-agementwithLEGORCXRobots.ProceedingsoftheThirty-secondSIGCSETechnicalSymposiumonCom-puterScienceEducation33(1):95–99. 因篇幅问题不能全部显示,请点此查看更多更全内容