ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

Creating and Tuning a PID controller with Python Simulation

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ส.ค. 2024
  • The long-awaited PID Part 2 video!
    As mentioned this video was recorded in one 4 hr session where Luke and I sat down and recorded until it was done. Github: github.com/Jma...
    Music thanks to Noise Boise (@Noise Boise on Spotify)
    ********
    Discord: orionaerospace...
    ********
    TimeStamps
    00:00 Setup
    04:53 Creating a simulation class
    09:10 Rocket class
    15:33-PID class
    20:01 PID loop
    28:02 PID Tuning
    29:20 Plotting results
    36:28 Conclusion
    ---------------------------
    Thanks for watching!!!!!!!!

ความคิดเห็น • 68

  • @Ameliaross106
    @Ameliaross106 4 ปีที่แล้ว +31

    So you find the self.error at 20:51 by subtracting where the rocket isn’t from where it is. Therefore the missle knows where it is from where it isn’t

  • @IntRocketLaunch
    @IntRocketLaunch 4 ปีที่แล้ว +21

    Great video guys! I can tell a lot of effort went into this :)

  • @deldrise9169
    @deldrise9169 4 ปีที่แล้ว +23

    This is actually gold.

    • @revmartin2981
      @revmartin2981 3 ปีที่แล้ว +5

      Correction: diamond ♦💎👍

  • @DeltaSpaceSystems
    @DeltaSpaceSystems 4 ปีที่แล้ว +8

    Very nice video!

  • @user-eh5zk5bb9k
    @user-eh5zk5bb9k 3 ปีที่แล้ว +1

    This is so valuable for someone who just wants to see a practical intro to pid control !!!

  • @krlospelaez
    @krlospelaez 4 ปีที่แล้ว +2

    Thanks you guys! I found this very useful. It gives a better understanding about PID and how to tune it :)

  • @velocitylaunchsystems
    @velocitylaunchsystems 4 ปีที่แล้ว +5

    Very cool

  • @CondorSWE
    @CondorSWE 2 ปีที่แล้ว

    Attitude control for a typical rocket only needs a proportional + derivative term. Lack of integral on attitude can be compensated by an outer guidance loop.

  • @adamdude
    @adamdude 4 ปีที่แล้ว +15

    Man great video! I was looking at BPS space and his videos but he doesn't go into the software stuff as deep as you guys do. Are you going to make a video about 3D orientations and quaternions? Or maybe your arduino code?

    • @stevato0449
      @stevato0449 4 ปีที่แล้ว +1

      Check out the wiki at r/amateurTVC and read the Madgwick paper on quaternions until section 3.1.

    • @mostafaelshafie4550
      @mostafaelshafie4550 2 ปีที่แล้ว

      very true. I really like that they do that here.

  • @aerofoiledaero7807
    @aerofoiledaero7807 4 ปีที่แล้ว +3

    Nice simulation 👍🚀😁

  • @flwi
    @flwi 3 ปีที่แล้ว

    That's a _very_ good explanation of pid controllers imho. Didn't know how to tune them and I like your approach of quickly designing a simple simulation to get some numbers.
    Don't know how I ended up here, but I like it in this rabbit-hole ;-)

    • @flwi
      @flwi 3 ปีที่แล้ว

      Oh, I remember now. Maybe I'll revisit this coding challenge.
      The 2nd part now seems doable, but I still have no idea how to make a rocket follow a path, which is the problem in the 3rd part.
      2nd part: www.codingame.com/training/medium/mars-lander-episode-2
      3rd part: www.codingame.com/training/expert/mars-lander-episode-3

  • @hanbergsspacemission4184
    @hanbergsspacemission4184 3 ปีที่แล้ว +1

    Thank you so much for sharing this!

  • @stevato0449
    @stevato0449 4 ปีที่แล้ว +4

    YAAAAAAAAASSSSSSSSSS.

  • @storageupload7256
    @storageupload7256 ปีที่แล้ว

    Great video guys! thank you

  • @blitz8229
    @blitz8229 3 ปีที่แล้ว +1

    Really cool channel, keep going, subscribed!)

  • @sigurdvingelsgaard9466
    @sigurdvingelsgaard9466 3 ปีที่แล้ว

    this is a whole vibe

  • @datastako156
    @datastako156 ปีที่แล้ว

    nice vid! very informative..thank you!

  • @simonabunker
    @simonabunker 4 ปีที่แล้ว +2

    Great video! Would it be worth writing a flight computer in micropython so you could use the actual flight module in the simulation?

  • @milindsharma8106
    @milindsharma8106 3 ปีที่แล้ว +1

    Hi guys!!
    Absolutely loved this video, and thinking about joining your Discord.
    I have a question about PID controller algo's in Python. Aside from the obvious issue of most microcontrollers needing code in C++ or C, would Python code even run fast enough to really be of any use in an actual thrust vectoring system?

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว +1

      The flight software is still written in c++. This simulation is just to show how similar steps could be taken to attain PID gains that would then be implemented in C++ flight software :) hope that helps and would love to see you on the discord :D

    • @milindsharma8106
      @milindsharma8106 3 ปีที่แล้ว

      @@OrionAerospace Gotcha! Would it be fast enough at all though if you were to magically run the code on the controller?
      Yess, probably will be seeing me soon haha. Quite intrigued by the rapid progress you guys have made!!!

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว

      @@milindsharma8106 You can program all of your flight software in python (micropython or circuit python) In general python is pretty slow but on an embedded system like a rocket flight computer it might be fast enough-- i would stick to c++ though. We have some c++ on our discord that might help give you a good starting point! Theres also more info on our website

    • @milindsharma8106
      @milindsharma8106 3 ปีที่แล้ว +1

      @@OrionAerospace Once again, y’all are wonderful! Thanks a lot for all your help! I Gotta deal with a simpler problem first - finding my lost password to my PayPal account to make that donation

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว

      @@milindsharma8106 glad we could help :)

  • @sakshumgadyal
    @sakshumgadyal 3 ปีที่แล้ว

    Please make more videos like this

  • @mostafaelshafie4550
    @mostafaelshafie4550 2 ปีที่แล้ว +1

    hey, why not use matLab's simulink for the simulation instead of python?
    what do you guys personally feel is the advantage of python in this situation?

    • @Jon-ic3bt
      @Jon-ic3bt ปีที่แล้ว +2

      Simple. Mathlab require licences while python is free. My work doesn't pay for Mathlab so this tutorial is extremely valuable

  • @adamdude
    @adamdude 4 ปีที่แล้ว +1

    Is the Ziegler Method appropriate in this sort of application? I read somewhere that it's mainly useful when you have a slow process. Isn't a rocket launch an inherently fast process?

    • @OrionAerospace
      @OrionAerospace  4 ปีที่แล้ว

      adamdude yeah it works best for a slower plant or process. However from some simulations we did it’s passable. There are other versions of the ziegler Nichols however that are better suited :)

    • @adamdude
      @adamdude 4 ปีที่แล้ว

      @@OrionAerospace ok thanks! Any tips with dealing with quaternions? I'm writing my own simulation with a buddy of mine and we're trying to get the thrust angles calculated and such. Do you have a discord to chat?

    • @OrionAerospace
      @OrionAerospace  4 ปีที่แล้ว

      adamdude yep! Our discord is available here: orionaerospacelift.wixsite.com/orionaerospace/please-help we are thinking about releasing our custom quaternion library to the server as well! So that may help you out as well :)

    • @adamdude
      @adamdude 4 ปีที่แล้ว

      @@OrionAerospace awesome! Donated!

  • @vaibhav-_-5462
    @vaibhav-_-5462 ปีที่แล้ว +1

    which development board you are using????

    • @COSMOSIS245
      @COSMOSIS245 5 หลายเดือนก่อน

      teensy 3.5 i think

  • @jonathanlowe5077
    @jonathanlowe5077 3 ปีที่แล้ว

    Thought you were going to use state space?

  • @Extorc
    @Extorc 3 ปีที่แล้ว

    Umm my country isnt supported in your donation on the website.......

  • @rogervanschie8647
    @rogervanschie8647 3 ปีที่แล้ว +1

    Shouldn't 'def set_dy(self): self.dy += self.ddy' be 'def set_dy(self): self.dy += self.ddy * TIME_STEP'? Same for 'def set_y'. As you are integrating acceleration over time to get velocity and integrating velocity over time to get your position.

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว

      You are 100% correct! I’ll change that and upload it to the GitHub. Great catch!

    • @rogervanschie8647
      @rogervanschie8647 3 ปีที่แล้ว

      ​@@OrionAerospace Here some sane'ish values for that setup:
      'Kp':[1.3], #_Proportional_Control_Coefficient
      'Ki':[0.02], #_Integral_Control_Coefficient
      'Kd':[1.8], #_Derivative_Control_Coefficient
      'dt':[0.01], #_Sampling_period

  • @b5nj1m9n
    @b5nj1m9n 3 ปีที่แล้ว

    How did you get the desired gains? This can’t be just trial and error right? Or did you use AI to compute the ideal gains?

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว +1

      Its not trial and error! check the end of the video and we use a method called Ziegler nichols method to tune the system mathematically its faster than using AI although people have used genetic algorithms to tune similar systems :D

    • @b5nj1m9n
      @b5nj1m9n 3 ปีที่แล้ว

      Orion Aerospace my bad i asked my question before i finished watching haha, i made a function to auto tune the gains based on the Ziegler-Nichols method you talked about. It works good enough for me, if you want to I can send you my version of the code :)

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว

      @@b5nj1m9n feel free to add a pull request on the gituhub! that way anyone else who checks out the video in the future will also be able to see your fork!

    • @b5nj1m9n
      @b5nj1m9n 3 ปีที่แล้ว

      Orion Aerospace I am pretty new to the github community so I have no idea how to do that haha

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว +2

      @@b5nj1m9n ahah if you want you can send an email to us orionaerospace.liftoff@gmail.com and i can credit you in the commit :) not to worry if not! glad you found the video useful

  • @donharrold1375
    @donharrold1375 11 หลายเดือนก่อน

    Seems like massive effort when you could have got something similar with Matlab in a few minutes

    • @COSMOSIS245
      @COSMOSIS245 5 หลายเดือนก่อน +1

      MATLAB is pretty expensive by a lot of standards, still, hats off to these guys

  • @sigurdvingelsgaard9466
    @sigurdvingelsgaard9466 3 ปีที่แล้ว

    Podcasts comming?

  • @aparnar2459
    @aparnar2459 3 ปีที่แล้ว

    What is this turtle library?

  • @rechtebanana
    @rechtebanana 2 ปีที่แล้ว

    hello what IDE do you use

    • @siliconnitride7029
      @siliconnitride7029 2 ปีที่แล้ว

      He used sublime text, don't know what version though...

    • @rechtebanana
      @rechtebanana 2 ปีที่แล้ว

      @@siliconnitride7029 thank you

  • @Leo-it9dc
    @Leo-it9dc 3 ปีที่แล้ว

    Is that the full code?

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว +2

      VENTANIA 72 yep! GitHub link is in the description ;)

    • @Leo-it9dc
      @Leo-it9dc 3 ปีที่แล้ว +1

      Can you please make a video with the full software??

  • @DietBroccoli
    @DietBroccoli 3 ปีที่แล้ว

    You really ought to read PEP8. Your style is both in defiance of convention and inconsistent.

  • @emmetray9703
    @emmetray9703 3 ปีที่แล้ว

    do not use Python, use C.

    • @OrionAerospace
      @OrionAerospace  3 ปีที่แล้ว +2

      this is just a simulation :) the actual flight software is written in C/C++

    • @emmetray9703
      @emmetray9703 3 ปีที่แล้ว

      @@OrionAerospace that's good.

  • @Stagcraftstream
    @Stagcraftstream 4 หลายเดือนก่อน

    As a java programmer, python makes me want to puke