Robotics Programming: PID Algorithm - Wall Following and Balancing

Sdílet
Vložit
  • čas přidán 4. 07. 2024
  • Today's episode of Robotics Programming is a special one, we will learn how to write a PID or Proportional, Integral and Derivative controller. In this complete guide to understanding PID we will breakdown the Mathematics, give step by step examples and see it in use! We will apply it to solve problems in robotics by showing how it can be applied to create both a wall following robot and a balancing / standing one.
    This versatile algorithm is a staple not just in robotics programming but in many engineering disciplines and is the go-to method so solve many problems. We will discuss each of the 3 components of the PID controller, there relationship to each other and the overall outcome and introduce the idea of tuning a PID controller. Using a handwritten problem and also how to implement a PID in C for Arduino helps visualize solving this problem.
    The PID algorithm can look intimidating to the uninitiated, but it is actually just 3 simple math equations summed together. Proportional is simply multiplication, Integral maintains a running total, and Derivative subtracts to obtain the difference of the error from the previous time the algorithm ran.
    Throughout this series we will be introducing topics on building and programming an autonomous mobile robot! You can follow along with each lab adding amazing new behaviors to you robot projects and learning the algorithms and tuning techniques that produce incredible robots! We will be exploring reactive algorithms such as PID, Potential Fields and A*. Along the way you will learn how to program behaviors such as object following, wall following, standing / balancing, go-to goal and object avoidance. This series is intended to allow you to follow along with your own robot.
    Code access: Direct access to source code and additional resources are available by becoming a Coding Coach supporter. You can join and learn more here: codingcoach.net/sponsor . You may also copy the code from the video as you follow along.
    This video series is meant to help anyone interested in programming robots follow along. You do not need to use the same robot as I do. Any mobile robot can run these same algorithms, you just have to tune the robot differently.
    If you missed episode 1, you can find it here: • Robotics Programming: ...
    Episode 2: • Robotics Programming: ...
    Episode 3: • Robotics Programming: ...
    Episode 4: • Robotics Programming: ...
    The next video in this series will be arriving shortly, make sure to subscribe and ring the bell to be notified when it lands!
    Playlist of the full series: • Robotics Programming Labs
    Video that discusses the future direction of the series: • Robotics Programming: ...
    Chapters:
    0:00 Introduction
    1:35 Control Systems
    4:32 How to determine Error and Magnitude
    8:25 Applying a PID Controller
    9:20 PID Overview
    11:48 Proportional
    13:30 Integral
    15:21 Derivative
    16:09 Example PID Problem
    28:09 Coding a PID
    31:45 Conclusion
    32:46 Outtakes
    #codingcoach #arduinorobot #PID
    Robot used
    Pololu 3pi+: www.pololu.com/category/280/3...
    Links to hardware: (Amazon Affiliate links)
    S90 9g Servo (10 pack): amzn.to/3tmUhGN
    Mini breadboards: amzn.to/2NeHXZA
    Jumper Wire assortment: amzn.to/3bJD6Jh
    470uf Capacitors: amzn.to/2ORqBSU
    Break-away headers: amzn.to/3cwVapl
    Other robots, batteries and tools
    Elegoo Smart Car: amzn.to/3iG3uFO
    Robot car chassis (with encoder cutout): amzn.to/3odlacY
    Pololu Zumo: amzn.to/39TbaAC
    Batteries:
    EBL Rechargeable batteries: amzn.to/3pdiM7A
    Micrometer Caliper Measuring Tool (To measure wheel diameter): amzn.to/3sQ0BqB

Komentáře • 44

  • @JasonLearmouth
    @JasonLearmouth Před 3 lety +14

    This is the best PID explanation I've seen, and I've watched at least 15 other videos on the topic. The manually worked example brought it all together for me and I now feel like I can actually implement a PID controller in code myself.

    • @CodingCoach
      @CodingCoach  Před 3 lety

      I am so glad it was helpful! Thank you for the feedback!

    • @JasonLearmouth
      @JasonLearmouth Před 3 lety +1

      @@CodingCoach No worries. BTW, do you have a GitHub repo with your pseudo code in it? I know there's not much to it, but it would be nice to have the template to start from.

    • @CodingCoach
      @CodingCoach  Před 3 lety +1

      I am actually looking at setting that up this week!

    • @CodingCoach
      @CodingCoach  Před 2 lety

      @@JasonLearmouth I set up access through a sponsorship model using GitHub sponsors. You can learn more here if you are interested: codingcoach.net/sponsor

  • @ReDoG129
    @ReDoG129 Před 4 dny

    I'm in a robotics class and I HATE MATH WITH A PASSION. But this video will come in handy. I definitely will save this to my favorites. Thanks! 😅😅😅

  • @peterkanini867
    @peterkanini867 Před 6 měsíci

    What would someone have to be doing, and how much knowledge do you need to have accumulated to come up with such a simple yet robust algorithm? Hat's off to the one who came up with it. Best explanation of the algorithm I have ever seen. My search for this explanation officially ends here. Thanks man!

  • @shivangmandvia_drat3569

    Awesome explanation on PID 👍

  • @MathComputerScienceTradi-ge7tw
    @MathComputerScienceTradi-ge7tw Před 4 měsíci +2

    Can you please make a video about when the distance from the wall is not at 90 degree angle?

  • @nilupuleeamarathunga8021
    @nilupuleeamarathunga8021 Před 10 měsíci

    Thank you. understood well

  • @kartikbaderiya7323
    @kartikbaderiya7323 Před rokem

    I appreciate u a lot for making this video. Literally watched over 50 videos to understand the concept behind PID, finally after watching this video, i can practically implement this in my robot. Thanks a lot buddy

  • @BrickRoom7
    @BrickRoom7 Před 2 lety

    I love how you explained everything about PID controllers. This is the best PID video I've seen so far. I've been looking for an explanation on how to adjust the COG of the robot when you add weight or if it runs on an incline surface. Can you advise how to code that?

  • @CAT-dm9hy
    @CAT-dm9hy Před 3 lety +1

    wow so cool

  • @athuldas44
    @athuldas44 Před 2 lety +2

    sir you are the best teacher i bet there will be no one like you who can explain this algorithm keep sharing your knowledge

  • @maryskurt
    @maryskurt Před 2 lety +1

    I hope you are able to continue this series! I check every day for a new video!!!! Thank you for all your work!

    • @CodingCoach
      @CodingCoach  Před 2 lety +1

      You are most welcome.. the series is not forgotten :)

  • @jbaisden
    @jbaisden Před 3 lety +3

    As someone who is literally trying to figure out a starting place in Robotics, I immediately liked, subscribed, and set alerts on your videos.

  • @AhmedRayyan284
    @AhmedRayyan284 Před 2 lety +1

    please are you going to continue the series ?
    that was the best one on the youtube and it is bad that it is uncomplated but thanks anyway

  • @aidendeady1513
    @aidendeady1513 Před 2 lety

    Youre a beast :)!

  • @gregormurray314
    @gregormurray314 Před rokem

    great videos, got really excited when i saw what else you were planning on doing (including potential field), been a while since there have been any new videos though, is there anything in the pipeline?

  • @brandroid2960
    @brandroid2960 Před rokem

    You are a very talented teacher. I found your lessons extremely valuable, my only disappointment is that you did not continue. I hope that you will revisit your channel, because I'm certain that you could build a large following in time.

  • @Teacher_Ali
    @Teacher_Ali Před 3 lety +2

    Great explanation - Thanks.

  • @maryskurt
    @maryskurt Před 3 lety +2

    That you!! Great Explanation!!!

  • @jonathanr4242
    @jonathanr4242 Před 2 lety +1

    Another well explained video.

  • @JukaVKcro
    @JukaVKcro Před 10 měsíci

    Very, very nice!! What do you think, is it ok to use PID regulator for line following robot? I have 4 line sensors.

  • @Minji_Hanni_Dani_Haerin_Hyein

    T1 --> 17:28
    T2 --> 19:54

  • @melvinbullock5674
    @melvinbullock5674 Před 2 lety +1

    Avidly awaiting further videos in this series! will there be another soon?

  • @AhmadShaer97
    @AhmadShaer97 Před rokem

    Where is the navigation algorithms explaintion (A*,potential field) ?

  • @commanderbensisko
    @commanderbensisko Před 2 lety +1

    Thank you for this fantastic break down.
    However, is there an error in the ki calculation of T#4 ? I arrived at 0.5*(-15+36) = 10.5

    • @CodingCoach
      @CodingCoach  Před 2 lety

      Yes, sorry one of them was off.. I have not figured out how to "post live" add text to the video other then sub-titles which are not often used. Have to take another crack at figuring it out.

  • @septianmegantara5414
    @septianmegantara5414 Před 10 měsíci

    I'm sorry, i want to ask, from this explanation about PID, can it be applied to humanoid robots?

  • @septianmegantara5414
    @septianmegantara5414 Před 9 měsíci

    i'm sorry, i want to ask you a question i want to make an open loop for my robot humanoid, but i confused about how to make the algorith can you teach me to make it?

  • @okaytree7711
    @okaytree7711 Před rokem

    What happened to the next PID video for tuning? Are you doing alright...

  • @NikeAirJordanGabes
    @NikeAirJordanGabes Před 2 lety

    How do you come up with your K values? Like say I am tuning those values, how would I know which one's to increase and decrease? I have a robot following a wall on its right using a Sharp GP2Y0A41SK0F Analog Distance Sensor.

    • @CodingCoach
      @CodingCoach  Před 2 lety +1

      It varies for every problem you're solving but a good rule of thumb is to take the plant output you are trying to affect and divide it by the range of your sensor input and the result is the multiplier to the output for Kp.. so for example if my motors have a range of zero to 400 with 400 being full speed. and my sensor gives values of 0 cm to 100 cm. I would have a 4 for my starting Kp.. It may not be good it's just a rule of thumb to get started. then I tune KP usually first. and move on to KI and KD one at a time making small changes

    • @NikeAirJordanGabes
      @NikeAirJordanGabes Před 2 lety

      @@CodingCoach Another thing I am wondering is that if we want the robot to be going full speed when it is at the right distance from the wall, could we still use the max speed as our base speed? I do not know how it would work when adding the PID error to the base speed that is already max to the left motor (and of course it will work subtracting it from the right motor).

  • @O_A_Koroleva
    @O_A_Koroleva Před rokem

    Good day. You build robot now or you end all?

  • @CAT-dm9hy
    @CAT-dm9hy Před 3 lety +1

    :)

    • @CAT-dm9hy
      @CAT-dm9hy Před 3 lety

      wow my comment is the best