Is the AP_STICK MIXING Reversed in ArduPilot 2.6?

Hi,

 

I've been working with ArduPilot 2.6 load currently in the repository.

 

In my particular airframe, I need to reverse both the ailerons and the elevator, so in my header file, I have REVERSE_ROLL and REVERSE_PITCH both set to -1.

 

The FBW modes seem to work normally, however, STABILIZE and any AUTO mode (mode>FBW_B) the nudging function seems to be reversed to me.

 

Looking at the code, I notice that in the main loop we have the code for the FBW modes:

// fake Navigation output using sticks
  nav_roll = ((ch1_in - ch1_trim) * (long)HEAD_MAX * REVERSE_ROLL) / (ch1_max - ch1_trim);
  nav_roll = constrain(nav_roll, -HEAD_MAX, HEAD_MAX);

  // nav_pitch is the amount to adjust pitch due to altitude
  nav_pitch = ((ch2_in - ch2_trim) * -1 * (long)PITCH_MIN *  REVERSE_PITCH) / (ch2_max - ch2_trim);   // We use PITCH_MIN because its magnitude is normally greater than PITCH_MAX
  nav_pitch = constrain(nav_pitch, PITCH_MIN, PITCH_MAX);

 

While in the attitude tab we have the AP_STICK_Mixing code:

 

 if ((AP_STICK_MIXING == 1 && control_mode > FLY_BY_WIRE_B) || control_mode < FLY_BY_WIRE_A) { // if Controll mode is Auto/RTL/Loiter with Stick Mixing OR we're in STABILIZE
  ch1_inf = (float)ch1_in - (float)ch1_trim; //I wonder if the fact that there is no REVERSE controls here is why my STABILIZE mode appears to work backwards.
  ch1_inf = abs(ch1_inf);         
  ch1_inf = min(ch1_inf, 400.0);       
  ch1_inf = ((400.0 - ch1_inf) /400.0);
  ch2_inf = (float)ch2_in - (float)ch2_trim;
  ch2_inf = abs(ch2_inf);         
  ch2_inf = min(ch2_inf, 400.0);       
  ch2_inf = ((400.0 - ch2_inf) /400.0);
 }

 

Which does not use the REVERSE_PITCH/ROLL constants. On my aircraft the ailerons and elevator are correctly sensed when in either FLY_BY_WIRE mode, but are reversed in STABILIZE mode.

 

Is this a problem in the 2.6 code? I can see that this issue would not be caught unless one had to use the reversing function in the header file. On the otherhand, I'm still learning my way around this autopilot so there might be reversing logic deeper in the code that I haven't gotten to yet in my studies.

 

Cheers,

 

Tom

 

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

Join diydrones

Email me when people reply –

Replies

  • hi
    is it normal I've got no manual control over throttle while in stabilize mode (throttle is fixed at about 20%) ?

    regards
  • Developer
    Hey Tom and John,

    I have never tested the stick mixing, and now that I think of it I may never have tested FBW-B either, so it is quite possible that there is a bug there. I will check it out as soon as time permits.
  • I'm going to add a +1 to this. Same servo setup for me with a normal -1.

    I've had 2 flights with 2.6 now.

    First flight: Fairly good stabilization and navigation out of the box with -1. Nudging in AUTO mode was REVERSED.

    Second flight: Switched to 1 on REVERSE_PITCH/ROLL. Plane flies inverted.

    I finally sat down and bench tested this a bit more, and -1 is still the right setting for me but here are the issues.

    1) in AUTO mode nudging is reversed in its control input
    2) in FBW_B stabilization works well, but I have ZERO control input

    Manual mode works just fine. Let me know if there are any permutations that would help.

    Thanks!

    John C.
This reply was deleted.

Activity

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