How the Flight Controller Code Works - dRehmFlight VTOL

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

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

  • @NicholasRehm
    @NicholasRehm  3 ปีที่แล้ว +36

    Hi all, I know this vid is on the boring side, but I wanted to make sure it was out there to help anyone get flying more easily. This is the exact same code I use for all of my projects (I literally download a clean version from github to modify for every new project) so I want there to be as many resources out there as possible for others to do the same. So definitely give the whole vid a watch over dinner sometime if you're interested in flying this flight controller on your next project

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

      Very much interested. Keep going plz.

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

      Boring? You got to be efffing kidding me. This is amazing stuff!!!!! Kudos and thank you!

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

      I not think so , it was very good.

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

      sir its very helpfull , please make such more videos.

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

      It's not boring at all. I'm happy to finally found someone doing this with a teensy. Good luck man.

  • @ohitstarik
    @ohitstarik 3 ปีที่แล้ว +21

    this channel is so underrated

  • @tuberroot1112
    @tuberroot1112 8 หลายเดือนก่อน +2

    Boring ? Not at all. It's a very good run through. Not only do you supply your code, with excellently thorough documentation, you give us a video too ! If only everyone was this "boring".

  • @akyadavhere
    @akyadavhere 4 หลายเดือนก่อน +1

    Just to let you know, your "boring" video is still helping people

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

    Great video! Thanks so much for the effort you put into this. We are building our first drone from scratch and this is precisely the kind of approach we were looking for. I'm certain many, many more will find your effort useful for years to come.

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

    i was working on a custom drone firmware based on teensy and mpu6050, this video saved me a lot of time, I will definitely reuse some part of your code!

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

      Very happy to have helped

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

    this is great, should help a lot when i get deeper into this project. i think a video where you share the process of how you modify the code for an actual project could be a good finale to the series. cheers (edit: you said you're doing just that!)

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

      I think you'll really be surprised at the cool things you can do. Can't wait to see what you come up with

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

    Been waiting on a follow up on this! Good job man!

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

    Yoooo -- the king is back. Appreciate the deep dive.

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

    Hi Nicholas
    Your video is brilliant!! I've been waiting for your very informative, easy to understand and technical enough to grow with, type of video. I hope to work with you in the future. The world needs you!! Blessings, Steve

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

      Yes--more flight controller stuff is on the way, stay tuned

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

      @@NicholasRehm Would you be interested in helping with a real-world application?

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

    I really appreciated answers are in project documents "Frequently Asked Questions".

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

    This is super useful!!!!!! Thanks!!!! Always wanted to know how to make one of these in practice!

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

    Thank you for all the effort you put in. Just discovered this project and I love the approach. I will use it for some fun project soon!

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

    Hi, really great work! If I may ask, could you do a video explaining how you establish and solve the state-space equations for the flight controllor? I am really insterested in control and want to learn deeper. Really appreciated if you can do a video about the design behind the scene.

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

    The best of explanation , Thanks

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

    Could you go into more detail about how PID functions mathematically? Ie laplace transformations of the partial, integral, differential equations.

  • @23lkjdfjsdlfj
    @23lkjdfjsdlfj 2 ปีที่แล้ว

    Really great video. Thanks for creating this!

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

    dude you are my hero. thank you

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

    Brilliant work!. Thanks for sharing

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

    Need a "dRehmDrive ActiveAero" version :)

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

    Will the motors + ESC keep up with the 2kHZ loop frequency? I know it's good for the sensors but can the actuators make any significant output in 500 microseconds?

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

      On smaller racing drone size platforms, absolutely. But you do need to be careful not to over-tune pid gains or else you’ll heat up the motors from such high speed changes

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

    So this my be off topic since this is a tensey project but i am asking anyway:
    Will it also run on an ESP32? Specifically the newer s2/3 ?
    Also since tensey 4.1 is a bit better i assume it will work too.
    Also i plann to use an ESP32 as a WIFI receiver will this work? i did not check but i am sure there are some free pins for a I2C bus or a SPI connection.

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

    For a autonomous drone do we need both flight controller and flight computer?

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

    i'm at the exciting part of the project now (test flying quadcopter) and i see that often times, only one servo spins when i push throttle or they all spin but are offset as i push the throttle. other times, the drone is stable on the ground, but one or two servos slightly spin and the only way to stop is to restart the drone. i calibrated the motors but i have my mpu-6050 fixed on two standoffs, so it may be my weird way of installing the IMU?

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

    Nicholas, thanks for the deep explanation of your code. Just wondering is it possible to port the code to Arduino Nano considering the speed and memory needed?

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

      I started out on the nano but then moved to the teensy as the foundation for the project, so unfortunately it’s not backwards compatible

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

    Hello, building one nowadays, I wonder do you have a plan to add a OSD feature to video transmitters?

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

      Unfortunately that's out of the scope of this project

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

    by the way, how do you set up the visuals for these videos? is this just power point?

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

      lol yes, screencap with obs

  • @lucachacha71
    @lucachacha71 7 หลายเดือนก่อน

    this is pure gold

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

    Hello, Nice job dude, have been seeking for like this, but what is the difference between open source multiwii firmware that can be flashed to Arduino nano and your firmware?
    Thanks

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

      This is probably a more readable, easier to understand version of multiwii--mainly because the teensy board is so dang fast, code doesn't need to be optimized beyond recognition to get decent performance

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

    What motors and props did you use that can support the weight of the quadcopter with the added sand bag? Great project

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

      I use these: amzn.to/3wma3CT & amzn.to/3dMu52E on 4s

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

    wooowwww..... amaziinggggg.. thanks for the lessons

  • @Petriefied0246
    @Petriefied0246 8 หลายเดือนก่อน

    How could this be adapted to control an RC car with individual motors for each wheel? Im thinking of how it could control drift and apply torque vectoring.

    • @NicholasRehm
      @NicholasRehm  8 หลายเดือนก่อน

      The control mixer is your friend

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

    Hi Rehm… m pretty amazed at the simplicity of your explanation of code.
    Just curious, Well can we try the code on arduino board?

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

      The short answer is no. It’ll run on an earlier teensy like 3.1 but will be slower and the filters will need re-tuning

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

    I am using SimonK ESC’s which does not support oneshot protocol, what changes need to be done in the code?

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

      Just use the servo outputs for your motors which use regular 50hz pwm

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

    hey nick, a few question:
    - will this setup work on the Teensy 4.1?
    - how much sram/flash memory does this take up on the teensy 4.0? i know this mcu is a strong boy but if you wanted to add more modifications, will it be completely okay with the rest of the IMU code?
    - servo motors just mean the brushless drone motors right? lol
    thanks!

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

      Yep this works directly on the 4.1 with no changes. Code uses only like 5% or less memory if I recall correctly. You can load it up with as many modifications (sensors, additional actuators, calculations, data logging) as you want-only thing to watch out for is slowing down the void loop speed too much. There’s a lot of headroom for that though. Servos in the code refer to pwm outputs (as opposed to motors which use oneshot125 protocol) so the servo variables can be used for either ESCs or hobby servos. Motor variables can only be used on compatible bl-heli ESCs that support oneshot125

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

    Our engineering team is going to try and use this to work with a RC submarine. It is effectively a quadcopter with extra thrusters.

  • @piconano
    @piconano 7 หลายเดือนก่อน

    Can a ported version of your code run on one core of a raspberry pi 3(and up) models?
    Can it tolerate the non-RTOS nature of linux?

    • @NicholasRehm
      @NicholasRehm  7 หลายเดือนก่อน

      That’d be a challenge and probably not worth the time even if you could get all the peripherals/interfaces working well

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

    You mentioned that default loop rate should not be changed because of filter parameters, is there a guide on how to retune them if i want to use the code on a slower platform like stm32?

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

      dsp.stackexchange.com/questions/43063/first-order-low-pass-filter The 'alpha' in the equations is actually 'beta' for the filters in the code. Beta = omga*T/(1 + omga*T), where omga is the cutoff frequency in rad/s, T is the dt between loops. First calculate the cutoff frequency for the current betas using T = 1/2000. This omga stays constant for each filtered parameter (constant low-pass cutoff frequency). Using this omga and your new loop dt (1/new looprate), calculate the new beta. I'd recommend just pinning loop rate to 250hz. Do this for the gyro and accelerometer, and then you may as well scroll down to the getCommands() function and comment out the filtering happening down there--it's not really necessary. These calculations will get you in the ballpark of where they need to be... you'll need to fine tune them to get a good balance of delay to noise rejection. B_madgwick might be able to stay the same without tuning, but check your roll/pitch/yaw angles if it significantly lags behind. At the end of the day, as long as you get them tuned somewhat close and you don't expect to crank you PID gains too high, you'll be able to fly. The default tune for the teensy just gives the absolute best performance in my opinion in terms of how aggressive you can crank the PID controllers and still get a stable platform.

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

      @@NicholasRehm Wow thanks a lot for the quick answer. This kind of dedication is why I love your channel. Cheers!

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

    Sir can you please tell where to set the max thrust value or maximum rate at which motor should move as we want

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

      In the control mixer you can scale the commanded throttle or stabilization values by any value you want

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

    Hi Nicholas , Is my understanding correct about PID Controller ?
    - controlANGLE () is select for Multirotor or VTOL-Hover
    - controlRate () is select for Plane or VTOL- FF

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

      Correct! Angle can technically be used for forward flight too, but not recommended

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

      @@NicholasRehm In the example code line 417 "//PID Controller - *SELECT ONE:" *Select ONE , Is it fix for only multi-rotor not for VTOL ? and In case I need code for VTOL , I should //all (Not select ONE) then use IF (ch_6_pwm .......) instead for swap PID controller by remote sw, Right ?

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

      @@akkaradechsrithongchai7766 Correct, only one can be used at a time, but you are free to switch between them while in flight

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

      @@NicholasRehm Thank a lot , I follow you and will try to build one , Teensy and IMU are coming on mail.

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

    Hey Nicholas, just a quick question I wantes to ask
    In controlMixer (), it says left two motors should have +roll_PID while front ones should have +pitch_PID
    can you or anyone please tell how this works

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

      If the stabilization is reversed you can subtract them instead

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

    I really wanna thanks a lot ❤️

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

    great vid!

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

    But why didn't you use the prop shield. It has a barometer and gyroscope..... Or you leaving it for an advanced one

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

    Hello. Teensy 4.0 is hard to find
    Is it okay to use 4.1?
    Thank you.

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

    things are seeming to work ok thru the programming. but now we are having no luck getting the 4 in 1 ESC to initialize. looking at the motor outputs in the code, they are live, but that is the end of the good news. I have the X-Rotor 60A ESC. any ideas??

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

      You may need to calibrate your ESC endpoints

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

      @@NicholasRehm i think that's the problem. i am only seeing 125 - 240 on the throttle chn. the other chns make it to 250. haven't figured out how to change that yet in my older Frsky 9xd. thanks.

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

      I recalibrated so now am getting full range. the esc beeps, but doesn't initialize. I got a response on RCGroups suggesting uncommenting a "calibrate ESCs()" line of code in the Void Setup area. but that is not in the code I have been using.

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

      @@merlingreen3481 try 1.3 version

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

      @@NicholasRehm I had been using the dRehmFlight_Beta_1.2_F-35VTOL file. The servos work with this. when I load the dRehmFlight_Teensy__Beta_1.3, the servos drive to the end and are not operative. Is there another 1.3 version I haven't found? a bit more information ... i am powering the Teensy separately, not from the ESC. the only wires I have connected between the teensy and the ESC are m1 - m4 from on the ESC to pins 0-3 on the Teensy even tho m4 isn't used.

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

    Can this code work for a hybrid VTOL aircraft and transition modes?

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

      Yes

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

      @@NicholasRehm Thanks for the reply!

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

    Hey Nick,
    I am getting a 0 output for all my PWM servos and they are occasionally spinning for 2 seconds but mainly making a lot of beeping noises lmao. I get correct outputs for the motors but the servos are just all zeros and I just can't figure it out. Thanks!

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

      Have you assigned anything to the servo variables in the control mixer? Default code has them set to 0

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

      @@NicholasRehm I have not. So it's just s1_command_scaled = 0, etc. Am I misunderstanding something?

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

      @@najmaperveen6504 Read tutorials 9.7-9.9 in the docs (17:09 in the video above). The default code just has output mixing for standard quad as an example. If you want to use the other actuators/change motor assignments, you need to update the assignments to the ..._command_scaled variables accordingly

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

      Also, if you're planning to use the servo variables to control motors (which it sounds like you are), uncomment the corresponding variables in the throttleCut() function so they won't twitch like you described when throttle cut is engaged for safety

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

      @@NicholasRehm Ahh, I just got them to spin (quadcopter). I copy pasted the lines from the mx_command_scaled_variables to the servo outputs. Very satisfying but bittersweet since I spent too many hours trying to troubleshoot. Gotta study control mixing now!

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

    Hi Nicholas, I am trying to save other versions so I can keep the original intact, but if I try to save it the modified code with a different name, it will not compile. Do you know why? Also, I am trying to delete the folder so I can reinstall it (I made some modifications and won't run anymore), but now it requires a administrator permission to do that. How do I bypass that step?

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

      If you change the name of the .ino arduino script, you need to make sure the folder it is in has the same name

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

      @@NicholasRehm nice, thanks, and if you are willing to meet and teach me how the program works that would be great. I have a project that I am working on it, but I am stuck. Do you have a patrion account? I can make a donation there for your projects. Nice work on the Starship.

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

      @@ernestosaboia You can email me if you'd like, or we can help you over on RCGroups, that way others can benefit from your learning process as well: www.rcgroups.com/forums/showthread.php?3706571-dRehmFlight-VTOL-Teensy-Flight-Controller-and-Stabilization

  • @rickygoings4823
    @rickygoings4823 9 หลายเดือนก่อน

    I used the imuinit() and the calculate_IMU_error() and calibrate Attitude();

  • @rickygoings4823
    @rickygoings4823 9 หลายเดือนก่อน

    is the 9250 better than the 6050

    • @NicholasRehm
      @NicholasRehm  9 หลายเดือนก่อน

      No I wouldn’t recommend going through the extra trouble, you won’t notice any difference

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

    Is there any code to connect gps?

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

      Nope but you could add it and write a new controller yourself

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

    Thanks for the video!
    I would like to buy a Arduino compatible board and maybe use it for a vtol RC Plane!

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

      This project uses the Teensy 4/4.1

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

      @@NicholasRehm Thanks!

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

      @@NicholasRehm compatible with teensy 3.2/3.6 ?

  • @rickygoings4823
    @rickygoings4823 9 หลายเดือนก่อน

    .my roll_imu drift back to 0.0 or -0.45 or something. after I use the madgwick filter

    • @NicholasRehm
      @NicholasRehm  9 หลายเดือนก่อน

      Have you gone through the IMU calibration procedures?

    • @rickygoings4823
      @rickygoings4823 9 หลายเดือนก่อน

      I used the imuinit() and the calculate_IMU_error() @@NicholasRehm

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

    Would you consider giving private lessons?

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

    nice

  • @christianengineer.
    @christianengineer. 3 ปีที่แล้ว

    And I thought Command_Blocks were complicated

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

    Hello sir. Can you make it simplier then that?! Please make one tutorial for persons, like me🤪, with setup, Code writing for vtol like f35.. Thanks for understanding me and others that is not familiar with arduino stuff. I work only with kk2 boards. Cheers mate

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

      Video on the F-35 very soon