3D Robotics
In addition to the setting you can change from the desktop utility program (rudder and elevator trim, max speed, waypoints and home postition), these are the settings you can change from within the code itself. They're all at the top of the first tab of the code (called "ArduPilot_EasyStar_WP_PRO). My annotations and instructions are in [brackets]: Especially note the settings at the bottom that allow you to reverse servo travel and say whether your FMA sensor is pointed forwards or backwards: [maximum servo throw in each direction] #define servo_max 2000 //For servos pitch and roll #define servo_min 900 [PID gains for navigation: In general when tweaking PID gains to reduce quick oscillations you must decrease the P, to reduce long oscillations also reduce I, the derivative is to slow down oscillations but is not implement due to the lack of refresh rate.] #define head_P 1.2 //.7 Heading error proportional (same used to move the rudder)... #define head_I 1.5 //heading error integrator Not used for navgiation #define head_error_max 35 //The maximun output in degrees to control the roll setpoint #define head_error_min -35 //The min output in degrees to control the roll setpoint [PID gains for roll stabilization. Same as above #define roll_abs .3 //Set point absolute proportional... I don't know how to explain it... #define roll_P .8 //roll PID proportional #define roll_I 1.3 //roll PID integrator #define roll_min -45 //55 //PID output limit in servo degrees #define roll_max 45 //PID output limit in servo degrees #define roll_comp 0 #define roll_Integrator_max 35 #define roll_Integrator_min -35 [PID gains for altitude control. Same as above] #define alt_P 2 //proportional to control the altitude hold... #define alt_error_max 0 //The maximun output in degrees to control the pitch setpoint #define alt_error_min -10 //The min output in degrees to control the pitch setpoint #define throttle_max 1800 //In us seconds #define throttle_min 1200 #define throttle_dead_zone 20 //In porcent #define throttle_absolute 3 #define throttle_kp 2 #define throttle_ki 1 #define throttle_max 80 #define throttle_Integrator_max 50 #define AirSpeed_Central 25 [PID gains for pitch control] #define pitch_P .9 #define pitch_I 1.5 #define pitch_min -50 #define pitch_max 50 #define pitch_Integrator_max 25 #define pitch_Integrator_min -25 #define PID_dt 20 //Servo refresh time in milliseconds [Says whether a Z sensor is present or not. [Note: autopilot will not properly calibrate without one] #define SENSOR_Z 1 [Says whether the FMA sensor is pointed forward or backwards] #define REVERSE_X_SENSOR 1 //1 = cable behind, 0 = cable front [If your servos are reversed set these to 1 instead] #define REVERSE_ROLL 0 //To reverse servo roll #define REVERSE_PITCH 0 //To reverse servo pitch
E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Belatedly, I looked at this code. I am not a C expert but I noticed the constant "throttle_max" has its value defined twice. Is this an error?
  • Moderator
    Thanks Bryan, that says it well and hence my request for help on explaining these parameters.

    While flying my aircraft, I see what I feel it is doing wrong and then try to find the parameter in the code that will correct/improve that behavior which is very time consuming, it's all very well looking at PID theory but a lot of that is so technical one comes away more confused than before.

    Proportional "to the error" makes more sense now, but for those of us who are just trying to get our planes to fly acceptably and who aren't clued up in C and/or the effects of the various parameters in very hard to understand all that's going on and the comments in the code aren't much of a help

    e.g. I'm trying to understand the difference between 'absolute proportional' and 'proportional' and why Roll has it but Pitch doesn't... ? or what #define roll_comp is which doesn't have any comments/explanation.
  • What Graham might be getting at is:
    There is already a #define roll_P and a #define pitch_P that handles the errors in course and altitude. So, what does #define head_P and #define alt_P do for you? Looking at the same errors?
    This is where Jordi's write ups on the Ardupilot will be a big help in tuning our planes to fly.
  • 3D Robotics
    Graham,

    Please see the posts here on PID theory, but the short version is "proportional to the error". The further off course you are, the more it will turn.
  • 3D Robotics
    David,

    RTL is the the top position of the switch. So if you have a two position switch, it's just "on". If you have a three position switch, Waypoint mode is the middle and RTL is the top. You can change that in the code if you want. IN the System tab, the code is here:

    byte Tx_Switch_Status(void) //Return zero when we are in manual mode, return 2 when autopilot mode 0, return 3 when autopilot mode 1...
    {
    if(digitalRead(4)==HIGH)
    {
    if(digitalRead(5)==HIGH)
    return 0x01; // WP mode
    else
    return 0x02; // RTL mode
    }
    else
    return 0x00;
    }
  • Moderator
    #define head_P 1.2 //.7 Heading error proportional

    Proportional to WHAT? (dictionary - proportional - Properly related in size or degree or other measurable characteristics; usually followed by 'to')
    Also what increments would one increase or decrease this value?

    #define roll_abs .3 //Set point absolute proportional

    again proportional to what?

    thanks
  • @Chris: I realized the "#define RTL" is gone. So in ardupilot 2.1, how do we trigger "return to home"? must use a 3 position switch?
  • Got it Chris. Thanks. I want to try it out this afternoon in my Easyglider if the wind ever calms down!
  • OOPS, just realized I posted in the wrong place, I will delete and repost in the right section!
  • 3D Robotics
    Bryan,

    I think you downloaded an old version of code--all is there in the version I'm looking at. Please try again.
This reply was deleted.