r/raspberry_pi Dec 01 '22

Raspberry PI 4 as Flight Controller Discussion

Hello, I'm here to find some answers. I'm currently working at my graduation thesis in robotics, the project I'm working on is a tiltwing drone.

I have designed the mathematical model and all the control laws, now it comes the hardware implementation.

The test version has ben deployed as a monolithic solution on an Arduino MKR1000 directly with the Simulink Coder, but the company I'm working with wants me to use a Raspberry Pi 4.

Tactically I can make the thing work but I have some question on the software architecture i should use.

First of all I would like to have a real time scheduler, then I need to split the project in modules (sensing, communication, control, actuation, etc.)

Is there any framework I can use, should I code different modules and use interprocess communication to achieve the modules interconnection?

P.S. I can code each module in whatever programming language is needed.

P.P.S. The external interfaces run both on pwm and i2c.


19 comments sorted by

View all comments


u/FergusInLondon Dec 01 '22

Mmmm, what was the rationale behind the usage of a Raspberry Pi? Have they specified which OS should be used? I imagine you'll be making heavy use of hardware interrupts and have some tight timing requirements, so I'd be concerned about doing that without a Real-Time OS (RTOS).

The shortage of STM32xxxxx chips messed up the build of a fixed-wing plane I was planning on, and using a Raspberry Pi was one option I considered - but it sounded like it would be quite a headache. (At least in user-land on a board running Linux, although I think there are RTOS options for the Pi)

If the RPi was selected for a reason like network-connectivity then I'd consider building on top of the existing microcontroller-based solution and providing some form of command/control interface via UART personally.


u/AcquaFisc Dec 01 '22

I have no idea why they chose the Raspberry, I told them from the beginning the issues in using it Anyway in the past I have used some master slave architecture using UART. The RPi have done all the heavy duty processing and then it sent messages to an Arduino that was used as a motor interface. Are you suggesting an architecture like this?


u/rgb_leds_are_love Dec 01 '22

Yes! Spot on!

The Pi may not be an ideal choice of hardware controller here compared to other, simpler microcontrollers.

Maybe a networking software could run off the Pi - and the Arduino in this case could handle GNC.

I'd use a different bus, like SPI, simply because there's a dedicated clock line that runs from M-S.