Hi Doug

I have an understanding problem with tuning the PID's.

I followed your instructions in the manual.

I adjusted the servo_roll P to 1.2 and the plane acts very crisp as in manual. But 45° angle is achived by maybe 30% stick input.

With this setting all settings for nav tend to overshoot or to miss waypoints. The best I found for nav was 0.8/0.18/0 & XTrackGain 0.8.

When heading for home after switching to RTL, it flies straight and level in direction home but never loiters "round". When flying a mission the plane turns maybe 160° at the 1st wp before turning the other way around for the next WP (flying "S"). When I reduce nav P, it almost never finds the next wp.

Now I wonder if I should set the servo_roll to a "linear resolution" for the stickmovement. eg 100% stick -> 45°, 50% stick 22.5% ect. and add some I to have it "crisp".

 

I am stuck at the moment. I need a push in the right direction.

Thanks in advance for your advice.

 

Christof

 

 

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

Join diydrones

Email me when people reply –

Replies

  • Hi Doug

    I made the logging work with CLI -> disable cur, enable cur. Last time I used disable all and then enabled log by log.

    As soon as I have a log, I will let you know. But the next days are not very promissing. Too much rain.

    Best

    Christof  

     

  • Doug

    I was flying today and the code is awsome. The last flight was the "best" regarding orientation of the plane. Unfortunately there where no logs recorded although they where enabled.

     

    I think we can close this now.

    Christof

     

  • Hi Doug

    I was looking at the sin() & cos() as well but I does not seem to solve the problem. We have good corrections this way at east orientation only. If you find a solution without trigo functions - good. I stop then refreshing my geometry skills and wait what you come up with.

    Best

    Christof 

  • Doug

    I was flying the SQRT corrected compass today. The syptoms persist. Whenever nav_roll turns negative, compass has an upper and a lower cap.

    Ah, when we power two negative values we get a positive value. But for one side correction we need positive and for the other we need negative. I go on digging later on.

     

    Christof

     

    07-05-11 11-45 5.log

  • Doug

    a simple question

    Trigo definition: sin2 A + cos2 A = 1

    in Compass.pde Line 78

    sin_roll = 1  - (cos_roll * cos_roll);

    in MHO it should read sin_roll = SQRT( 1 - cos_roll2) according to the trigo rules.

    same for sin_pitch.

    I did not calculate it yet to test the values.

    Christof

  • Doug

    I have two logs ready for you with extended logging

    1. Compass enabled: FBW A - AUTO - FBW A l&r circles

    2. Compass disabled: FBW A - AUTO, the Mission was completed although the PID's really would need some tuning....  

     

    Best

    Christof

    05-05-11 09-31 1.log

    05-05-11 09-33 2.log

    https://storage.ning.com/topology/rest/1.0/file/get/3692207070?profile=original
  • Developer
    OK Christof,

    I cannot get it to act up on the bench, so we will need to gather some more detailed data while flying. Below are two new replacement functions for the NTUN logging. If possible please make one flight flying the mission you have been flying and one flight in FBW-A where you fly several sets of 3 circles to the right and then 3 circles to the left.



    // Read a nav tuning packet
    void Log_Read_Nav_Tuning()
    {
    Serial.printf_P(PSTR("NTUN: %4.4f, %d, %4.4f, %4.4f, %4.4f, %4.4f, %4.4f,"), // \n
    (float)((uint16_t)DataFlash.ReadInt())/100.0,
    DataFlash.ReadInt(),
    (float)((uint16_t)DataFlash.ReadInt())/100.0,
    (float)((uint16_t)DataFlash.ReadInt())/100.0,
    (float)DataFlash.ReadInt()/100.0,
    (float)DataFlash.ReadInt()/100.0,
    (float)DataFlash.ReadInt()/1000.0);
    Serial.print(comma); // Just a temp hack
    Serial.print(DataFlash.ReadInt()); // Just a temp hack
    Serial.print(comma); // Just a temp hack
    Serial.print(DataFlash.ReadLong()); // Just a temp hack
    Serial.print(comma); // Just a temp hack
    Serial.print((float)DataFlash.ReadInt()/1000); // Just a temp hack
    Serial.print(comma); // Just a temp hack
    Serial.print((float)DataFlash.ReadInt()/1000); // Just a temp hack
    Serial.print(comma); // Just a temp hack
    Serial.print((float)DataFlash.ReadInt()/1000); // Just a temp hack
    Serial.print(comma); // Just a temp hack
    Serial.println((float)DataFlash.ReadInt()/1000); // Just a temp hack
    }



    // Write a navigation tuning packet. Total length : 18 bytes
    void Log_Write_Nav_Tuning()
    {
    Matrix3f tempmat = dcm.get_dcm_matrix();
    DataFlash.WriteByte(HEAD_BYTE1);
    DataFlash.WriteByte(HEAD_BYTE2);
    DataFlash.WriteByte(LOG_NAV_TUNING_MSG);
    DataFlash.WriteInt((uint16_t)dcm.yaw_sensor);
    DataFlash.WriteInt((int)wp_distance);
    DataFlash.WriteInt((uint16_t)target_bearing);
    DataFlash.WriteInt((uint16_t)nav_bearing);
    DataFlash.WriteInt(altitude_error);
    DataFlash.WriteInt((int)airspeed);
    DataFlash.WriteInt((int)(nav_gain_scaler*1000));
    DataFlash.WriteInt((int)(wrap_360(ToDeg(compass.heading)*100)/100)); // Just a temp hack
    DataFlash.WriteLong(compass.last_update); // Just a temp hack
    DataFlash.WriteInt((int)(tempmat.b.x*1000)); // Just a temp hack
    DataFlash.WriteInt((int)(compass.heading_x*1000)); // Just a temp hack
    DataFlash.WriteInt((int)(tempmat.a.x*1000)); // Just a temp hack
    DataFlash.WriteInt((int)(compass.heading_y*1000)); // Just a temp hack
    DataFlash.WriteByte(END_BYTE);
    }
  • Doug

    I see. When I inserted the extra log I was not aware of that. I only corrected the "comma" and "line" thing to get the log readable. I do not understand why the logged yaw values do not oscilate 0-360° when the plane circels but they oscilate somewhat 10°-60° .

     

       

  • Developer
    Christof - if you are looking at your logs from today and see that the compass heading value is goofy part of the time that is simply because I used the wrap_360 function incorrectly in the log.  It does not appear that the compass "locked up" at any point.  You can see that the last update time increments throughout the flight.
  • Doug

    Jason

    In navigation.pde update_crosstrack(void) crosstrack following is limited to 45° "off track"

    if (abs(wrap_180(target_bearing - crosstrack_bearing)) < 4500)

     

    Where do we go if nav_bearing is not updated?

     

     

     

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…