How the Flight Controller Code Works - dRehmFlight VTOL

  Рет қаралды 28,897

Nicholas Rehm

Nicholas Rehm

Күн бұрын

Пікірлер: 134
@NicholasRehm
@NicholasRehm 3 жыл бұрын
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 жыл бұрын
Very much interested. Keep going plz.
@aeroakram
@aeroakram 3 жыл бұрын
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.
@akyadavhere
@akyadavhere 2 ай бұрын
Just to let you know, your "boring" video is still helping people
@ohitstarik
@ohitstarik 3 жыл бұрын
this channel is so underrated
@junuhunuproductions
@junuhunuproductions 3 жыл бұрын
Haha it's you 🧐🧐
@tuberroot1112
@tuberroot1112 5 ай бұрын
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".
@RaisingAwesome
@RaisingAwesome 2 жыл бұрын
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.
@thercproject9309
@thercproject9309 3 жыл бұрын
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
@ShilleR2044
@ShilleR2044 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
@jimboloco539
@jimboloco539 3 жыл бұрын
Been waiting on a follow up on this! Good job man!
@akkaradechsrithongchai7766
@akkaradechsrithongchai7766 3 жыл бұрын
I really appreciated answers are in project documents "Frequently Asked Questions".
@rockapedra1130
@rockapedra1130 2 ай бұрын
This is super useful!!!!!! Thanks!!!! Always wanted to know how to make one of these in practice!
@Q_Channel1
@Q_Channel1 3 жыл бұрын
Yoooo -- the king is back. Appreciate the deep dive.
@realrealitymedia6725
@realrealitymedia6725 3 жыл бұрын
dude you are my hero. thank you
@BenjaminKelm
@BenjaminKelm Жыл бұрын
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!
@akkaradechsrithongchai7766
@akkaradechsrithongchai7766 3 жыл бұрын
The best of explanation , Thanks
@arlenn729
@arlenn729 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.
@lucachacha71
@lucachacha71 5 ай бұрын
this is pure gold
@steveell7334
@steveell7334 3 жыл бұрын
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 жыл бұрын
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?
@23lkjdfjsdlfj
@23lkjdfjsdlfj 2 жыл бұрын
Really great video. Thanks for creating this!
@beefybeef1326
@beefybeef1326 Жыл бұрын
Brilliant work!. Thanks for sharing
@mattuiop
@mattuiop 2 жыл бұрын
Could you go into more detail about how PID functions mathematically? Ie laplace transformations of the partial, integral, differential equations.
@wongsorc6918
@wongsorc6918 3 жыл бұрын
wooowwww..... amaziinggggg.. thanks for the lessons
@corty8969
@corty8969 3 жыл бұрын
great vid!
@P0K0
@P0K0 Жыл бұрын
I really wanna thanks a lot ❤️
@brianblasius
@brianblasius 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 2 жыл бұрын
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
@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
@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.
@EngineeringAfterHours
@EngineeringAfterHours 2 жыл бұрын
Need a "dRehmDrive ActiveAero" version :)
@ohitstarik
@ohitstarik 3 жыл бұрын
by the way, how do you set up the visuals for these videos? is this just power point?
@NicholasRehm
@NicholasRehm 3 жыл бұрын
lol yes, screencap with obs
@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 Жыл бұрын
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
@Petriefied0246
@Petriefied0246 5 ай бұрын
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 5 ай бұрын
The control mixer is your friend
@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
@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 Жыл бұрын
Just use the servo outputs for your motors which use regular 50hz pwm
@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 жыл бұрын
I use these: amzn.to/3wma3CT & amzn.to/3dMu52E on 4s
@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
@piconano
@piconano 4 ай бұрын
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 4 ай бұрын
That’d be a challenge and probably not worth the time even if you could get all the peripherals/interfaces working well
@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 жыл бұрын
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
@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 жыл бұрын
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 жыл бұрын
@@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.
@yucekaya1622
@yucekaya1622 2 жыл бұрын
Hello. Teensy 4.0 is hard to find Is it okay to use 4.1? Thank you.
@NicholasRehm
@NicholasRehm 2 жыл бұрын
Yes
@ijahongirmirzo
@ijahongirmirzo 2 жыл бұрын
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 2 жыл бұрын
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
@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 жыл бұрын
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!
@rickygoings4823
@rickygoings4823 7 ай бұрын
I used the imuinit() and the calculate_IMU_error() and calibrate Attitude();
@Mkkl3782
@Mkkl3782 3 жыл бұрын
nice
@rahultembhurne7481
@rahultembhurne7481 2 жыл бұрын
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 2 жыл бұрын
In the control mixer you can scale the commanded throttle or stabilization values by any value you want
@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 жыл бұрын
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 жыл бұрын
@@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
@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
@ernestosaboia
@ernestosaboia 3 жыл бұрын
Would you consider giving private lessons?
@AssBurgerHD
@AssBurgerHD 3 жыл бұрын
How reliable can I assume the imu data is from the madgwick filter? Or your code I guess.
@NicholasRehm
@NicholasRehm 3 жыл бұрын
Stdev of about 0.4 deg in roll and pitch, but can be prone to drift if accelerating wildly (like a freestyle drone, for example)
@AssBurgerHD
@AssBurgerHD 3 жыл бұрын
@@NicholasRehm so a kalman filter would be more accurate? How do ardupilots drones do this, do they use the kalman? Isn't that more expensive computational wise. If not how they rocking position estimation?
@AssBurgerHD
@AssBurgerHD 3 жыл бұрын
@@NicholasRehm btw I respect what you did and digging your recent content too
@NicholasRehm
@NicholasRehm 3 жыл бұрын
@@AssBurgerHD Ardupilot uses a variant called extended kalman filter or EKF. Yes it can be more accurate, and they often have better IMU's than the 6250. It's quite a bit more computationally involved, but not really necessary on a hobbyist VTOL project like this. Thanks for your kind words
@ozone9942
@ozone9942 Жыл бұрын
Can this code work for a hybrid VTOL aircraft and transition modes?
@NicholasRehm
@NicholasRehm Жыл бұрын
Yes
@ozone9942
@ozone9942 Жыл бұрын
@@NicholasRehm Thanks for the reply!
@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.
@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 жыл бұрын
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!
@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 жыл бұрын
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 7 ай бұрын
is the 9250 better than the 6050
@NicholasRehm
@NicholasRehm 7 ай бұрын
No I wouldn’t recommend going through the extra trouble, you won’t notice any difference
@karindachbauer3080
@karindachbauer3080 Жыл бұрын
Is there any code to connect gps?
@NicholasRehm
@NicholasRehm Жыл бұрын
Nope but you could add it and write a new controller yourself
@rickygoings4823
@rickygoings4823 7 ай бұрын
.my roll_imu drift back to 0.0 or -0.45 or something. after I use the madgwick filter
@NicholasRehm
@NicholasRehm 7 ай бұрын
Have you gone through the IMU calibration procedures?
@rickygoings4823
@rickygoings4823 7 ай бұрын
I used the imuinit() and the calculate_IMU_error() @@NicholasRehm
@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 жыл бұрын
Video on the F-35 very soon
Making an INSANE Hovering RC F-35 VTOL Jet
21:28
Nicholas Rehm
Рет қаралды 407 М.
The Difference Between a Drone Flight Controller and Flight Computer
7:18
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 15 МЛН
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 60 МЛН
АЗАРТНИК 4 |СЕЗОН 3 Серия
30:50
Inter Production
Рет қаралды 874 М.
Making a Drone Smarter With Motion Planning
12:53
Nicholas Rehm
Рет қаралды 80 М.
DroneCase: The DIY Phone Case That FLIES
8:50
Nicholas Rehm
Рет қаралды 186 М.
Radio Controlled SpaceX Starship CRASH
10:10
Nicholas Rehm
Рет қаралды 19 М.
Setting Up Your Radio Connection - dRehmFlight VTOL
3:45
Nicholas Rehm
Рет қаралды 18 М.
The Extraordinary Redundancy of Spinning Drones - Part 3
9:13
Nicholas Rehm
Рет қаралды 1,2 МЛН
Un-Folding a Quadcopter to Increase Efficiency - Part 1
10:57
Nicholas Rehm
Рет қаралды 579 М.
Flying Inverted Pendulum
7:58
Nicholas Rehm
Рет қаралды 46 М.
The Spinning Drone Paradox - Part 1
8:44
Nicholas Rehm
Рет қаралды 2,2 МЛН