Developer

Arducopter Alt hold

3689422262?profile=original

This is a simulation I'm working on to improve the Altitude hold and change control laws. I have identical code from Arducopter running in Flash as OO Javascript so I can ensure the behavior is the same as the real thing. I sampled data from the barometer to introduce identical noise into each copter's solution. This allows me to test PID and other tricks side by side and see how the copter will behave. The copter itself is a simple physics equation and should be fairly accurate.

 

The Hover value is in your logs when you switch to Alt Hold. You should see it with the mode switch name. Mine was 495 which is the equivalent of 49.5% throttle. A lower value has a profound effect on the flight so play around with that.

 

The A copter is the current control solution. The B and C copters are Pi->Pi rate based solutions and are identical. You can adjust PID setting to pit the two against each other.

 

The scale on the left is meters. The Sonar is active and the mix is identical to the current AC2 solution.

 

This new code is in testing and will be available next week in 2.0.40b

Jason

 

 

 

 

E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Hi Jason, great programme, alt hold is the major issue I am struggling with, am I to take it that with alt hold there should be no I value, what values make this model most stable, is it possible to make the flas model perfectly stable, if so, what values do you set

  • That's great, thanks! Looking forward to test!

  • Developer

    That's what I believe as well. A heavy craft may have a higher value. A powerful one will have a lower value. In the end it's the thrust vs gravity. Here is the sim code:

     

    package com {
    import flash.display.MovieClip;
    import com.Location;


    public class Copter extends MovieClip {

    var loc:Location;
    var actual:Location;

    var mass :Number = 1;
    var altitude_rate :Number = 9;
    var throttle :Number = 0;
    var gravity :Number = 981;
    var thrust :Number = 1.6545;
    var scaler :Number = 1;
    var velocity :Number = 0;

    public function Copter() {
    // constructor code
    actual = new Location();
    }

    public function init(hold:Number)
    {
    thrust = gravity / hold;
    }

    public function update(dt:Number)
    {
    //throttle = Math.max(throttle, 0);
    // 500 * .01 = 5/10 = .5;

    var accel = (throttle * thrust)/mass;
    accel -= gravity;

    actual.alt += velocity * dt + .5 * accel * dt *dt

    velocity += accel * dt;

    //trace ("loc.alt "+loc.alt);

    copter_mc.y = -actual.alt/2;
    copter_mc.y = Math.min(copter_mc.y, 0);

    if(copter_mc.y == 0){
    //actual.alt = 0;
    velocity = 0;
    }
    }
    }
    }

  • John: the only input you need is your hover throttle, which depends on your setup.

    it includes weight, motor types and everything else you could vary

  • Moderator

    Very cool. Say, what are the parameters of your copter equation? Any provision for specifying custom weight, etc?

  • Really cool, hope it helps alot.

    Any news on the alt hold issue in version 38, 39 and 40 were certain people get 137m as altitude and during AH at low altitude flight, seems to be using baro as reference.

  • Looking forward to test this, great simulation btw!

  • great simulation jason!

    I love that it's so much like the real bahaviour

This reply was deleted.