oppa_copter
Posts: 2
Joined: Mon Sep 24, 2012 5:06 pm

Rasberry Pi Controlled Quadrotor

Mon Sep 24, 2012 5:28 pm

Hello, I am working on a senior design project for my university. I am an CE/EE major. My design team plans to make a quadrotor that will be controlled via an android application. We are planning to use the rPi as the control board for this. We are looking for advice regarding how to connect and interface with the various sensors required for this project's functionality.

We will need to use:
-accelerometer and/or gyroscope
-compass
-gps
-wifi
-video camera
We will also need to control the 4 motors (possibly using pwm).

Would the rPi GertBoard be a suitable hardware interface?

Any advice regarding where to purchase these sensors and what kind to order would be much appreciated.

User avatar
patolin
Posts: 122
Joined: Mon Jan 09, 2012 3:25 pm
Location: Cuenca, Ecuador
Contact: Website

Re: Rasberry Pi Controlled Quadrotor

Tue Sep 25, 2012 6:28 am

to be honest I dont think that the PI will work forma a quad. may be for wifi connection but no for realtime control. you may buy any multicopter board and use uart ti control it from the PI
Patricio Reinoso - www.patolin.com

GrayHatter
Posts: 18
Joined: Tue Sep 25, 2012 6:29 pm

Re: Rasberry Pi Controlled Quadrotor

Tue Sep 25, 2012 6:33 pm

My friend and I are working on a similar project. We've decided that for what we want to do we need realtime support and don't want to build it into a Raspi yet, so we're pairing it with an Arduino board for flight control.

User avatar
rew
Posts: 423
Joined: Fri Aug 26, 2011 3:25 pm

Re: Rasberry Pi Controlled Quadrotor

Mon Oct 01, 2012 1:12 pm

I'd think that realtime flight control is best done in a microcontroller like the arduino or just the bare processor like the atmega168.

Normally you'd have radio remote control to give it highlevel commands: bit left, up down.

But adding a 'pi that can give it those highlevel comands, go to GPS xxx, take a picture, etc etc makes things very interesting... :-)
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

oppa_copter
Posts: 2
Joined: Mon Sep 24, 2012 5:06 pm

Re: Rasberry Pi Controlled Quadrotor

Mon Oct 01, 2012 3:28 pm

rew wrote:I'd think that realtime flight control is best done in a microcontroller like the arduino or just the bare processor like the atmega168.

Normally you'd have radio remote control to give it highlevel commands: bit left, up down.

But adding a 'pi that can give it those highlevel comands, go to GPS xxx, take a picture, etc etc makes things very interesting... :-)
Since I am still fairly new to this, please excuse the dumb question, but why would the RPi not be good for real-time calculations?
I have heard that using an Arduino would be a good approach to this project, and am not opposed to it, but I did find this library that was written to provide some Arduino functionality to the RPi. Do you think that this would be able to accomplish the hardware integration and real-time control needed?
Thank you for your feedback!

GrayHatter
Posts: 18
Joined: Tue Sep 25, 2012 6:29 pm

Re: Rasberry Pi Controlled Quadrotor

Mon Oct 01, 2012 4:09 pm

The problem is not that the Raspi can't do it all but that it also has to do other things too.

i.e. reorganizing memory, deleting tmp files, calculating uptime, running cron jobs, moving log files.

Because of that if you want to bank left but the Raspi wants to log 'x' then your command will have to wait and if rotor A gets the command but rotor B has to wait your quadrotor crashes... literally

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Rasberry Pi Controlled Quadrotor

Tue Oct 02, 2012 12:19 am

It appears that ChibiOS has just been ported for the Pi but is still having its wrinkles ironed out. I think alot of people confuse the Pi with Linux. Linux is not an RTOS but that does not mean the Pi hardware is incapable of RT control. You might see some ChibiOS based projects that showcase the Pi's potential in the near(ish) future...
Ostendo ignarus addo scientia.

cTn
Posts: 49
Joined: Sat Aug 11, 2012 4:11 pm
Contact: Website

Re: Rasberry Pi Controlled Quadrotor

Tue Oct 02, 2012 1:45 pm

oppa_copter wrote:
rew wrote:I'd think that realtime flight control is best done in a microcontroller like the arduino or just the bare processor like the atmega168.

Normally you'd have radio remote control to give it highlevel commands: bit left, up down.

But adding a 'pi that can give it those highlevel comands, go to GPS xxx, take a picture, etc etc makes things very interesting... :-)
Since I am still fairly new to this, please excuse the dumb question, but why would the RPi not be good for real-time calculations?
I have heard that using an Arduino would be a good approach to this project, and am not opposed to it, but I did find this library that was written to provide some Arduino functionality to the RPi. Do you think that this would be able to accomplish the hardware integration and real-time control needed?
Thank you for your feedback!
The simple answer is "no" i tried, and its not possible (you can do realtime operations on a non-realtime system like linux) and second, there is a custom kernel driver with will allow you to generate/drive multiple PWM outputs (which in your case are speed controller inputs), it won't be fast enough, as the required adjusting frequency between rotors and stabilization should be at least evey 10ms) and the driver can change the output every 20ms.

If you want you can have a look at my Phoenix project (which is an raspberry pi controller quadcopter)
http://www.ctn-dev.org/index.php?page=phoenix

I usually idle in the #arduino IRC channel, in case you would need some "quick help" or have some quick questions you can contact me or some of the guys over there :-)

User avatar
rew
Posts: 423
Joined: Fri Aug 26, 2011 3:25 pm

Re: Rasberry Pi Controlled Quadrotor

Tue Oct 02, 2012 3:16 pm

The raspberry pi is quite capable of doing real-time things. It usually even manages the USB system! (which is a real-time task on the raspberry pi).

However, the advantage of the raspberry pi is that it's easy to program because it has a full linux system on it. And having a full Linux system means that it is difficult to get real-time performance.

So, unless you're willing to go "bare bones" with the raspberry pi, I'd suggest you stick with the real-time things on proven platforms like AVR, and use the raspberry pi for the higher level things.
(Pay my salary for a year and I'll gladly prove it possible that you can run the quadrotor real-time thingies on the raspberry pi.... )
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Rasberry Pi Controlled Quadrotor

Tue Oct 02, 2012 3:42 pm

I need also 10ms responsiveness on my self-balancing robot and am excited by the ChibiOS port - how much is your salary for a year?
Ostendo ignarus addo scientia.

cTn
Posts: 49
Joined: Sat Aug 11, 2012 4:11 pm
Contact: Website

Re: Rasberry Pi Controlled Quadrotor

Tue Oct 02, 2012 3:49 pm

rew wrote:The raspberry pi is quite capable of doing real-time things. It usually even manages the USB system! (which is a real-time task on the raspberry pi).

However, the advantage of the raspberry pi is that it's easy to program because it has a full linux system on it. And having a full Linux system means that it is difficult to get real-time performance.

So, unless you're willing to go "bare bones" with the raspberry pi, I'd suggest you stick with the real-time things on proven platforms like AVR, and use the raspberry pi for the higher level things.
(Pay my salary for a year and I'll gladly prove it possible that you can run the quadrotor real-time thingies on the raspberry pi.... )
Yes, you "can" achieve an realtime-like behavior on the rpi, but bear in mind that there is only one pin that supports hardware pwm generation for the servos/speed controllers, even if you would manage to get fast enough response from the stabilization algorithm, the single pwm generation split into buffers for 4 pins would never be fast enough for a real-time project like quadcopter stabilization or balancing robot.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Rasberry Pi Controlled Quadrotor

Tue Oct 02, 2012 4:43 pm

Hopefully not a problem - Im using an additional I2C board for my pwm - faster SPI equivilents are also available.

If I succeed in balancing my robot using this + chibiOS then you should be able to use the same approach to fly a quad-copter...

I think it's possible.

It might even be possible just using Pi + Linux - see http://www.raspberrypi.org/phpBB3/viewt ... 37&t=15011 - although talking about servos, this gives an indication of the pwm performance acheivable.

To my mind the biggest obstcle is the weight of the lipos required to power the Pi.
Ostendo ignarus addo scientia.

merlz42
Posts: 25
Joined: Sun May 13, 2012 1:19 pm

Re: Rasberry Pi Controlled Quadrotor

Thu Oct 04, 2012 1:04 am

The pi should be fast enough to do control tasks (like integrate gyro + other sensors and give desired motor speeds) but something not running a full OS (like an arduino) is ideal for really timing sensitive stuff. In my experience, it's good for robotics projects to do control stuff on the CPU side, but send the motor commands to a microcontroller to manage. Timing accuracy of 20ms is nothing for an arduino, but for a raspberry pi your might want to update more like every 200ms. Using both together usually wins.

jfornango
Posts: 113
Joined: Fri Sep 14, 2012 7:46 pm
Location: St. Louis, MO USA
Contact: Yahoo Messenger

Re: Rasberry Pi Controlled Quadrotor

Fri Oct 05, 2012 8:00 pm

I think you definitely want to consider splitting the functionality between two platforms.

With the full LINUX OS on the RPi, I'd use that to drive the WiFi, GPS, compass and video camera. That puts communication and navigation together.

I'd use an Arduino (maybe a Mega) to handle the gyro, accelerometers and motor control. This allows the Ard to be dedicated to platform stability (you can set it up to auto-stabilize if the acceleration or gyro angles go beyond vehicle specs)

Have the RPi and Ard talk to each other over serial (via GPIO).

This sounds like a really slick project. Would love to see photos and documentation of the finished product.
I'm only wearing black until they find something darker.

cTn
Posts: 49
Joined: Sat Aug 11, 2012 4:11 pm
Contact: Website

Re: Rasberry Pi Controlled Quadrotor

Fri Oct 05, 2012 8:03 pm

jfornango wrote:I think you definitely want to consider splitting the functionality between two platforms.

With the full LINUX OS on the RPi, I'd use that to drive the WiFi, GPS, compass and video camera. That puts communication and navigation together.

I'd use an Arduino (maybe a Mega) to handle the gyro, accelerometers and motor control. This allows the Ard to be dedicated to platform stability (you can set it up to auto-stabilize if the acceleration or gyro angles go beyond vehicle specs)

Have the RPi and Ard talk to each other over serial (via GPIO).

This sounds like a really slick project. Would love to see photos and documentation of the finished product.
http://www.ctn-dev.org/index.php?page=phoenix

ill be putting some fresh photos tomorrow, (my setup is basically what you just said) :)

cTn
Posts: 49
Joined: Sat Aug 11, 2012 4:11 pm
Contact: Website

Re: Rasberry Pi Controlled Quadrotor

Sat Oct 06, 2012 2:36 pm

as i promised, new gallery pictures capturing the rpi and arduino are up :)

User avatar
Christoph
Posts: 9
Joined: Fri Jun 01, 2012 7:33 pm
Location: Germany

Re: Rasberry Pi Controlled Quadrotor

Sun Oct 07, 2012 5:18 pm

Nice Job so far. I'm also working on a AMR Cortes M4 quadcopter control bord and I'm also thinking about using the RPI as a high level brain. However I'm still at the low level part and hardly making any progress.

There's one thing I am particularly interested in. I admit, I did not dig very deep in your source code. Could you point out how you implemented the sensor fusion of gyro / acc and magnetometer ? I've read some papers so far (which already gave me a headache).

Regards
Christoph
Not everything is great

cTn
Posts: 49
Joined: Sat Aug 11, 2012 4:11 pm
Contact: Website

Re: Rasberry Pi Controlled Quadrotor

Sun Oct 07, 2012 7:46 pm

Christoph wrote:Nice Job so far. I'm also working on a AMR Cortes M4 quadcopter control bord and I'm also thinking about using the RPI as a high level brain. However I'm still at the low level part and hardly making any progress.

There's one thing I am particularly interested in. I admit, I did not dig very deep in your source code. Could you point out how you implemented the sensor fusion of gyro / acc and magnetometer ? I've read some papers so far (which already gave me a headache).

Regards
Christoph
at the moment i have only 6 axis dof (i got some initial support for magnetometer) but its not yet implemented to output 9 axis dof, in my case i am using mpu6050 which has DMP build in, with some initialization code you can get the 6 axis dof to work "out of the box", according to documentation you should be able to implement 9 axis dof directly on the DMP, but the creators of this chip left the DMP part quite undocumented, so getting more then 6 axis to work requires calculation on the "master" side, in my case an arduino, from the DMP you get nice and "smooth" quaternion, from witch you can calculate the gravity vector and yaw pitch roll (which is basically what you need for a nice quad stabilization), "reading" my code would probably be easier then what you can find in various papers.

I am still waiting to do an outdoor test flight, but the weather is horrible and my new propellers haven't arrived yet. But from my tests and PID calibration on a testing "stick" it seems to be working perfectly.

Return to “Automation, sensing and robotics”