Quadrotor autopilot in Simulink

Hello,

I am working on my bachelor thesis about programming the autopilot of a quadrotor with Simulink. However, I am having some problems.

The main block is 6DoF Euler Angles, where the inputs are the weight, the thrust of the four rotors and the moments. The thrust is calculated according to:

T=cT*rho*pi*omega^2*r^4  (propeller PER3 10x45MR)

The objective is to create four PIDs, for the speed in X and Y directions, for altitude (Z) and for yaw angle (psi).

In "quadrotor_GOOD3", I created a PID for the altitude (required 100 meters) and another one for the yaw angle (required 50 degrees). It seems to work properly.

However, in "quadrotor_GOOD4", I tried to create the PID for the speeds in X and Y directions but no matter what I do, they are unstable.

INSTRUCTIONS FOR RUNNING:

1. Run "gravity.m".

2. Simulate "main_gravity.mdl".

3. Run "Data.m".

4. Run the proper simulation "Quadrotor_GOOD…".

Please find the rest of files attached in a reply, since I couldn't attach more files.

Could anyone please help me?

Thank you very much

gravity.m

Data.m

quadrotor_GOOD3.mdl

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Other references:

    http://eprints.qut.edu.au/33767/1/33767.pdf
  • Hello,

    I had the time to take a look at it. Some observations on the model itself:

    • Do you really need to compute the gravity acceleration? Can't you simply put 9.81 m/s2? The variations along the world are less than 2%...
    • Your inertia is too big imho, 1kg*m2 for each axis for 1kg copter means a lot, but I guess you are just making some tests before actually computing it.
    • The most important missing part is some aerodynamic drag effect: this means that your copter will have a constant speed in all directions, making the height control unrealistic and lateral movements also. You can model it as an aerodynamic drag and making the thrust depending on the propeller inflow (which is the better approximation of reality). In this way your PID tuning will be more realistic.

    On the Control Law:

    • On the X speed control, I feel you should control the copter roll and pitch angles, instead of the thrust directly: associate an inner PID to achieve a demand on roll/pitch angles via thrust differential, and an outer PID loop to achieve a speed demand with angle control. A specific angle is associated to a specific speed only if you add aerodynamic drag, we go back to the modeling problem. I think the control should work even without the drag if you threat the angle as an acceleration, do you follow me?

    Ciao,

    Michele

    P. S.: will I have the final model when you'll finish the thesis? I want to play with it :)

    • Hello,

      • I know I don't really need to compute the gravity acceleration, but since it is easy to obtain it, I just included it in the model.

      • What do you mean about the inertia? Where is it 1kg·m^2?

      • I wanted to include some aerodynamic drag, but I really don't know how. Could you guide me a little?

      Thanks a lot again :)

      P.S.: yes, of course you can have it!

        • In the 6DoF EoM block, you have to set the mass and the inertia of the rigid body (default is mass=1 and Inertia matrix=eye(3) which is the identity matrix). Double click on it to set them! I guess you have some basic mechanic knowledge, do you?
        • You can add a force = -1/2 * Cd * rho * Sref *V^2 with the direction equal to the speed vector. Cd is the drag coefficient (you can put 0.3 considering the copter an average bluff body) and Sref a reference surface (the projected area from the top view, for example).
        • Propeller inflow: you can read paragraph 5.3.1 of this thesis of Brian Decimo Marchini (who is also a member of Diydrones community) who did a very interesting job of modeling and controlling a model A/C. This will make the vertical speed control much more realistic.

        Ciao,

        Michele

        http://digitalcommons.calpoly.edu/cgi/viewcontent.cgi?article=2202&context=theses
  • Rest of the files:

    quadrotor_GOOD4.mdl

    main_gravity.mdl

  • Hi,

    I'm quite interested in dynamic systems modelling, therefore I would like to help, but your Data.m is not running as you uploaded it, and debugging is quite boring on others' code:

    Undefined function or variable 'gz'.

    Error in Data (line 62)
    Fg=gz(end)*m; % Gravity force in Z direction of the body frame [N]. Execute only when the input thrust is the
    required for hovering.

    If you upload a working version I can give it a try.

    Michele

    • Hello Michele,

      You are right, my code was not working properly. Please, re-read the instructions and find new files attached.

      Thank you very much for your interest.

This reply was deleted.

Activity