SlideShare a Scribd company logo
1 of 17
Download to read offline
ADVANCED EV3
PROGRAMMING LESSON
Line Followers: Basic to PID
By Sanjay and Arvind Seshan
ì Evaluate and compare different line followers
ì Prerequisites: Complete all Line Follower lessons on
EV3Lessons.com, Calibration
ì Videos will not play in PDF
© 2019 EV3Lessons.com, Last edit 7/19/2019 2
Lesson Objectives
© 2019 EV3Lessons.com, Last edit 7/19/2019 3
Which Program Works Best for Which
Situation?
Smooth Line Follower
• Almost the same as simple
• Turns are less sharp
• Has trouble on sharp curves
• Good for rookie teams à need to know
loops and switches
Simple Line Follower
• Most basic line follower
• Wiggles a lot due to sharp turns
• Good for rookie teams à need to
know loops and switches
Proportional Follower
• Uses the “P” in PID
• Makes proportional turns
• Works well on both straight and curved
lines
• Good for intermediate to advanced
teams à need to know math blocks and
data wires
3-Stage Follower
• Best for straight lines
• Droids do not recommend this.
Just learn the proportional line
follower.
• Need to know nested switches
Watch the videos on the next 2 slides to see all four.
© 2019 EV3Lessons.com, Last edit 7/19/2019 4
Curved Line: Watch Videos
Smooth Line Follower
Simple Line Follower
Proportional Follower
3-Stage Follower
Straight Line: Watch Videos
© 2019 EV3Lessons.com, Last edit 7/19/2019 5
Smooth Line Follower
Simple Line Follower
Proportional Follower
3-Stage Follower
© 2019 EV3Lessons.com, Last edit 7/19/2019 6
Watch Videos
Proportional Follower PID Follower
ì Challenge 1: Can you write a simple line follower? Hint: Review
Beginner: Basic Line Follower lesson
ì Challenge 2: Can you write a smoother line follower? Hint:
Change how sharp the turns are in a simple line follower.
ì Challenge 3: Can you write a three-stage line follower where
the robot moves different 3 different ways (left, right or
straight) based on the reading from the color sensor?
© 2019 EV3Lessons.com, Last edit 7/19/2019 7
3 Line Follower Challenges
ì CALIBRATE:
ì The programs use the EV3 Color Sensor in Light Sensor mode
ì You will have to calibrate your sensors.
ì Please refer to Intermediate: Color Sensor Calibration Lesson
ì PORTS:
ì The Color Sensor is connected to Port 3.
ì Please change this for your robot.
ì WHICH SIDE OF THE LINE:
ì Please take note of which side of the line the code is written for
© 2019 EV3Lessons.com, Last edit 7/19/2019 8
A Note About Our Solutions
Simple Line Follower
© 2019 EV3Lessons.com, Last edit 7/19/2019 9
Smooth Line Follower
© 2019 EV3Lessons.com, Last edit 7/19/2019 10
Three-Stage Line Follower
© 2019 EV3Lessons.com, Last edit 7/19/2019 11
Can you write a proportional line follower that changes the angle of the turn
depending on how far away from the line the robot is?
Pseudocode:
1. Reset the Rotation sensor (Only required for line following for a total
distance)
2. Compute the error = Distance from line = (Light sensor reading – Target
Reading)
3. Scale the error to determine a correction amount. Adjust your scaling factor
to make you robot follow the line more smoothly.
4. Use the Correction value (computer in Step 3) to adjust the robot’s turn
towards the line.
© 2019 EV3Lessons.com, Last edit 7/19/2019 12
Proportional Pseudocode
© 2019 EV3Lessons.com, Last edit 7/19/2019 13
Proportional Line Follower
Note: This program uses the color sensor in
reflected light mode. You will need to
calibrate your color sensor. If you do not know
how to calibrate, please refer to our
Calibration lesson.
Part 1: Compute the Error
Our goal is to stay at the edge of
the line (light sensor = 50)
Part 2: Apply the correction
The error in part 1 is multiplied by
a Constant of Proportionality
(0.7). This will be different for
each robot/application. See slides
9-11 to learn how to tune this
number.
This line follower
ends after 1000
degrees. Change
this to suit your
needs.
Reset
the
rotation
sensor
Please refer to Proportional Control Lesson
for more details
1. Take a new light sensor reading
2. Compute the “error”
3. Scale error to determine contribution to steering update (proportional control)
4. Use error to update integral (sum of all past errors)
5. Scale integral to determine contribution to steering update (integral control)
6. Use error to update derivative (difference from last error)
7. Scale derivative to determine contribution to steering update (derivative control)
8. Combine P, I, and D feedback and steer robot
© 2019 EV3Lessons.com, Last edit 7/19/2019 14
PID Pseudocode
© 2019 EV3Lessons.com, Last edit 07/10/2019 15
PID Code
Proportional Integral
Derivative Putting it all Together
Set up the variables for
the last error and integral
before the loop and
initialize to 0 because
they are read before
being written.
Code has been
split for
readability.
Continues below.
Refer to PID lesson for more
details
Evaluating Line followers
Proportional
ì Uses the “P” in PID
ì Makes proportional turns
ì Works well on both straight
and curved lines
ì Good for intermediate to
advanced teams à need to
know math blocks and data
wires
PID
ì It is better than proportional
control on a very curved line,
as the robot adapts to the
curviness
ì However, for FIRST LEGO
League, which mostly has
straight lines, proportional
control can be sufficient
© 2019 EV3Lessons.com, Last edit 7/19/2019 16
ì This tutorial was created by Sanjay Seshan and Arvind Seshan
ì More lessons at www.ev3lessons.com
© 2019 EV3Lessons.com, Last edit 7/19/2019 17
Credits
This work is licensed under a Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International License.

More Related Content

Similar to LineFollower.pdf

PC Based DC Motor Speed Control using PID for Laboratory
PC Based DC Motor Speed Control using PID for LaboratoryPC Based DC Motor Speed Control using PID for Laboratory
PC Based DC Motor Speed Control using PID for Laboratoryijtsrd
 
IRJET- Designing of a Portable Hemoglobinometer using Raspberry Pi
IRJET- Designing of a Portable Hemoglobinometer using Raspberry PiIRJET- Designing of a Portable Hemoglobinometer using Raspberry Pi
IRJET- Designing of a Portable Hemoglobinometer using Raspberry PiIRJET Journal
 
Dish Positioning By Using IR Remote
Dish Positioning By Using IR RemoteDish Positioning By Using IR Remote
Dish Positioning By Using IR RemoteIRJET Journal
 
IRJET- Auto Range Resistor Sorter
IRJET- Auto Range Resistor SorterIRJET- Auto Range Resistor Sorter
IRJET- Auto Range Resistor SorterIRJET Journal
 
IRJET- Autonomous Floor Cleaning BOT
IRJET- 	  Autonomous Floor Cleaning BOTIRJET- 	  Autonomous Floor Cleaning BOT
IRJET- Autonomous Floor Cleaning BOTIRJET Journal
 
IRJET - Mobile Application Testing and Report Generation using Image Proc...
IRJET -  	  Mobile Application Testing and Report Generation using Image Proc...IRJET -  	  Mobile Application Testing and Report Generation using Image Proc...
IRJET - Mobile Application Testing and Report Generation using Image Proc...IRJET Journal
 
IRJET- Study of Emg Sensor based Servo Motor Position Control
IRJET-  	  Study of Emg Sensor based Servo Motor Position ControlIRJET-  	  Study of Emg Sensor based Servo Motor Position Control
IRJET- Study of Emg Sensor based Servo Motor Position ControlIRJET Journal
 
Android application for driver assistance using strain guage load cell and mo...
Android application for driver assistance using strain guage load cell and mo...Android application for driver assistance using strain guage load cell and mo...
Android application for driver assistance using strain guage load cell and mo...IJARIIT
 
A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...
A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...
A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...IOSR Journals
 
IRJET- Smart Glasses Multimeter
IRJET- Smart Glasses MultimeterIRJET- Smart Glasses Multimeter
IRJET- Smart Glasses MultimeterIRJET Journal
 
IRJET- A Unique Methodology for Transmission Line Breakage Detection and ...
IRJET-  	  A Unique Methodology for Transmission Line Breakage Detection and ...IRJET-  	  A Unique Methodology for Transmission Line Breakage Detection and ...
IRJET- A Unique Methodology for Transmission Line Breakage Detection and ...IRJET Journal
 
IRJET- Braille Oriented Classroom
IRJET-  	  Braille Oriented ClassroomIRJET-  	  Braille Oriented Classroom
IRJET- Braille Oriented ClassroomIRJET Journal
 
IRJET- Implementation of TPG-LFSR with Reseeding Pattern Value
IRJET-  	  Implementation of TPG-LFSR with Reseeding Pattern ValueIRJET-  	  Implementation of TPG-LFSR with Reseeding Pattern Value
IRJET- Implementation of TPG-LFSR with Reseeding Pattern ValueIRJET Journal
 
Hill Top Braking System in Electronic Bikes
Hill Top Braking System in Electronic BikesHill Top Braking System in Electronic Bikes
Hill Top Braking System in Electronic BikesIRJET Journal
 
IRJET- Design and Simulation of Comparator Architectures for Various ADC ...
IRJET-  	  Design and Simulation of Comparator Architectures for Various ADC ...IRJET-  	  Design and Simulation of Comparator Architectures for Various ADC ...
IRJET- Design and Simulation of Comparator Architectures for Various ADC ...IRJET Journal
 
IRJET- Improvising Reliability of Autonomous Car using Risk Detection
IRJET-  	  Improvising Reliability of Autonomous Car using Risk DetectionIRJET-  	  Improvising Reliability of Autonomous Car using Risk Detection
IRJET- Improvising Reliability of Autonomous Car using Risk DetectionIRJET Journal
 
IRJET - Approximate Unsigned Multiplier with Varied Error Rate
IRJET - Approximate Unsigned Multiplier with Varied Error RateIRJET - Approximate Unsigned Multiplier with Varied Error Rate
IRJET - Approximate Unsigned Multiplier with Varied Error RateIRJET Journal
 
IRJET- Robo Supporting Human Leg
IRJET-  	  Robo Supporting Human LegIRJET-  	  Robo Supporting Human Leg
IRJET- Robo Supporting Human LegIRJET Journal
 

Similar to LineFollower.pdf (20)

PC Based DC Motor Speed Control using PID for Laboratory
PC Based DC Motor Speed Control using PID for LaboratoryPC Based DC Motor Speed Control using PID for Laboratory
PC Based DC Motor Speed Control using PID for Laboratory
 
IRJET- Designing of a Portable Hemoglobinometer using Raspberry Pi
IRJET- Designing of a Portable Hemoglobinometer using Raspberry PiIRJET- Designing of a Portable Hemoglobinometer using Raspberry Pi
IRJET- Designing of a Portable Hemoglobinometer using Raspberry Pi
 
Dish Positioning By Using IR Remote
Dish Positioning By Using IR RemoteDish Positioning By Using IR Remote
Dish Positioning By Using IR Remote
 
IRJET- Auto Range Resistor Sorter
IRJET- Auto Range Resistor SorterIRJET- Auto Range Resistor Sorter
IRJET- Auto Range Resistor Sorter
 
IRJET- Autonomous Floor Cleaning BOT
IRJET- 	  Autonomous Floor Cleaning BOTIRJET- 	  Autonomous Floor Cleaning BOT
IRJET- Autonomous Floor Cleaning BOT
 
IRJET - Mobile Application Testing and Report Generation using Image Proc...
IRJET -  	  Mobile Application Testing and Report Generation using Image Proc...IRJET -  	  Mobile Application Testing and Report Generation using Image Proc...
IRJET - Mobile Application Testing and Report Generation using Image Proc...
 
IRJET- Study of Emg Sensor based Servo Motor Position Control
IRJET-  	  Study of Emg Sensor based Servo Motor Position ControlIRJET-  	  Study of Emg Sensor based Servo Motor Position Control
IRJET- Study of Emg Sensor based Servo Motor Position Control
 
Android application for driver assistance using strain guage load cell and mo...
Android application for driver assistance using strain guage load cell and mo...Android application for driver assistance using strain guage load cell and mo...
Android application for driver assistance using strain guage load cell and mo...
 
A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...
A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...
A Proportional-Integral-Derivative Control Scheme of Mobile Robotic platforms...
 
IRJET- Smart Glasses Multimeter
IRJET- Smart Glasses MultimeterIRJET- Smart Glasses Multimeter
IRJET- Smart Glasses Multimeter
 
Comparators
ComparatorsComparators
Comparators
 
IRJET- A Unique Methodology for Transmission Line Breakage Detection and ...
IRJET-  	  A Unique Methodology for Transmission Line Breakage Detection and ...IRJET-  	  A Unique Methodology for Transmission Line Breakage Detection and ...
IRJET- A Unique Methodology for Transmission Line Breakage Detection and ...
 
IRJET- Braille Oriented Classroom
IRJET-  	  Braille Oriented ClassroomIRJET-  	  Braille Oriented Classroom
IRJET- Braille Oriented Classroom
 
IRJET- Implementation of TPG-LFSR with Reseeding Pattern Value
IRJET-  	  Implementation of TPG-LFSR with Reseeding Pattern ValueIRJET-  	  Implementation of TPG-LFSR with Reseeding Pattern Value
IRJET- Implementation of TPG-LFSR with Reseeding Pattern Value
 
NewMetricsforCCTV_edited
NewMetricsforCCTV_editedNewMetricsforCCTV_edited
NewMetricsforCCTV_edited
 
Hill Top Braking System in Electronic Bikes
Hill Top Braking System in Electronic BikesHill Top Braking System in Electronic Bikes
Hill Top Braking System in Electronic Bikes
 
IRJET- Design and Simulation of Comparator Architectures for Various ADC ...
IRJET-  	  Design and Simulation of Comparator Architectures for Various ADC ...IRJET-  	  Design and Simulation of Comparator Architectures for Various ADC ...
IRJET- Design and Simulation of Comparator Architectures for Various ADC ...
 
IRJET- Improvising Reliability of Autonomous Car using Risk Detection
IRJET-  	  Improvising Reliability of Autonomous Car using Risk DetectionIRJET-  	  Improvising Reliability of Autonomous Car using Risk Detection
IRJET- Improvising Reliability of Autonomous Car using Risk Detection
 
IRJET - Approximate Unsigned Multiplier with Varied Error Rate
IRJET - Approximate Unsigned Multiplier with Varied Error RateIRJET - Approximate Unsigned Multiplier with Varied Error Rate
IRJET - Approximate Unsigned Multiplier with Varied Error Rate
 
IRJET- Robo Supporting Human Leg
IRJET-  	  Robo Supporting Human LegIRJET-  	  Robo Supporting Human Leg
IRJET- Robo Supporting Human Leg
 

Recently uploaded

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

LineFollower.pdf

  • 1. ADVANCED EV3 PROGRAMMING LESSON Line Followers: Basic to PID By Sanjay and Arvind Seshan
  • 2. ì Evaluate and compare different line followers ì Prerequisites: Complete all Line Follower lessons on EV3Lessons.com, Calibration ì Videos will not play in PDF © 2019 EV3Lessons.com, Last edit 7/19/2019 2 Lesson Objectives
  • 3. © 2019 EV3Lessons.com, Last edit 7/19/2019 3 Which Program Works Best for Which Situation? Smooth Line Follower • Almost the same as simple • Turns are less sharp • Has trouble on sharp curves • Good for rookie teams à need to know loops and switches Simple Line Follower • Most basic line follower • Wiggles a lot due to sharp turns • Good for rookie teams à need to know loops and switches Proportional Follower • Uses the “P” in PID • Makes proportional turns • Works well on both straight and curved lines • Good for intermediate to advanced teams à need to know math blocks and data wires 3-Stage Follower • Best for straight lines • Droids do not recommend this. Just learn the proportional line follower. • Need to know nested switches Watch the videos on the next 2 slides to see all four.
  • 4. © 2019 EV3Lessons.com, Last edit 7/19/2019 4 Curved Line: Watch Videos Smooth Line Follower Simple Line Follower Proportional Follower 3-Stage Follower
  • 5. Straight Line: Watch Videos © 2019 EV3Lessons.com, Last edit 7/19/2019 5 Smooth Line Follower Simple Line Follower Proportional Follower 3-Stage Follower
  • 6. © 2019 EV3Lessons.com, Last edit 7/19/2019 6 Watch Videos Proportional Follower PID Follower
  • 7. ì Challenge 1: Can you write a simple line follower? Hint: Review Beginner: Basic Line Follower lesson ì Challenge 2: Can you write a smoother line follower? Hint: Change how sharp the turns are in a simple line follower. ì Challenge 3: Can you write a three-stage line follower where the robot moves different 3 different ways (left, right or straight) based on the reading from the color sensor? © 2019 EV3Lessons.com, Last edit 7/19/2019 7 3 Line Follower Challenges
  • 8. ì CALIBRATE: ì The programs use the EV3 Color Sensor in Light Sensor mode ì You will have to calibrate your sensors. ì Please refer to Intermediate: Color Sensor Calibration Lesson ì PORTS: ì The Color Sensor is connected to Port 3. ì Please change this for your robot. ì WHICH SIDE OF THE LINE: ì Please take note of which side of the line the code is written for © 2019 EV3Lessons.com, Last edit 7/19/2019 8 A Note About Our Solutions
  • 9. Simple Line Follower © 2019 EV3Lessons.com, Last edit 7/19/2019 9
  • 10. Smooth Line Follower © 2019 EV3Lessons.com, Last edit 7/19/2019 10
  • 11. Three-Stage Line Follower © 2019 EV3Lessons.com, Last edit 7/19/2019 11
  • 12. Can you write a proportional line follower that changes the angle of the turn depending on how far away from the line the robot is? Pseudocode: 1. Reset the Rotation sensor (Only required for line following for a total distance) 2. Compute the error = Distance from line = (Light sensor reading – Target Reading) 3. Scale the error to determine a correction amount. Adjust your scaling factor to make you robot follow the line more smoothly. 4. Use the Correction value (computer in Step 3) to adjust the robot’s turn towards the line. © 2019 EV3Lessons.com, Last edit 7/19/2019 12 Proportional Pseudocode
  • 13. © 2019 EV3Lessons.com, Last edit 7/19/2019 13 Proportional Line Follower Note: This program uses the color sensor in reflected light mode. You will need to calibrate your color sensor. If you do not know how to calibrate, please refer to our Calibration lesson. Part 1: Compute the Error Our goal is to stay at the edge of the line (light sensor = 50) Part 2: Apply the correction The error in part 1 is multiplied by a Constant of Proportionality (0.7). This will be different for each robot/application. See slides 9-11 to learn how to tune this number. This line follower ends after 1000 degrees. Change this to suit your needs. Reset the rotation sensor Please refer to Proportional Control Lesson for more details
  • 14. 1. Take a new light sensor reading 2. Compute the “error” 3. Scale error to determine contribution to steering update (proportional control) 4. Use error to update integral (sum of all past errors) 5. Scale integral to determine contribution to steering update (integral control) 6. Use error to update derivative (difference from last error) 7. Scale derivative to determine contribution to steering update (derivative control) 8. Combine P, I, and D feedback and steer robot © 2019 EV3Lessons.com, Last edit 7/19/2019 14 PID Pseudocode
  • 15. © 2019 EV3Lessons.com, Last edit 07/10/2019 15 PID Code Proportional Integral Derivative Putting it all Together Set up the variables for the last error and integral before the loop and initialize to 0 because they are read before being written. Code has been split for readability. Continues below. Refer to PID lesson for more details
  • 16. Evaluating Line followers Proportional ì Uses the “P” in PID ì Makes proportional turns ì Works well on both straight and curved lines ì Good for intermediate to advanced teams à need to know math blocks and data wires PID ì It is better than proportional control on a very curved line, as the robot adapts to the curviness ì However, for FIRST LEGO League, which mostly has straight lines, proportional control can be sufficient © 2019 EV3Lessons.com, Last edit 7/19/2019 16
  • 17. ì This tutorial was created by Sanjay Seshan and Arvind Seshan ì More lessons at www.ev3lessons.com © 2019 EV3Lessons.com, Last edit 7/19/2019 17 Credits This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License.