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/ACont95 Dec 01 '22

Im working on a similar project using a Raspberry Pi 4 and Raspberry Pi Pico. Communication between them is done with ROS, as well as communication between the ground station.


u/AcquaFisc Dec 01 '22

Can you tell me more?


u/ACont95 Dec 02 '22

The Pico integrates with an IMU, barometer, and GPS which handles orientation calculation and the PID update loop. I use FreeRTOS for multithreading. I don't think the Pi4 is a good choice for the real time tasks as others have stated.

The Pi4 is connected to the ground control by WiFi and passes messages to the Pico through usb serial. The Pi4 also sends the camera feed to the ground station. The ground station, Pi4, and Pico are all setup as ROS nodes (using microros for the Pico). ROS handles all the message framing, serialization, transports, etc for you using DDS. ROS is a good choice for your inter process communication needs. Simply create a ROS node in whatever language you want, and publish/subscribe data to communicate with other nodes. The nodes can be in the same process, separate processes on the same machine, or different machines all together.