Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why not run flight controller under Linux?
#1
Why can't I find any flight controller software that can run as a Linux application and use ESC, servo, IMU etc. using Linux drivers? If I want to have a small Linux single-board computer (e.g. Raspberry Pi) controlling my drone, why do I also need an extra FC board when the single-board computer has every GPIO pin function I need?

Sorry if this is a beginner's question,
Reply
Login to remove this ad | Register Here
#2
a raspberry is just a "brain"
it does need a gyro with high processing speed, a sensor. to do contorlled steering, the gyro is needed to tell the actual movement and to controll quad
Reply
#3
(25-Feb-2024, 12:27 PM)hugnosed_bat Wrote: a raspberry is just a "brain"
it does need a gyro with high processing speed, a sensor. to do contorlled steering, the gyro is needed to tell the actual movement and to controll quad

Sure. And such accessories (IMU, magnetic compass, pressure sensor, GPS) are readily available and easily attached to the GPIO pins. Drivers exist.
Reply
#4
If the model Pi you are using has sufficient UARTS and timers, it can replace the usual STM flight controller (Multiwii ran on an Arduino). For communicating with ESCs, typical protocol is DSHOT (specs can be found) or borrow the code from BF which is open source. Otherwise you can use good old school PWM used in controlling a servo, that will work for most ESCs as well. UARTS will provide high speed hardware serial communication to devices such as serial RXs and GPS.
Linux is an OS, the FC would need to be run in a dedicated high speed program such as one written in C++.
[-] The following 2 users Like mstc's post:
  • ph2t, hugnosed_bat
Reply
#5
(25-Feb-2024, 02:20 PM)mstc Wrote: If the model Pi you are using has sufficient UARTS and timers, it can replace the usual STM flight controller (Multiwii ran on an Arduino). For communicating with ESCs, typical protocol is DSHOT (specs can be found) or borrow the code from BF which is open source. Otherwise you can use good old school PWM used in controlling a servo, that will work for most ESCs as well. UARTS will provide high speed hardware serial communication to devices such as serial RXs and GPS.
Linux is an OS, the FC would need to be run in a dedicated high speed program such as one written in C++.

Thanks for answering. Yes that is how I see it also. I actually have a raspberry pi -like single board computer up and running, with GNSS, IMU, compass, pressure sensor, a servo, and an ESC, with a motor, connected. It all works, I can position servos, control engine RPM and get all sort of position information. And there are outputs for up to 6 ESC/servos on this board. So hardware-wise this approach should be fine. But which flight controller software should I use ("high speed program written in C++" as you write)? Has anyone tweaked cleanflight or betaflight to work inside Linux using Linux device drivers? Or are there other alternatives for a Linux platform?

/Oskar
Reply
#6
I am not aware of any of the main flight control software that has been ported to work on the Rpi. However PX4 is another open source and designed to work across multiple hardware platforms. There are some experimental branches that run on Rpi.

https://docs.px4.io/main/en/flight_contr...avio2.html

https://docs.px4.io/main/en/flight_contr...lotpi.html

Edit: This might also be of interest
https://youtu.be/6GCR0PLV0fs?si=oWPqObxvOo0T3pUe
[-] The following 1 user Likes mstc's post:
  • ph2t
Reply
#7
(25-Feb-2024, 05:46 PM)mstc Wrote: I am not aware of any of the main flight control software that has been ported to work on the Rpi. However PX4 is another open source and designed to work across multiple hardware platforms. There are some experimental branches that run on Rpi.

https://docs.px4.io/main/en/flight_contr...avio2.html

https://docs.px4.io/main/en/flight_contr...lotpi.html

Edit: This might also be of interest
https://youtu.be/6GCR0PLV0fs?si=oWPqObxvOo0T3pUe

Right. PX4 or ardupilot seems better alternatives under Linux, although they seem less focused on quadcopters. I found a nice comparison here

Navio2 looks like it is in reality a raspberry pi with an external flightcontroller on top running it's own firmware on a separate processor? The chip on the hat reads "STM32F103", a member of the popular STM32 family that so many dedicated flightcontrollers are based on. So not very different from connecting the Linux board to any other self-contained flightcontroller. The thought I had was why not connect the servos and ESC's directly to the Linux system's GPIO pins, without any STM32 processor or other firmware.

That youtube comparison is partly wrong. A raspberry pi with quad cortex-A72 cores and GPU accelerator is MUCH faster computationally than the STM32xxxx single core cortex-M that pixhawk is based on. A Linux system is just normally not optimized for realtime applications.

I suppose it makes sense to separate the lowlevel control functions that require fast response into a hardware+firmware tweaked for realtime requirements, and keep the Linux system on a different processor board running higher-level functions like navigation with higher computation power requirements but lower realtime requirements.

It would be interesting though to try to tweak a Linux system into also fulfilling the response speed requirements. But it looks like it would be a lot of work, since nobody has bothered doing it yet, it seems.
[-] The following 1 user Likes enok71's post:
  • ph2t
Reply
#8
I think the main reason is speed. Linux isn't fast enough. For true speed you need to write code in assembly or C, that has direct access to the CPU (no translation layers). Using Linux would be like programming in Java or using Perl. Unless you convert it to machine code, it just isn't going to be fast enough.

If on the other hand you wrote your own cutdown OS that ran on a RPi, written in say assembly, that was optimised specifically for use with quadcopters and the hardware they require, then it probably would be fine. i still don't think it would be as real time as you would need for freestyle or racing, but if you were building a DJI style drone that didn't need millisecond response times and was maybe going to fly using a checkpoint system with minimal proximity issues, it would probably work.
Try Not, Do or Do Not
- Yoda

[-] The following 1 user Likes Pathfinder075's post:
  • ph2t
Reply
#9
(25-Feb-2024, 09:06 PM)Pathfinder075 Wrote: I think the main reason is speed.  Linux isn't fast enough.  For true speed you need to write code in assembly or C, that has direct access to the CPU (no translation layers).  Using Linux would be like programming in Java or using Perl.  Unless you convert it to machine code, it just isn't going to be fast enough.

If on the other hand you wrote your own cutdown OS that ran on a RPi, written in say assembly, that was optimised specifically for use with quadcopters and the hardware they require, then it probably would be fine.  i still don't think it would be as real time as you would need for freestyle or racing, but if you were building a DJI style drone that didn't need millisecond response times and was maybe going to fly using a checkpoint system with minimal proximity issues, it would probably work.

I agree, although I think the "speed" is not the problem, the processor cores alone in a raspberry pi are 10x faster than in any STM32 core. And you can write Linux applications in any language you like, including C and assembler. The problem is that the Linux and kernel is normally not tweaked towards fast response but rather high performance on average. In this application we want to avoid delays. If you read a file under Linux the processor will perhaps pause all other activity for a few ms in order for that read to have full focus, because on a desktop computer or server nobody will notice a 10ms response delay when clicking the mouse button. In other situations the system could freeze for even longer than that.

But most or all such standard tradeoffs in Linux can be tweaked by recompiling the kernel with different configuration, applying patches, tweaking runtime system parameters and removing potentially problematic unneeded system services, security features and such.

But I'm guessing the argument is that this is not worth the effort. Adding a STM32xxx microcontroller running a well-proven firmware is probably easier and cheaper.
[-] The following 1 user Likes enok71's post:
  • ph2t
Reply
#10
Hi,

Ok, call me confused?  
Why would you want to re-invent the wheel?
What, specifically, are you trying to accomplish?

I guess that I just don't understand the point of it.

Later, iFly   High Five
______________________________________
My BUILDS  ||   My INDEX   ||  Parts Guide  <-- Download


Reply
#11
i believe he is just familiar to linux and personal pc, programming.
the puristic part of our hobby is difficult to understand, sometimes non diversity can be more reliable than diversity. the timing we need is different to personal pcs.

the difference in need might be well displayed by digital fpv and how the peogress was.
while film streaming does work in a very high resolution, we are faraway from that with digital video transmission.

we are very limited with sensors in comparison, there is no tolerance for any buffering to make it more reliable.
digital image transmission, optical sensor data might be the cloasest technology to personal pcs, we does generaly need much more rare and low latency data by our sensors to get a craft reliable.

a 30$ raspberry pi with a bunch of sensors, each more than 10$ - can not hold up with an optimized product, a flightcontroller. even an old f1 or f3 will outperform a raspberry pi in many ways.

Cats has huge eyes, directly next to the brain, they has low latency. we are still there, we need short ways and speed on our hardware. buffering, clusters, ... all that common ways doesnt work to make our quads more reliable, speed is high high priority.
[-] The following 1 user Likes hugnosed_bat's post:
  • enok71
Reply
#12
(27-Feb-2024, 12:25 PM)iFly4rotors Wrote: Hi,

Ok, call me confused?  
Why would you want to re-invent the wheel?
What, specifically, are you trying to accomplish?

I guess that I just don't understand the point of it.

Later, iFly   High Five

We do these things because we can, you should know that H! Smile
[-] The following 2 users Like ph2t's post:
  • enok71, iFly4rotors
Reply
#13
(27-Feb-2024, 01:08 PM)ph2t Wrote: We do these things because we can, you should know that H! Smile

Hi Ph2t,

Of course, I should have known. What was I thinking.  Thinking Rolleyes

Still, I was wondering if there was a specific reason. 
Is it just to say that it can be done? Or, is there something the OP is trying to
accomplish that can not be done with any current firmware?   

Overall, I am happy with Betaflight, however, iNav looks pretty good as well.
One day, I might try iNav just because I can, Ha, Ha,  ROFL Big Grin

Later, iFly   High Five
______________________________________
My BUILDS  ||   My INDEX   ||  Parts Guide  <-- Download


Reply
#14
@iFly4rotors and @hugnosed_bat thanks for answering and I totally agree. I'm a beginner with these hobby drone technology. I do work with embedded Linux though, not so much PC software. Raspberry pi is just an example that people know of. Custom embedded linux can be used on virtually any 32/64-bit board with 128M RAM and 48M flash or even less.

I was looking at a new processor with built-in functionality for e.g. realtime video processing, neural network block for e.g. object identification, and my idea was to use it as a "brain" in a autonomous drone, just for fun and to learn something. Running Linux is an obvious choice because all those highlevel software building blocks exist there. And then my next thought was: why not save some cost and weight and make the FC also run as a Linux process instead of adding another FC hardware gadget. This processor I'm looking at definitly has all the output pins and hardware blocks needed, it's insanely packed with all kind of features.

But like @iFly4rotors says: why reinvent the wheel, probably better use the existing optimized building block that a dedicated FC is.

But what FC or drone platform do you recommend? Is it doable to contruct my own thing from motors, ESC, FC etc., or is that also a thing of the past, i.e. is it cheaper and far superior to just buy an optimized complete drone system and add my custom brain board to control it?

Thanks.
Reply
#15
(27-Feb-2024, 01:44 PM)enok71 Wrote: @iFly4rotors and @hugnosed_bat thanks for answering and I totally agree. I'm a beginner with these hobby drone technology. I do work with embedded Linux though, not so much PC software. Raspberry pi is just an example that people know of. Custom embedded linux can be used on virtually any 32/64-bit board with 128M RAM and 48M flash or even less.

Yeah, I guess it depends on what you want to do; fly, build, invent, program, collect video,
make money, have fun, etc. There are a lot of different disciplines and directions in which
one could go. Many beginners just want to start out flying and having fun; maybe collect 
video, and maybe make some money. The flying styles go from smooth easy and endurance
flying to cinematic to full on ACRO stunt flying and racing. Many folks are happy to just be
a pilot and leave the building and programming to someone else.

Next, there are the builder/pilots who also like to build  as well as fly. Since we are not
building motors and soldering circuit boards, it is more like assembly than making. Other
than firmware configuration, there is no programming in the standard sense of the word. 

Some of the flight controller firmware/software is open source where folks can actually
write program code to make different versions or for inclusion in the core programming.
Betaflight is one such product and I believe that iNav is as well. These folks are always
looking for new contributors. I believe the current firmware is programmed in "C" or
"C++". Being a UNIX programmer, you would be familiar with the language. 

I was looking at a new processor with built-in functionality for e.g. realtime video processing, neural network block for e.g. object identification, and my idea was to use it as a "brain" in a autonomous drone, just for fun and to learn something. Running Linux is an obvious choice because all those highlevel software building blocks exist there. And then my next thought was: why not save some cost and weight and make the FC also run as a Linux process instead of adding another FC hardware gadget. This processor I'm looking at definitly has all the output pins and hardware blocks needed, it's insanely packed with all kind of features.

You know, having a new processor for use in quadcopters is an interesting prospect. 
Innovation is always a good thing. 

I will say that iNav already has autonomous flight features, so you might take a look  
at that and see what it has and how it operates. 


But like @iFly4rotors says: why reinvent the wheel, probably better use the existing optimized building block that a dedicated FC is.

Well, this would be your call, Mate. 

But what FC or drone platform do you recommend? Is it doable to contruct my own thing from motors, ESC, FC etc., or is that also a thing of the past, i.e. is it cheaper and far superior to just buy an optimized complete drone system and add my custom brain board to control it?

Well, I guess it depends on how your "brain" board and software would integrate into
or work in conjunction with the existing FC firmware.


Thanks.

Hi enok,

I believe that learning is a good thing and if that is one of your objectives, 
than that is all fine. Maybe you will discover something useful and can share
that with others for the improvement of the hobby. Or maybe you develop
something that can be marketed.

Yeah, one method might be to re-write everything yourself from the ground
up and move toward something new. Of course, if you are talking about using
a whole different chip, then you are also talking about making (manufacturing)
a whole new FC board. Keep in mind that size is also a consideration and the
kind of craft that the unit could be installed in. 

You might also consider if and how your concepts can be programmed to 
interface with existing firmware such as Betaflight or iNav or maybe a fork
off one of those. If this works out, then (at least in theory), your "brain"
board and firmware could be added to existing BNF quads and FC boards.
Just a thought. 

By the way, what country do you live in? 



Later, iFly   High Five
______________________________________
My BUILDS  ||   My INDEX   ||  Parts Guide  <-- Download


Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Beta flight settings caddx vista... whatever 19 9,549 22-Jun-2023, 03:10 PM
Last Post: mattyfleischfpv
  Using a old aio fc as a wireless sim controller Rob Axel 7 841 06-Sep-2022, 02:06 AM
Last Post: Rob Axel
  Flight data / Telemetry K.Flucas@937 5 2,985 14-Nov-2020, 10:42 PM
Last Post: EVILsteve
  Tutorial Turning Off Inversion Circuit on F4 Flight Controller voodoo614 7 9,568 25-Oct-2020, 07:26 AM
Last Post: jseaber
  Mavic Pro Controller Hack Treetops 5 1,728 03-Apr-2020, 11:11 AM
Last Post: SnowLeopardFPV


Login to remove this ad | Register Here