squaring or aligning on a line - stemrobotics | stem...
TRANSCRIPT
ì Learnhowtogetyourrobottosquareup(straightenout)whenitcomestoaline
ì Learnhowsquaring(alsoknownasaligningonaline)canhelptherobotnavigate
ì Learnhowtoimproveinitialcodeforaligningbyrepeatingatechnique
ì PracticecreatingausefulMyBlock
ì Prerequisites:MyBlockswithInputs&Outputs,DataWires,ParallelBeams,ParallelBeamsSynchronization
©2015EV3Lessons.com,Lastedit11/04/2015 2
LessonObjectives
ì MoveSteeringletsyoucontrolbothmotorsatthesametime
ì Whatifyouwanttomoveorstoponemotoratatime?ì UsetheLargeMotorBlock
©2015EV3Lessons.com,Lastedit11/04/2015 3
Review:MotorMovements
LargeMotorBlock LargemotorblockinONmode/OFFmode
ì Aligningonalinehelpstherobotnavigateì Robotsgetangledastheytravelfartheror
turn(theerroraccumulates)ì Aligningonalinecanstraightenoutarobot.ì Aligningcantellarobotwhereitiswhenit
hastotravelfar
ì ExampleGoal:YourrobotmustdeliveranobjectonlyinsideasmallENDarea.Thedistancebetweenstartandendis8feetì Doyouthinkyourrobotcantravel8feetand
continuetobestraight?
©2015EV3Lessons.com,Lastedit11/04/2015 4
WhyAlignonaLine?
Start
8ft
Challenge:Maketherobotstraightenout(align/squareup)
©2015EV3Lessons.com,Lastedit11/04/2015 5
ThreeEasyStepstoAlign
STEP1:Startbothmotors
STEP2:Stoponemotorwhenthesensoronthecorrespondingsideseestheline
STEP3:Stopmovingthesecondmotorwhenthesensoronthatsideseestheline
Hints:UseaLargeMotorBlock,UseParallelBeams,UsetheLargeMotorBlock (Thisslideisanimated)
©2015EV3Lessons.com,Lastedit11/04/2015 7
NotesAboutOurSolution:
ì Oursolutionuses2ColorSensors(connectedinPorts1and4).
ì Oursolutionassumesthatthecolorsensoronport1isnexttothewheelonmotorportBandcolorsensoronport4isnexttothewheelonmotorportC.
ì Youshouldadjusttheportsasneeded
ì YourcolorsensorsshouldNOTbeplacedrightnexttoeachother(Seeredboxesbelowinrobotimage.Thesearethecolorsensors.)
ì Whenyouhavetwoormorebeamsyoudonotknowwheneachbeamwillfinish.
ì Ifyouwantedtomoveafterthealignfinishesyoumighttrytoaddamoveblockattheendofoneofthebeams.ì Note:ThiswillnotworkbecauseEV3codewillplayyourmoveblock
withoutwaitingfortheotherbeamtofinish.ì Solution:Youneedtosynchronizeyourbeams.Tolearnmoreabout
synchronizationandsolutionsgototheAdvancedEV3Lessons.comLessononSyncBeams:PPTX, PDF ,EV3Code
ì TheproblemofsynchronizationcanalsobesolvedbymakingaMyBlockoutofthealigncode.ì MyBlocksalwayswaitforbothbeamstofinishbeforeexiting
©2015EV3Lessons.com,Lastedit11/04/2015 9
Note:Synchronization&ParallelBeams
ì Whatdoyounoticeaboutthesolutionwejustpresented?ì Therobotisn’tquitestraight(aligned)attheendofit.ì Bothcolorsensorsareontheline,buttherobotstopsatan
angle.
ì ChallengeContinued:Thinkabouthowyoucanimprovethiscodesothattherobotendsstraighterì Hint:Canyourepeatthelastprocessbylookingforwhite?ì Thisassumesthattheblacklinewewerestraighteningoutonhas
whiteonbothsides.
©2015EV3Lessons.com,Lastedit11/04/2015 10
ImprovingYourAlignCode
©2015EV3Lessons.com,Lastedit11/04/2015 11
ImprovedSolution:CreateaMyBlock
A
A. HighlightalltheblocksthengotoMyBlockBuilder
B. Add2inputs:oneforpowerandoneforcolor
RefertotheMyBlockswithInputs&OutputslessonifyouneedhelpsettinguptheMyBlock
B
C.Wiretheinputsinthegreyblock.ThecolorinputconnectstoboththecolorinputinbothWaitBlocks.ThepowervaluegoesintothepowerinputinbothMoveSteeringBlocks.
©2015EV3Lessons.com,Lastedit11/04/2015 12
ImprovedSolution:WireMyBlock
ì Youwillgetbetterresultsì ….ifyourcolorsensorsareabout1cmfromthegroundì ….ifyoushieldyourcolorsensorsì ….ifyoudon’tcomeatthelineatsteepanglesì ….ifyoukeepyourcolorsensorsspreadapart
©2015EV3Lessons.com,Lastedit11/04/2015 14
TipsforSuccess
1. WhatdoesAligningonaLine/Squaringmean?Ans.Itmeanswhenyourrobotcomesatanangle,itcanusealinetostraightenout
2. WhydoesSquaringhelpwhenyoutravellongdistances?Ans.Robotsdonotmoveaccurately/straight.Squaringcanhelpyouknowwhereyouareandstraightenout.
3. Whymightitbeusefultorepeatthealignmentprocessmultipletimes?Ans.Yourrobotwillgetstraightereachtimeyourepeat
©2015EV3Lessons.com,Lastedit11/04/2015 15
DiscussionGuide
ì ThistutorialwascreatedbySanjaySeshanandArvindSeshanfromDroidsRobotics.ì Author’sEmail:[email protected]
ì Morelessonsatwww.ev3lessons.com
©2015EV3Lessons.com,Lastedit11/04/2015 16
Credits
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.