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

 

Views: 241

Reply to This

Replies to This Discussion

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.
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.
Thanks for the reply Doug.

I was going to monkey around a bit with it as well. Seems like this would be a likely place to look in the attitude routine.

// Mix in stick inputs in STABILIZE mode or if AP_STICK_MIXING = 1
// ---------------------------------
servo_roll += (1.0f - ch1_inf) * (ch1_in - ch1_trim) * 45.0f / 400;
servo_pitch += (1.0f - ch2_inf) * (ch2_in - ch2_trim) * 45.0f / 400;


Any other tips on where else to look? In looking back at 2.5, you obviously handle attitude in a completely different way.

Thanks!

JC
Seems like this may be a suspect section in the main routine on the FBW_B issue.

if (control_mode == FLY_BY_WIRE_A || control_mode == FLY_BY_WIRE_B) {
// 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);
}
JC - looks like we just need REVERSE_ROLL and REVERSE_PITCH in the nudging calculation.

However I'm not seeing a problem with FBW_B right off. Can you please look at the code revision you are using and see if in the main file you see the line:
boolean takeoffComplete = 0; // Flag for using take-off controls

If so please change the 0 to 1 and retest.

Regards,
Doug
Hey Doug,

I don't think the problem exists in FBW_A or FBW_B. These are the two that work great for me with REVERSE_ROLL/PITCH set to -1

The problem exists for sure in STABILIZE mode for me, and I think also in AUTO modes. I haven't flown any AUTO modes yet, so I can't say for sure.
Nice work Doug. Changing the takeoffComplete variable to 1 gave me FBW control.

The control in FBW works accurately.

AUTO nudging is still reversed. I agree that the nudge calc is just missing the reverse vars.

Thanks! Looks like I should be able to get her back in the air today if the weather keeps cooperating.
I'm not much of a programmer, so I'm not sure if this is the right way to do it or not, but this is a fix that works for me.

In the attitude routine, change this:

// Mix in stick inputs in STABILIZE mode or if AP_STICK_MIXING = 1
// ---------------------------------
servo_roll += (1.0f - ch1_inf) * (ch1_in - ch1_trim) * 45.0f / 400;
servo_pitch += (1.0f - ch2_inf) * (ch2_in - ch2_trim) * 45.0f / 400;


To this:

// Mix in stick inputs in STABILIZE mode or if AP_STICK_MIXING = 1
// ---------------------------------
if (REVERSE_ROLL == 1) {
servo_roll += (1.0f - ch1_inf) * (ch1_in - ch1_trim) * 45.0f / 400;
} else {
servo_roll -= (1.0f - ch1_inf) * (ch1_in - ch1_trim) * 45.0f / 400;
}
if (REVERSE_PITCH == 1) {
servo_pitch += (1.0f - ch2_inf) * (ch2_in - ch2_trim) * 45.0f / 400;
} else {
servo_pitch -= (1.0f - ch2_inf) * (ch2_in - ch2_trim) * 45.0f / 400;
}

Let me know if it's a reasonable solution...thanks!

JC
Yeah JC that is fine. You can do it a bit cleaner by just multiplying in the reverse parameters. I will get it added on the next revision.
hi
is it normal I've got no manual control over throttle while in stabilize mode (throttle is fixed at about 20%) ?

regards

Reply to Discussion

RSS

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service