gyro turns - ev3 lessons · 3. direction (the first input) defines: • 0 –check if the value has...
TRANSCRIPT
ADVANCEDEV3PROGRAMMINGLESSON
GyroTurnsBySanjayandArvindSeshan
©2016EV3Lessons.com,Lastedit7/19/2016 1
1. LearnwhatGyroLagis
2. Learnonewaytocorrectforthislag
3. Understandwhyitisimportanttoexplorealternativesolutionstoaproblem
ì Pre-requisites:MyBlockswithInputsandOutputs,Datawires,MathBlocks,Loops
©2016EV3Lessons.com,Lastedit7/19/2016 2
LessonObjectives
ì Whatislag?ì Thegyrosensorreadingslagbehindthetruevaluesometimes
ì Whentheturnstarts,ittakestimeforthegyrotobeginchanging
ì Thislessonpresentsonewaytodealwithlaginaturn: reducetheamountofanglethatyouturntocompensateforlag
©2016EV3Lessons.com,Lastedit7/19/2016 3
GyroProblem2:Lag
©2016EV3Lessons.com,Lastedit7/19/2016 4
ChangeModeinWaitBlock
1. InthislessonweusetheWaitBlock(gyrosensor)inChangeMode
2. AdvantagesoverCompareMode:• Youdonotneedtoresetthegyrobeforehand• Youcanmeasureifthevaluehaschangedthe
targetdegreesbybothdecreasingorincreasing(noneedtochangethewaitblockforaleftturn)
3. Direction(thefirstinput)defines:• 0– checkifthevaluehasincreasedthedesired
degrees• 1– checkifthevaluehasdecreasedthedesired
degrees• 2– checkifthevaluehaseitherincreasedor
decreasedthedesireddegrees
STEP1:CreateasimpleGyroTurnprogramthatturns90degreesusingtheWaitforGyroblockinChangeMode
Remember toCalibrate theGyrobeforetheWaitForBlock(seeGyroLessonforhelp)
STEP2:CompensateforLag
A. Compensateforthelagbyreducingtheamountofangletoturnbasedonyourrobot(e.g 86degreesinsteadof90degrees)
B. UseaMathBlocktocreateanautomaticcalculatortocompensateforlag
STEP3:CreateandWiretheMyBlock
STEP4:RepeatthestepstomakeoneforLeftTurnsvs.oneforRightTurns.
©2016EV3Lessons.com,Lastedit7/19/2016 5
GyroTurninFourEasySteps
©2016EV3Lessons.com,Lastedit7/19/2016 6
Step1:SimpleGyroTurn
©2016EV3Lessons.com,Lastedit7/19/2016 7
Step2A:DealingwithLag
©2016EV3Lessons.com,Lastedit7/19/2016 8
Step2B:AutomaticallyCorrectforLag
©2016EV3Lessons.com,Lastedit7/19/2016 9
Step3A:CreateaMyBlock
A. HighlightalltheblocksthengotoMyBlockBuilder
B. Add2inputs:oneforpowerandoneforanddegrees
RefertotheMyBlockswithInputs&OutputslessonifyouneedhelpsettinguptheMyBlock
B
A
©2016EV3Lessons.com,Lastedit7/19/2016 10
Stage3B:WiretheMyBlock
degrees
power
Connectthedegreesvalueintothemathblockandthepowerintothemovesteeringblock
©2016EV3Lessons.com,Lastedit7/19/2016 11
Stage4:UsingtheMyBlock
©2016EV3Lessons.com,Lastedit7/19/2016 12
Step4:TurnDegreesRight
©2016EV3Lessons.com,Lastedit7/19/2016 13
Step4:TurnDegreesLeft
ì Whatisgyrolag?Ans.Thegyrosensor’sreadinglagsbehindthetruereading
ì Whatisonewaytocompensateforlag?Ans:Reducethenumberofdegreesthatyouturn
©2016EV3Lessons.com,Lastedit7/19/2016 14
Discussion
ì ThistutorialwaswrittenbySanjaySeshan andArvindSeshan
ì Morelessonsatwww.ev3lessons.com
©2016EV3Lessons.com,Lastedit7/19/2016 15
Credits
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.