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

 

 

 

 

Views: 3682

Comment by Sebastian Gralla on August 30, 2011 at 12:24pm

great simulation jason!

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

Comment by Björn Pettersson on August 30, 2011 at 12:32pm

Looking forward to test this, great simulation btw!

Comment by Vincent Mees on August 30, 2011 at 1:23pm

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.


Moderator
Comment by John Church on August 30, 2011 at 1:32pm

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

Comment by Sebastian Gralla on August 30, 2011 at 2:58pm

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


Developer
Comment by Jason Short on August 30, 2011 at 3:05pm

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;
}
}
}
}

Comment by Kirill on August 31, 2011 at 12:33am

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

Comment by Lee Williams on September 1, 2011 at 1:24pm

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

Comment by Hein on September 1, 2011 at 1:31pm

Hi Jason,

That is very good news!  Will this solution also work for GPS hold?, to make it also more accurate?  And even waypoint navigation?

Greetings,

Hein


Developer
Comment by Jason Short on September 1, 2011 at 1:32pm

Yes, Testing it today. Loiter and RTL are sooo much better. It's stunning.

Jason

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service