-
Notifications
You must be signed in to change notification settings - Fork 365
Fied wing updates #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fied wing updates #304
Changes from 13 commits
ce866ac
39a986b
f2066ac
e5b6ad3
57a4b9d
e9f73c0
a8b4ff1
912220a
c80cc71
a75f59f
f90a1d1
e912073
5991dc9
9905832
4b3564a
0bbef09
44b2f32
c32a76e
9d83e01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,7 +156,7 @@ const mixer_t mixers[] = { | |
| { 8, 0, mixerOctoX8 }, // MULTITYPE_OCTOX8 | ||
| { 8, 0, mixerOctoFlatP }, // MULTITYPE_OCTOFLATP | ||
| { 8, 0, mixerOctoFlatX }, // MULTITYPE_OCTOFLATX | ||
| { 1, 1, NULL }, // * MULTITYPE_AIRPLANE | ||
| { 2, 1, mixerTrustVector }, // * MULTITYPE_AIRPLANE | ||
| { 0, 1, NULL }, // * MULTITYPE_HELI_120_CCPM | ||
| { 0, 1, NULL }, // * MULTITYPE_HELI_90_DEG | ||
| { 4, 0, mixerVtail4 }, // MULTITYPE_VTAIL4 | ||
|
|
@@ -166,7 +166,7 @@ const mixer_t mixers[] = { | |
| { 1, 1, NULL }, // MULTITYPE_SINGLECOPTER | ||
| { 4, 0, mixerAtail4 }, // MULTITYPE_ATAIL4 | ||
| { 0, 0, NULL }, // MULTITYPE_CUSTOM | ||
| { 1, 1, NULL }, // MULTITYPE_CUSTOM_PLANE | ||
| { 2, 1, mixerTrustVector }, // MULTITYPE_CUSTOM_PLANE | ||
| }; | ||
|
|
||
| // mixer rule format servo, input, rate, speed, min, max, box | ||
|
|
@@ -545,15 +545,18 @@ void mixTable(void) | |
| } | ||
|
|
||
| // motors for non-servo mixes | ||
| if (numberMotor > 1) | ||
| for (i = 0; i < numberMotor; i++) | ||
| if (numberMotor > 1) { | ||
| for (i = 0; i < numberMotor; i++) { | ||
| motor[i] = rcCommand[THROTTLE] * currentMixer[i].throttle + axisPID[PITCH] * currentMixer[i].pitch + axisPID[ROLL] * currentMixer[i].roll + -cfg.yaw_direction * axisPID[YAW] * currentMixer[i].yaw; | ||
|
|
||
| if (f.FIXED_WING) { | ||
| if (!f.ARMED) | ||
| motor[0] = mcfg.mincommand; // Kill throttle when disarmed | ||
| else | ||
| motor[0] = constrain(rcCommand[THROTTLE], mcfg.minthrottle, mcfg.maxthrottle); | ||
| if (f.FIXED_WING) { // vector_trust handeling | ||
| if (cfg.fw_vector_trust) { | ||
| if (f.PASSTHRU_MODE) | ||
| motor[i] = rcCommand[THROTTLE] - rcCommand[YAW] * (i - 0.5f); | ||
| } else { // Override mixerTrustVector | ||
| motor[i] = rcCommand[THROTTLE]; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There has to be a better way to write the above, I don't understand what current version does so surely there's a simpler way.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I'm actually not understanding why this is necessary?
Is this correct?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's vector THRUST. if cfg.fw_vector_trust = false The for loop is used to write motor[i] = |
||
|
|
||
| // airplane / servo mixes | ||
|
|
@@ -639,6 +642,7 @@ void mixTable(void) | |
| } | ||
| if (!f.ARMED) { | ||
| motor[i] = motor_disarmed[i]; | ||
| f.MOTORS_STOPPED = 1; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,17 +109,40 @@ void annexCode(void) | |
| static int64_t mAhdrawnRaw = 0; | ||
| static int32_t vbatCycleTime = 0; | ||
|
|
||
| // PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value | ||
| if (rcData[THROTTLE] < cfg.tpa_breakpoint) { | ||
| prop2 = 100; | ||
| if (!f.FIXED_WING) { // Baseflight original dynamic PID adjustemnt | ||
| // PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value | ||
| if (rcData[THROTTLE] < cfg.tpa_breakpoint) { | ||
| prop2 = 100; | ||
| } else { | ||
| if (rcData[THROTTLE] < 2000) { | ||
| prop2 = 100 - (uint16_t)cfg.dynThrPID * (rcData[THROTTLE] - cfg.tpa_breakpoint) / (2000 - cfg.tpa_breakpoint); | ||
| } else { | ||
| prop2 = 100 - cfg.dynThrPID; | ||
| } | ||
| } | ||
| } else { | ||
| if (rcData[THROTTLE] < 2000) { | ||
| prop2 = 100 - (uint16_t)cfg.dynThrPID * (rcData[THROTTLE] - cfg.tpa_breakpoint) / (2000 - cfg.tpa_breakpoint); | ||
| // Throttle & Angle combined PID Attenuation | ||
| // Will dampen the PID's in High speeds dive on Fixed Wing Only | ||
| prop2 = 128; // prop2 was 100, is 128 now | ||
| if (rcData[THROTTLE] < cfg.tpa_breakpoint) { | ||
| prop2 = 128; // Higher prop2 for Fixed wing Same as used in MWii | ||
| } else { | ||
| prop2 = 100 - cfg.dynThrPID; | ||
| if (rcCommand[THROTTLE] > cfg.dynThrPID) { // Using rcCommand() to include Tpa even in Gps modes. | ||
| if (rcCommand[THROTTLE] < 2000) { | ||
| prop2 -= ((uint16_t)cfg.dynThrPID * (rcCommand[THROTTLE] - cfg.dynThrPID) >> 9); | ||
| } else { | ||
| prop2 -= cfg.dynThrPID; | ||
| } | ||
| } | ||
| } | ||
| // APA dynamic PID adjustemnt, depending on Angle of attack | ||
| uint16_t MaxBrkpoint = 300; // Max angle | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this variable is not at start of scope |
||
| if (angle[1] > 20) | ||
| prop2 -= ((uint16_t)cfg.dynThrPID * (min(angle[1], MaxBrkpoint)) >> 8); | ||
| prop2 = max((128 - cfg.dynThrPID), prop2); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's copypasted code here and its function is unclear.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding Dive angle to TPA for Fixed wing.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, but this code duplicates already stupid code. what does it acutally do and can it be rewritten better?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High speed can cause Wobbling (overcorrection) The function works good and i don't know how to improve it atm.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but if that's what it does, then the whole shit can be replaced with On Sun, Jan 3, 2016 at 3:11 AM, EmilsPa notifications@github.com wrote:
|
||
|
|
||
|
|
||
| for (axis = 0; axis < 3; axis++) { | ||
| tmp = min(abs(rcData[axis] - mcfg.midrc), 500); | ||
| if (axis != 2) { // ROLL & PITCH | ||
|
|
@@ -691,6 +714,11 @@ void loop(void) | |
| auxState |= (rcData[AUX1 + i] < 1300) << (3 * i) | (1300 < rcData[AUX1 + i] && rcData[AUX1 + i] < 1700) << (3 * i + 1) | (rcData[AUX1 + i] > 1700) << (3 * i + 2); | ||
| for (i = 0; i < CHECKBOXITEMS; i++) | ||
| rcOptions[i] = (auxState & cfg.activate[i]) > 0; | ||
| f.CRUISE_MODE = rcOptions[BOXGCRUISE]; | ||
| if (f.CRUISE_MODE) { | ||
| rcOptions[BOXGPSHOLD] = true; | ||
| rcOptions[BOXHORIZON] = true; | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will above change somehow affect quads if selected?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No |
||
| // note: if FAILSAFE is disable, failsafeCnt > 5 * FAILSAVE_DELAY is always false | ||
| if ((rcOptions[BOXANGLE] || (failsafeCnt > 5 * cfg.failsafe_delay)) && (sensors(SENSOR_ACC))) { | ||
|
|
@@ -782,6 +810,9 @@ void loop(void) | |
| #ifdef GPS | ||
| if (sensors(SENSOR_GPS)) { | ||
| if (f.GPS_FIX && GPS_numSat >= 5) { | ||
| if (nav_mode != NAV_MODE_NONE && (!f.HORIZON_MODE && !f.ANGLE_MODE)) | ||
| f.ANGLE_MODE = true; // Force a stable mode in GPS Mode | ||
|
|
||
| // if both GPS_HOME & GPS_HOLD are checked => GPS_HOME is the priority | ||
| if (rcOptions[BOXGPSHOME] || f.FW_FAILSAFE_RTH_ENABLE ) { | ||
| if (!f.GPS_HOME_MODE) { | ||
|
|
@@ -832,7 +863,7 @@ void loop(void) | |
| f.PASSTHRU_MODE = 0; | ||
| } | ||
|
|
||
| if (mcfg.mixerConfiguration == MULTITYPE_FLYING_WING || mcfg.mixerConfiguration == MULTITYPE_AIRPLANE || mcfg.mixerConfiguration == MULTITYPE_CUSTOM_PLANE) { | ||
| if (f.FIXED_WING) { | ||
| f.HEADFREE_MODE = 0; | ||
| if (feature(FEATURE_FAILSAFE) && failsafeCnt > (6 * cfg.failsafe_delay)) { | ||
| f.PASSTHRU_MODE = 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing
scaler = (GEO_SKAL... etc