Top Banner
ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay and Arvind Seshan
12

Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

May 31, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ADVANCEDEV3PROGRAMMINGLESSON

SquaringorAligningonaLineBySanjayandArvindSeshan

Page 2: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì Learnhowtogetyourrobottosquareup(straightenout)whenitcomestoaline

ì Learnhowsquaring(alsoknownasaligningonaline)canhelptherobotnavigate

ì Learnhowtoimproveinitialcodeforaligningbyrepeatingatechnique

ì PracticecreatingausefulMyBlock

ì Prerequisites:MyBlockswithInputs&Outputs,DataWires,ParallelBeams,ParallelBeamsSynchronization

©2016EV3Lessons.com,Lastedit06/19/2016

LessonObjectives

Page 3: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì MoveSteeringletsyoucontrolbothmotorsatthesametime

ì Whatifyouwanttomoveorstoponemotoratatime?ì UsetheLargeMotorBlock

©2016EV3Lessons.com,Lastedit06/19/2016

Review:MotorMovements

LargeMotorBlock LargemotorblockinONmode/OFFmode

Page 4: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì Aligningonalinehelpstherobotnavigateì Robotsgetangledastheytravelfartheror

turn(theerroraccumulates)ì Aligningonalinecanstraightenoutarobot.ì Aligningcantellarobotwhereitiswhenit

hastotravelfar

ì ExampleGoal:YourrobotmustdeliveranobjectonlyinsideasmallENDarea.Thedistancebetweenstartandendis8feetì Doyouthinkyourrobotcantravel8feetand

continuetobestraight?

©2016EV3Lessons.com,Lastedit06/19/2016

WhyAlignonaLine?

Start

8ft

Page 5: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

Challenge:Maketherobotstraightenout(align/squareup)

©2016EV3Lessons.com,Lastedit06/19/2016

ThreeEasyStepstoAlign

STEP1:Startbothmotors

STEP2:Stoponemotorwhenthesensoronthecorrespondingsideseestheline

STEP3:Stopmovingthesecondmotorwhenthesensoronthatsideseestheline

Hints:UseaLargeMotorBlock,UseParallelBeams,UsetheLargeMotorBlock (Thisslideisanimated)

Page 6: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

©2016EV3Lessons.com,Lastedit06/19/2016

WhatAligningShouldLookLike

Page 7: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

©2016EV3Lessons.com,Lastedit06/19/2016

NotesAboutOurSolution:

ì Oursolutionuses2ColorSensors(connectedinPorts1and4).

ì Oursolutionassumesthatthecolorsensoronport1isnexttothewheelonmotorportBandcolorsensoronport4isnexttothewheelonmotorportC.

ì Youshouldadjusttheportsasneeded

ì YourcolorsensorsshouldNOTbeplacedrightnexttoeachother(Seeredboxesbelowinrobotimage.Thesearethecolorsensors.)

Page 8: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

©2016EV3Lessons.com,Lastedit06/19/2016

BasicSolution:MovingUntilLine

Page 9: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì Whenyouhavetwoormorebeamsyoudonotknowwheneachbeamwillfinish.

ì Ifyouwantedtomoveafterthealignfinishesyoumighttrytoaddamoveblockattheendofoneofthebeams.ì Note:ThiswillnotworkbecauseEV3codewillplayyourmoveblock

withoutwaitingfortheotherbeamtofinish.ì Solution:Youneedtosynchronizeyourbeams.Tolearnmoreabout

synchronizationandsolutionsgototheAdvancedEV3Lessons.comLessononSyncBeams

ì TheproblemofsynchronizationcanalsobesolvedbymakingaMyBlockoutofthealigncode(refertoMyBlocklessoninIntermediate)ì MyBlocksalwayswaitforbothbeamstofinishbeforeexiting

©2016EV3Lessons.com,Lastedit06/19/2016

Note:Synchronization&ParallelBeams

Page 10: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì Whatdoyounoticeaboutthesolutionwejustpresented?ì Therobotisn’tquitestraight(aligned)attheendofit.ì Bothcolorsensorsareontheline,buttherobotstopsatan

angle.

ì ChallengeContinued:Thinkabouthowyoucanimprovethiscodesothattherobotendsstraighter

©2016EV3Lessons.com,Lastedit06/19/2016

ImprovingYourAlignCode

Page 11: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì Youwillgetbetterresultsì ….ifyourcolorsensorsareabout4mm-12mmfromtheground

(seeColorSensorPlacementLessoninRobotDesignLessons)ì ….ifyoudon’tcomeatthelineatsteepanglesì ….ifyoukeepyourcolorsensorsspreadapart

©2016EV3Lessons.com,Lastedit06/19/2016

TipsforSuccess

Page 12: Squaring or Aligning on a Line - EV3 Lessonsev3lessons.com/en/ProgrammingLessons/advanced/Align.pdf · 2020-02-07 · ì Learn how to get your robot to square up (straighten out)

ì ThistutorialwascreatedbySanjaySeshan andArvindSeshan

ì Morelessonsatwww.ev3lessons.com

©2016EV3Lessons.com,Lastedit06/19/2016

Credits

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.