3
$\begingroup$

I am starting to assemble a quadrotor from scratch.

Currently, I have this:

  • Structure;
  • an IMU (accelerometer, gyro, compass);
  • 4 ESCs and DC motors;
  • 4 propellers;
  • Raspberry Pi to control the system, and;
  • LiPo battery.

I have calibrated the ESCs and the four motors are already working and ready. But now I am stuck.

I guess the next step is to dive deeply in the control system, but I am not sure where to begin. I read some articles about the control using PIDs, but I don't know how many should I use, or whether I need to model the quadrotor first to compute kinematic and dynamic of the quadrotor inside the RPi. Sorry if the question is too basic!

More details

The structure is from a kit. Well, all I have now is the ESCs calibrated, although I do not have documentation of them to adjust the cut off voltage for the LiPo battery. I have been made tests with some Python code I found to have PWM outputs for the motors and to control I2C bus to communicate with IMU.

One of my problems now is that I need RPIO library for PWM and the quick2wire-python-api to work with the I2C libraries from the MIT to control my IMU but as far as I know RPIO works with Python2 and quick2wire works with Python3 so I don't know how to manage this.

So actually, I have no code yet to control the four motors in parallel, only have testing code to test them separately and also with the IMU.

About the IMU, I am still learning how to work with it and how to use the MIT library. The unit includes those sensors:

  • ADXL345
  • HMC5883L-FDS
  • ITG3205

You can see a picture of the quadrotor below,

Quadrotor

So as I said before, I would like to know how to handle the control system and how it is implemented inside the Raspberry Pi, and then start to work with the Python code to assemble the motors, the IMU and the control.

$\endgroup$
3
  • $\begingroup$ Can you elaborate more on how much all of this is assembled and ready to fly? There are a lot of different things you are going to have to do if you are starting from scratch, balancing and trimming the thrust distribution between rotors, calibrating your IMU, etc. Is this something built from a kit or have you carved it out of wood yourself? Show us a picture! $\endgroup$ Commented Nov 12, 2015 at 21:40
  • $\begingroup$ I have edited the post with more details! $\endgroup$
    – osuarez
    Commented Nov 13, 2015 at 8:18
  • $\begingroup$ Is the code you are working on open source? I'm working on a project that uses RPi with a 10-DOF IMU. I've been porting code to Java based on the implementations from Arduino and would be very interested in seeing how you are doing it. $\endgroup$ Commented Dec 8, 2015 at 21:57

2 Answers 2

2
$\begingroup$

I would advise against using a Raspberry Pi for your flight control. The Raspberry could be used for higher level decision making algorithms with regards to automation of your vehicle, but the vehicle also needs some real-time algorithms that can react instantaneously to deviations from desired attitude, etc.

The reason the Raspberry is not the best for this is because it is OS based which means that at any moment in time it could preempt your flight control logic in order to service another request from the OS. This is not what you want. I'm not saying its impossible to do this on an ARM chip but using a Linux based solution would be less than optimal.

There are Arduino boards that are ARM based which are not pre-emptive, but then there are also less expensive arduino (AtMel chips) that would have ample processing speed to handle the flight controls.

There are several affordable of flight controllers that are available to the hobbyist including:

  • Naze
  • Ardupilot
  • MultiWii
  • CC3D
  • KK2

If you are wanting to write the software yourself, I would suggest buying a MultiWii or CC3D board. Those are basically an arduino with all of the sensors that you would need to control a flying vehicle already attached to the board (accelerometers, gyros, barometer, magnetometer) and with serial ports so you can easily attach GPS, On-screen displays, radio links, etc, etc. Then you only need the basic Arduino developer's kit (opensource) to start coding in C.

You can check into other opensource software solutions that will work on some of these boards such as MultiWii, ArduPilot or OpenPilot.

I would strongly suggest starting with one of these ready-to-go solutions first as you will soon discover that your vehicle will require plenty of attention as far as tuning, balancing and calibrating before it will be airworthy. You might discover that your design isn't well suited to the motors you bought and you might have to buy different kV motors or adjust prop sizes to compensate. Once you know it can fly then you might want to start experimenting with adjusting the code in the existing opensource packages or if you're really bold, build new code from scratch.

$\endgroup$
2
  • $\begingroup$ Thanks for your comment!! Is not there any RTOS available for Raspberry Pi? In fact Linux OS can be made RTOS with some patches. And about writing the code, how should I start to coding the control system? What to stabilize first? Is the PID the best design for quadrotor? $\endgroup$
    – osuarez
    Commented Nov 16, 2015 at 9:41
  • $\begingroup$ i agree with your thinking...but how to interface raspberry pi with cc3d , i have arduino 2560 and cc3d , now i want to control through a server via wifi...i will write the server code..but i dont have any clue about connections..pls help $\endgroup$ Commented Jun 7, 2016 at 6:44
1
$\begingroup$

Helping with inspiration

Hello,

I suggest you to evaluate separately the altitude and attitude dynamics. Then you can start thinking in the control you need to achieve your own objectives.

For example:

The altitude of a Quadrotor is how high it can get. For this, we need to have a mathematical model:

quadrotor schematic

For this approach, you should read about euler angles & rotation matrices.

From Newton's equation:

$\ddot{z} = \frac{1}{M}{\cos(\phi)\cos(\theta)\sum_{n=1}^{4} \omega_n^{2}} - g$

Where the expression can be derived from the relationship of the two frames represented in the figure above! Please, observe that the angles are essential to control the altitude, but we can do (and should do!) some approximations to simplify our model. Suppose $\phi$ and $\theta$ very small

$\ddot{z} = \frac{1}{M}{\sum_{n=1}^{4} \omega_n^{2}} - g$

(...)

For more, I recommend this book here

Hope I have inspired you to start your cool project. Good luck!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.