+ All Categories
Home > Documents > Squaring or Aligning on a Line - EV3Lessons.com | by...

Squaring or Aligning on a Line - EV3Lessons.com | by...

Date post: 24-Apr-2018
Category:
Upload: vuongthuan
View: 222 times
Download: 4 times
Share this document with a friend
12
ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay and Arvind Seshan
Transcript
Page 1: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

ADVANCEDEV3PROGRAMMINGLESSON

SquaringorAligningonaLineBySanjayandArvindSeshan

Page 2: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

ì 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 - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

ì MoveSteeringletsyoucontrolbothmotorsatthesametime

ì Whatifyouwanttomoveorstoponemotoratatime?ì UsetheLargeMotorBlock

©2016EV3Lessons.com,Lastedit06/19/2016

Review:MotorMovements

LargeMotorBlock LargemotorblockinONmode/OFFmode

Page 4: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

ì 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 - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

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 - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

©2016EV3Lessons.com,Lastedit06/19/2016

WhatAligningShouldLookLike

Page 7: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

©2016EV3Lessons.com,Lastedit06/19/2016

NotesAboutOurSolution:

ì Oursolutionuses2ColorSensors(connectedinPorts1and4).

ì Oursolutionassumesthatthecolorsensoronport1isnexttothewheelonmotorportBandcolorsensoronport4isnexttothewheelonmotorportC.

ì Youshouldadjusttheportsasneeded

ì YourcolorsensorsshouldNOTbeplacedrightnexttoeachother(Seeredboxesbelowinrobotimage.Thesearethecolorsensors.)

Page 8: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

©2016EV3Lessons.com,Lastedit06/19/2016

BasicSolution:MovingUntilLine

Page 9: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

ì 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 - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

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

angle.

ì ChallengeContinued:Thinkabouthowyoucanimprovethiscodesothattherobotendsstraighter

©2016EV3Lessons.com,Lastedit06/19/2016

ImprovingYourAlignCode

Page 11: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

ì Youwillgetbetterresultsì ….ifyourcolorsensorsareabout4mm-12mmfromtheground

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

©2016EV3Lessons.com,Lastedit06/19/2016

TipsforSuccess

Page 12: Squaring or Aligning on a Line - EV3Lessons.com | by ...ev3lessons.com/translations/en-us/advanced/Align.pdf · ADVANCED EV3 PROGRAMMING LESSON Squaring or Aligning on a Line By Sanjay

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


Recommended